Issue #2636 - Scheduling refactor. Single scheduling method now.
Review comments Change-Id: I4d1e7c171504a8a6f97d4660bf165857dd6e7e58 Former-commit-id:eee642ac9b
[formerly fc9ed661c3fe3ca75d30d8df414b5d1cd5725613] Former-commit-id:eb46191ba9
This commit is contained in:
parent
64f55c6b02
commit
684390e599
36 changed files with 1127 additions and 850 deletions
|
@ -22,8 +22,10 @@ package com.raytheon.uf.common.datadelivery.registry.handlers;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -60,6 +62,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
|
||||
* Jan 14, 2014 2459 mpduff Validate subs should be scheduled before returning them.
|
||||
* Jan 17, 2014 2459 mpduff Persist the state of the expired subs.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -198,14 +201,14 @@ public abstract class BaseSubscriptionHandler<T extends Subscription, QUERY exte
|
|||
@Override
|
||||
public List<T> getActiveForRoute(Network route)
|
||||
throws RegistryHandlerException {
|
||||
return getActiveForRoutes(route);
|
||||
return getActiveForRoutes(route).get(route);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getActiveForRoutes(Network... routes)
|
||||
public Map<Network, List<T>> getActiveForRoutes(Network... routes)
|
||||
throws RegistryHandlerException {
|
||||
SubscriptionFilterableQuery<T> query = getQuery();
|
||||
query.setActive(true);
|
||||
|
@ -215,10 +218,13 @@ public abstract class BaseSubscriptionHandler<T extends Subscription, QUERY exte
|
|||
|
||||
checkResponse(response, "getActiveForRoutes");
|
||||
|
||||
List<T> returnList = new ArrayList<T>();
|
||||
Map<Network, List<T>> returnMap = new HashMap<Network, List<T>>();
|
||||
for (Network network : routes) {
|
||||
returnMap.put(network, new ArrayList<T>());
|
||||
}
|
||||
for (T sub : response.getResults()) {
|
||||
if (((RecurringSubscription) sub).shouldSchedule()) {
|
||||
returnList.add(sub);
|
||||
returnMap.get(sub.getRoute()).add(sub);
|
||||
} else if (((RecurringSubscription) sub).shouldUpdate()) {
|
||||
updateList.add(sub);
|
||||
}
|
||||
|
@ -250,6 +256,6 @@ public abstract class BaseSubscriptionHandler<T extends Subscription, QUERY exte
|
|||
});
|
||||
}
|
||||
|
||||
return returnList;
|
||||
return returnMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
package com.raytheon.uf.common.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
|
||||
|
@ -37,6 +39,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 20, 2014 2538 mpduff Initial creation
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -102,10 +105,10 @@ public class EmptyAdhocSubscriptionHandler implements IAdhocSubscriptionHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<AdhocSubscription> getActiveForRoutes(Network... routes)
|
||||
throws RegistryHandlerException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public Map<Network, List<AdhocSubscription>> getActiveForRoutes(
|
||||
Network... routes) throws RegistryHandlerException {
|
||||
// an empty map
|
||||
return new HashMap<Network, List<AdhocSubscription>>(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,9 @@ package com.raytheon.uf.common.datadelivery.registry.handlers;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
|
@ -40,7 +42,8 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 4, 2013 2545 bgonzale Initial creation
|
||||
* Nov 04, 2013 2545 bgonzale Initial creation
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -51,8 +54,13 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
public class EmptySharedSubscriptionHandler implements
|
||||
ISharedSubscriptionHandler {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionTypeHandler#getByPendingSubscription(com.raytheon.uf.common.datadelivery.registry.PendingSubscription)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* ISubscriptionTypeHandler
|
||||
* #getByPendingSubscription(com.raytheon.uf.common.datadelivery
|
||||
* .registry.PendingSubscription)
|
||||
*/
|
||||
@Override
|
||||
public SharedSubscription getByPendingSubscription(
|
||||
|
@ -60,8 +68,11 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionTypeHandler#getByPendingSubscriptionId(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* ISubscriptionTypeHandler#getByPendingSubscriptionId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SharedSubscription getByPendingSubscriptionId(String id)
|
||||
|
@ -69,8 +80,12 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionTypeHandler#getActiveByDataSetAndProvider(java.lang.String, java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* ISubscriptionTypeHandler#getActiveByDataSetAndProvider(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getActiveByDataSetAndProvider(
|
||||
|
@ -79,8 +94,11 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByName(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SharedSubscription getByName(String name)
|
||||
|
@ -88,8 +106,11 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByNames(java.util.Collection)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByNames(java.util.Collection)
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getByNames(Collection<String> names)
|
||||
|
@ -97,8 +118,11 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByOwner(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByOwner(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getByOwner(String owner)
|
||||
|
@ -106,8 +130,11 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByGroupName(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByGroupName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getByGroupName(String group)
|
||||
|
@ -115,8 +142,11 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByFilters(java.lang.String, java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByFilters(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getByFilters(String group, String officeId)
|
||||
|
@ -124,8 +154,11 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getSubscribedToDataSetNames(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getSubscribedToDataSetNames(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getSubscribedToDataSetNames(String siteId)
|
||||
|
@ -133,16 +166,23 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return Collections.EMPTY_SET;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getActive()
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getActive()
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getActive() throws RegistryHandlerException {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getActiveForRoute(com.raytheon.uf.common.datadelivery.registry.Network)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler
|
||||
* #getActiveForRoute(com.raytheon.uf.common.datadelivery.registry.Network)
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getActiveForRoute(Network route)
|
||||
|
@ -150,17 +190,26 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getActiveForRoutes(com.raytheon.uf.common.datadelivery.registry.Network[])
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler
|
||||
* #getActiveForRoutes(com.raytheon.uf.common.datadelivery
|
||||
* .registry.Network[])
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getActiveForRoutes(Network... routes)
|
||||
throws RegistryHandlerException {
|
||||
return Collections.EMPTY_LIST;
|
||||
public Map<Network, List<SharedSubscription>> getActiveForRoutes(
|
||||
Network... routes) throws RegistryHandlerException {
|
||||
return new HashMap<Network, List<SharedSubscription>>(0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#getById(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#getById
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SharedSubscription getById(String id)
|
||||
|
@ -168,69 +217,104 @@ public class EmptySharedSubscriptionHandler implements
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#getAll()
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#getAll()
|
||||
*/
|
||||
@Override
|
||||
public List<SharedSubscription> getAll() throws RegistryHandlerException {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#store(java.lang.Object)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#store(
|
||||
* java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(SharedSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#update(java.lang.Object)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#update
|
||||
* (java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void update(SharedSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete(java.lang.Object)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete
|
||||
* (java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void delete(SharedSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#deleteById(java.lang.String, java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#deleteById
|
||||
* (java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(String username, String registryId)
|
||||
throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#deleteByIds(java.lang.String, java.util.List)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#deleteByIds
|
||||
* (java.lang.String, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(String username, List<String> registryIds)
|
||||
throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete(java.lang.String, java.lang.Object)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete
|
||||
* (java.lang.String, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void delete(String username, SharedSubscription obj)
|
||||
throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete(java.util.Collection)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete
|
||||
* (java.util.Collection)
|
||||
*/
|
||||
@Override
|
||||
public void delete(Collection<SharedSubscription> objects)
|
||||
throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete(java.lang.String, java.util.Collection)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete
|
||||
* (java.lang.String, java.util.Collection)
|
||||
*/
|
||||
@Override
|
||||
public void delete(String username, Collection<SharedSubscription> objects)
|
||||
|
|
|
@ -21,7 +21,9 @@ package com.raytheon.uf.common.datadelivery.registry.handlers;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
|
@ -40,7 +42,8 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 4, 2013 2545 bgonzale Initial creation
|
||||
* Nov 04, 2013 2545 bgonzale Initial creation
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,8 +53,13 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
|
||||
public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionTypeHandler#getByPendingSubscription(com.raytheon.uf.common.datadelivery.registry.PendingSubscription)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* ISubscriptionTypeHandler
|
||||
* #getByPendingSubscription(com.raytheon.uf.common.datadelivery
|
||||
* .registry.PendingSubscription)
|
||||
*/
|
||||
@Override
|
||||
public SiteSubscription getByPendingSubscription(PendingSubscription pending)
|
||||
|
@ -59,8 +67,11 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionTypeHandler#getByPendingSubscriptionId(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* ISubscriptionTypeHandler#getByPendingSubscriptionId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SiteSubscription getByPendingSubscriptionId(String id)
|
||||
|
@ -68,8 +79,12 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionTypeHandler#getActiveByDataSetAndProvider(java.lang.String, java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* ISubscriptionTypeHandler#getActiveByDataSetAndProvider(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getActiveByDataSetAndProvider(
|
||||
|
@ -78,8 +93,11 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByName(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SiteSubscription getByName(String name)
|
||||
|
@ -87,8 +105,11 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByNames(java.util.Collection)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByNames(java.util.Collection)
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getByNames(Collection<String> names)
|
||||
|
@ -96,8 +117,11 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByOwner(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByOwner(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getByOwner(String owner)
|
||||
|
@ -105,8 +129,11 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByGroupName(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByGroupName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getByGroupName(String group)
|
||||
|
@ -114,8 +141,11 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getByFilters(java.lang.String, java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getByFilters(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getByFilters(String group, String officeId)
|
||||
|
@ -123,8 +153,11 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getSubscribedToDataSetNames(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getSubscribedToDataSetNames(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getSubscribedToDataSetNames(String siteId)
|
||||
|
@ -132,16 +165,23 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return Collections.EMPTY_SET;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getActive()
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler#getActive()
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getActive() throws RegistryHandlerException {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getActiveForRoute(com.raytheon.uf.common.datadelivery.registry.Network)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler
|
||||
* #getActiveForRoute(com.raytheon.uf.common.datadelivery.registry.Network)
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getActiveForRoute(Network route)
|
||||
|
@ -149,86 +189,130 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler#getActiveForRoutes(com.raytheon.uf.common.datadelivery.registry.Network[])
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.datadelivery.registry.handlers.
|
||||
* IBaseSubscriptionHandler
|
||||
* #getActiveForRoutes(com.raytheon.uf.common.datadelivery
|
||||
* .registry.Network[])
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getActiveForRoutes(Network... routes)
|
||||
throws RegistryHandlerException {
|
||||
return Collections.EMPTY_LIST;
|
||||
public Map<Network, List<SiteSubscription>> getActiveForRoutes(
|
||||
Network... routes) throws RegistryHandlerException {
|
||||
return new HashMap<Network, List<SiteSubscription>>(0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#getById(java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#getById
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SiteSubscription getById(String id) throws RegistryHandlerException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#getAll()
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#getAll()
|
||||
*/
|
||||
@Override
|
||||
public List<SiteSubscription> getAll() throws RegistryHandlerException {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#store(java.lang.Object)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#store(
|
||||
* java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(SiteSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#update(java.lang.Object)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#update
|
||||
* (java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void update(SiteSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete(java.lang.Object)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete
|
||||
* (java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void delete(SiteSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#deleteById(java.lang.String, java.lang.String)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#deleteById
|
||||
* (java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(String username, String registryId)
|
||||
throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#deleteByIds(java.lang.String, java.util.List)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#deleteByIds
|
||||
* (java.lang.String, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(String username, List<String> registryIds)
|
||||
throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete(java.lang.String, java.lang.Object)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete
|
||||
* (java.lang.String, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void delete(String username, SiteSubscription obj)
|
||||
throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete(java.util.Collection)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete
|
||||
* (java.util.Collection)
|
||||
*/
|
||||
@Override
|
||||
public void delete(Collection<SiteSubscription> objects)
|
||||
throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete(java.lang.String, java.util.Collection)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.registry.handler.IRegistryObjectHandler#delete
|
||||
* (java.lang.String, java.util.Collection)
|
||||
*/
|
||||
@Override
|
||||
public void delete(String username, Collection<SiteSubscription> objects)
|
||||
|
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.common.datadelivery.registry.handlers;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
|
@ -44,6 +45,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* Feb 20, 2013 1543 djohnson Add ability to filter on routes.
|
||||
* May 28, 2013 1650 djohnson Add getByNames.
|
||||
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -151,6 +153,6 @@ public interface IBaseSubscriptionHandler<T extends Subscription> extends
|
|||
* @throws RegistryHandlerException
|
||||
* on error
|
||||
*/
|
||||
List<T> getActiveForRoutes(Network... routes)
|
||||
Map<Network, List<T>> getActiveForRoutes(Network... routes)
|
||||
throws RegistryHandlerException;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ package com.raytheon.uf.common.datadelivery.registry.handlers;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -54,6 +56,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
* May 28, 2013 1650 djohnson Add getByNames.
|
||||
* May 29, 2013 1650 djohnson Fix ability to delete multiple types of subscriptions at once.
|
||||
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -186,12 +189,36 @@ public class PendingSubscriptionHandler implements IPendingSubscriptionHandler {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<InitialPendingSubscription> getActiveForRoutes(
|
||||
public Map<Network, List<InitialPendingSubscription>> getActiveForRoutes(
|
||||
Network... routes) throws RegistryHandlerException {
|
||||
List<InitialPendingSubscription> subs = Lists.newArrayList();
|
||||
subs.addAll(siteSubscriptionHandler.getActiveForRoutes(routes));
|
||||
subs.addAll(sharedSubscriptionHandler.getActiveForRoutes(routes));
|
||||
return subs;
|
||||
Map<Network, List<InitialPendingSubscription>> returnMap = new HashMap<Network, List<InitialPendingSubscription>>(
|
||||
2);
|
||||
|
||||
Map<Network, List<InitialPendingSiteSubscription>> subMap = siteSubscriptionHandler
|
||||
.getActiveForRoutes(routes);
|
||||
returnMap
|
||||
.putAll((Map<? extends Network, ? extends List<InitialPendingSubscription>>) subMap);
|
||||
|
||||
Map<Network, List<InitialPendingSharedSubscription>> sharedSubMap = sharedSubscriptionHandler
|
||||
.getActiveForRoutes(routes);
|
||||
|
||||
// Check for existing networks and add to them if they exist
|
||||
for (Map.Entry<Network, List<InitialPendingSharedSubscription>> entry : sharedSubMap
|
||||
.entrySet()) {
|
||||
Network key = entry.getKey();
|
||||
if (returnMap.containsKey(key)) {
|
||||
returnMap.get(key).addAll(entry.getValue());
|
||||
} else {
|
||||
List<InitialPendingSharedSubscription> sharedList = entry
|
||||
.getValue();
|
||||
|
||||
returnMap.put(key, new ArrayList<InitialPendingSubscription>(
|
||||
sharedList.size()));
|
||||
returnMap.get(key).addAll(sharedList);
|
||||
}
|
||||
}
|
||||
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,9 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -59,6 +62,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
* May 31, 2013 1650 djohnson Fix ability to get shared subscriptions by id.
|
||||
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
|
||||
* Jan 20, 2014 2538 mpduff Added AdhocSubscriptionHandler.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -250,12 +254,32 @@ public class SubscriptionHandler implements ISubscriptionHandler {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Subscription> getActiveForRoutes(Network... routes)
|
||||
throws RegistryHandlerException {
|
||||
List<Subscription> subs = Lists.newArrayList();
|
||||
subs.addAll(siteSubscriptionHandler.getActiveForRoutes(routes));
|
||||
subs.addAll(sharedSubscriptionHandler.getActiveForRoutes(routes));
|
||||
return subs;
|
||||
public Map<Network, List<Subscription>> getActiveForRoutes(
|
||||
Network... routes) throws RegistryHandlerException {
|
||||
Map<Network, List<Subscription>> returnMap = new HashMap<Network, List<Subscription>>();
|
||||
Map<Network, List<SiteSubscription>> subMap = siteSubscriptionHandler
|
||||
.getActiveForRoutes(routes);
|
||||
returnMap
|
||||
.putAll((Map<? extends Network, ? extends List<Subscription>>) subMap);
|
||||
|
||||
Map<Network, List<SharedSubscription>> sharedSubMap = sharedSubscriptionHandler
|
||||
.getActiveForRoutes(routes);
|
||||
// Check for existing networks and add to them if they exist
|
||||
for (Map.Entry<Network, List<SharedSubscription>> entry : sharedSubMap
|
||||
.entrySet()) {
|
||||
Network key = entry.getKey();
|
||||
if (returnMap.containsKey(key)) {
|
||||
returnMap.get(key).addAll(entry.getValue());
|
||||
} else {
|
||||
List<SharedSubscription> sharedList = entry.getValue();
|
||||
|
||||
returnMap.put(key,
|
||||
new ArrayList<Subscription>(sharedList.size()));
|
||||
returnMap.get(key).addAll(sharedList);
|
||||
}
|
||||
}
|
||||
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,15 +11,15 @@
|
|||
<value>SBN</value>
|
||||
</util:list>
|
||||
|
||||
<bean id="findActiveSubscriptionsForRoute"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.FindActiveSubscriptionsForRoute">
|
||||
<constructor-arg ref="localSubscriptionHandler" />
|
||||
<constructor-arg ref="subscriptionRoutesToSchedule" />
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthInitializer"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthInitializer">
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.FindActiveSubscriptionsForRoute">
|
||||
<constructor-arg ref="SubscriptionHandler" />
|
||||
<constructor-arg ref="subscriptionRoutesToSchedule" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg ref="findActiveSubscriptionsForRoute" />
|
||||
</bean>
|
||||
|
||||
<bean id="opsnetSubscriptionRetrievalAgentPrototype"
|
||||
|
|
|
@ -26,19 +26,19 @@
|
|||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="findActiveSubscriptionsForRoute"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.FindActiveSubscriptionsForRoute">
|
||||
<constructor-arg ref="localSubscriptionHandler" />
|
||||
<constructor-arg ref="subscriptionRoutesToSchedule" />
|
||||
</bean>
|
||||
|
||||
<util:list id="subscriptionRoutesToSchedule">
|
||||
<value>SBN</value>
|
||||
</util:list>
|
||||
|
||||
<bean id="bandwidthInitializer"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthInitializer">
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.FindActiveSubscriptionsForRoute">
|
||||
<constructor-arg ref="sharedSubscriptionHandler" />
|
||||
<constructor-arg ref="subscriptionRoutesToSchedule" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg ref="findActiveSubscriptionsForRoute" />
|
||||
</bean>
|
||||
|
||||
<bean id="sbnSubscriptionRetrievalAgentPrototype"
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.I
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
||||
|
||||
|
@ -51,6 +52,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Nov 13, 2013 2545 bgonzale Initial creation
|
||||
* Dec 04, 2013 2566 bgonzale use bandwidthmanager method to retrieve spring files.
|
||||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||
* Jan 30, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -78,16 +80,20 @@ public class MonolithicBandwidthManagerCreator<T extends Time, C extends Coverag
|
|||
* @param retrievalManager
|
||||
* @param bandwidthDaoUtil
|
||||
*/
|
||||
public MonolithicBandwidthManager(IBandwidthDbInit dbInit,
|
||||
IBandwidthDao<T, C> bandwidthDao, RetrievalManager retrievalManager,
|
||||
public MonolithicBandwidthManager(
|
||||
IBandwidthDbInit dbInit,
|
||||
IBandwidthDao<T, C> bandwidthDao,
|
||||
RetrievalManager retrievalManager,
|
||||
BandwidthDaoUtil<T, C> bandwidthDaoUtil,
|
||||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
|
||||
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil,
|
||||
dataSetMetaDataHandler, subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService);
|
||||
dataSetMetaDataHandler, subscriptionHandler,
|
||||
adhocSubscriptionHandler, subscriptionNotificationService,
|
||||
findSubscriptionsStrategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,11 +113,12 @@ public class MonolithicBandwidthManagerCreator<T extends Time, C extends Coverag
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
|
||||
return new MonolithicBandwidthManager(dbInit, bandwidthDao,
|
||||
retrievalManager,
|
||||
bandwidthDaoUtil, dataSetMetaDataHandler, subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService);
|
||||
retrievalManager, bandwidthDaoUtil, dataSetMetaDataHandler,
|
||||
subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService, findSubscriptionsStrategy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthManager;
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
||||
|
||||
|
@ -70,12 +71,14 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class NcfBandwidthManagerCreator<T extends Time, C extends Coverage> implements IEdexBandwidthManagerCreator<T, C> {
|
||||
public class NcfBandwidthManagerCreator<T extends Time, C extends Coverage>
|
||||
implements IEdexBandwidthManagerCreator<T, C> {
|
||||
|
||||
/**
|
||||
* NCF {@link BandwidthManager} implementation.
|
||||
*/
|
||||
static class NcfBandwidthManager<T extends Time, C extends Coverage> extends EdexBandwidthManager<T, C> {
|
||||
static class NcfBandwidthManager<T extends Time, C extends Coverage>
|
||||
extends EdexBandwidthManager<T, C> {
|
||||
|
||||
private static final String MODE_NAME = "centralRegistry";
|
||||
|
||||
|
@ -89,16 +92,20 @@ public class NcfBandwidthManagerCreator<T extends Time, C extends Coverage> impl
|
|||
* @param retrievalManager
|
||||
* @param bandwidthDaoUtil
|
||||
*/
|
||||
public NcfBandwidthManager(IBandwidthDbInit dbInit,
|
||||
IBandwidthDao<T, C> bandwidthDao, RetrievalManager retrievalManager,
|
||||
public NcfBandwidthManager(
|
||||
IBandwidthDbInit dbInit,
|
||||
IBandwidthDao<T, C> bandwidthDao,
|
||||
RetrievalManager retrievalManager,
|
||||
BandwidthDaoUtil<T, C> bandwidthDaoUtil,
|
||||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
|
||||
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil,
|
||||
dataSetMetaDataHandler, subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService);
|
||||
dataSetMetaDataHandler, subscriptionHandler,
|
||||
adhocSubscriptionHandler, subscriptionNotificationService,
|
||||
findSubscriptionsStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,7 +147,8 @@ public class NcfBandwidthManagerCreator<T extends Time, C extends Coverage> impl
|
|||
*/
|
||||
@Override
|
||||
protected Set<String> scheduleSbnSubscriptions(
|
||||
List<Subscription<T, C>> subscriptions) throws SerializationException {
|
||||
List<Subscription<T, C>> subscriptions)
|
||||
throws SerializationException {
|
||||
return scheduleSubscriptions(subscriptions);
|
||||
}
|
||||
}
|
||||
|
@ -155,10 +163,12 @@ public class NcfBandwidthManagerCreator<T extends Time, C extends Coverage> impl
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
|
||||
return new NcfBandwidthManager(dbInit, bandwidthDao, retrievalManager,
|
||||
bandwidthDaoUtil, dataSetMetaDataHandler, subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService);
|
||||
bandwidthDaoUtil, dataSetMetaDataHandler, subscriptionHandler,
|
||||
adhocSubscriptionHandler, subscriptionNotificationService,
|
||||
findSubscriptionsStrategy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,11 +38,11 @@ Require-Bundle: com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
|||
org.quartz;bundle-version="1.8.6"
|
||||
Export-Package: com.raytheon.uf.edex.datadelivery.bandwidth,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.dao,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.hibernate,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.interfaces,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.processing,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.registry,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.retrieval,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.registry,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.util
|
||||
Import-Package: com.raytheon.uf.common.datadelivery.event.retrieval,
|
||||
com.raytheon.uf.common.datadelivery.registry,
|
||||
|
|
|
@ -26,19 +26,19 @@
|
|||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="findActiveSubscriptionsForRoute"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.FindActiveSubscriptionsForRoute">
|
||||
<constructor-arg ref="localSubscriptionHandler" />
|
||||
<constructor-arg ref="subscriptionRoutesToSchedule" />
|
||||
</bean>
|
||||
|
||||
<util:list id="subscriptionRoutesToSchedule">
|
||||
<value>OPSNET</value>
|
||||
</util:list>
|
||||
|
||||
<bean id="bandwidthInitializer"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthInitializer">
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.FindActiveSubscriptionsForRoute">
|
||||
<constructor-arg ref="localSubscriptionHandler" />
|
||||
<constructor-arg ref="subscriptionRoutesToSchedule" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg ref="findActiveSubscriptionsForRoute" />
|
||||
</bean>
|
||||
|
||||
<bean id="opsnetSubscriptionRetrievalAgentPrototype"
|
||||
|
|
|
@ -50,5 +50,6 @@
|
|||
<constructor-arg ref="SubscriptionHandler" />
|
||||
<constructor-arg ref="AdhocSubscriptionHandler" />
|
||||
<constructor-arg ref="subscriptionNotificationService" />
|
||||
<constructor-arg ref="findActiveSubscriptionsForRoute" />
|
||||
</bean>
|
||||
</beans>
|
|
@ -140,6 +140,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
* Jan 14, 2014 2459 mpduff Change to subscription status.
|
||||
* Jan 25, 2014 2636 mpduff Don't do an initial adhoc query for a new subscription.
|
||||
* Jan 24, 2013 2709 bgonzale Before scheduling adhoc, check if in active period window.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -174,6 +175,10 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
@VisibleForTesting
|
||||
final RetrievalManager retrievalManager;
|
||||
|
||||
/** Map of Network->previous retrieval plan end time */
|
||||
private final Map<Network, Calendar> previousRetrievalEndMap = new HashMap<Network, Calendar>(
|
||||
1);
|
||||
|
||||
public BandwidthManager(IBandwidthDbInit dbInit,
|
||||
IBandwidthDao<T, C> bandwidthDao,
|
||||
RetrievalManager retrievalManager,
|
||||
|
@ -182,6 +187,11 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
this.bandwidthDao = bandwidthDao;
|
||||
this.retrievalManager = retrievalManager;
|
||||
this.bandwidthDaoUtil = bandwidthDaoUtil;
|
||||
for (Network network : retrievalManager.getRetrievalPlans().keySet()) {
|
||||
RetrievalPlan plan = retrievalManager.getRetrievalPlans().get(
|
||||
network);
|
||||
previousRetrievalEndMap.put(network, plan.getPlanEnd());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,9 +223,9 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
}
|
||||
|
||||
private List<BandwidthAllocation> schedule(Subscription<T, C> subscription,
|
||||
SortedSet<Integer> cycles) {
|
||||
SortedSet<Integer> cycles, Calendar start, Calendar end) {
|
||||
SortedSet<Calendar> retrievalTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, cycles);
|
||||
.getRetrievalTimes(subscription, cycles, start, end);
|
||||
|
||||
return scheduleSubscriptionForRetrievalTimes(subscription,
|
||||
retrievalTimes);
|
||||
|
@ -232,9 +242,9 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
* @return the list of unscheduled subscriptions
|
||||
*/
|
||||
private List<BandwidthAllocation> schedule(Subscription<T, C> subscription,
|
||||
int retrievalInterval) {
|
||||
int retrievalInterval, Calendar start, Calendar end) {
|
||||
SortedSet<Calendar> retrievalTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, retrievalInterval);
|
||||
.getRetrievalTimes(subscription, retrievalInterval, start, end);
|
||||
|
||||
return scheduleSubscriptionForRetrievalTimes(subscription,
|
||||
retrievalTimes);
|
||||
|
@ -444,30 +454,82 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
return unscheduled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a single subscription.
|
||||
*
|
||||
* @param sub
|
||||
* The subscription to schedule
|
||||
* @param fullSchedule
|
||||
* true to schedule for the full retrieval plan, false to
|
||||
* schedule from the last time
|
||||
* @return List of BandwidthAllocations that sould be unscheduled.
|
||||
*/
|
||||
public List<BandwidthAllocation> schedule(Subscription<T, C> sub,
|
||||
boolean fullSchedule) {
|
||||
Map<Network, List<Subscription<T, C>>> map = new HashMap<Network, List<Subscription<T, C>>>(
|
||||
1, 1);
|
||||
List<Subscription<T, C>> list = new ArrayList<Subscription<T, C>>(1);
|
||||
list.add(sub);
|
||||
map.put(sub.getRoute(), list);
|
||||
|
||||
return schedule(map, fullSchedule);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<BandwidthAllocation> schedule(Subscription<T, C> subscription) {
|
||||
// TODO: In 13.6.1 pull out all of the subscription stuff into a
|
||||
// separate plugin, BandwidthManager should not work with Subscription
|
||||
// objects directly, it should have extension plugins that can allocate
|
||||
// bandwidth in their own types (e.g. registry syncing should be able to
|
||||
// sync into the bandwidth management infrastructure if required)
|
||||
List<BandwidthAllocation> unscheduled;
|
||||
public List<BandwidthAllocation> schedule(
|
||||
Map<Network, List<Subscription<T, C>>> subMap, boolean fullSchedule) {
|
||||
List<BandwidthAllocation> unscheduled = new ArrayList<BandwidthAllocation>();
|
||||
|
||||
final DataType dataSetType = subscription.getDataSetType();
|
||||
switch (dataSetType) {
|
||||
case GRID:
|
||||
unscheduled = handleGridded(subscription);
|
||||
break;
|
||||
case POINT:
|
||||
unscheduled = handlePoint(subscription);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"The BandwidthManager doesn't know how to treat subscriptions with data type ["
|
||||
+ dataSetType + "]!");
|
||||
for (Network network : subMap.keySet()) {
|
||||
RetrievalPlan retrievalPlan = retrievalManager.getPlan(network);
|
||||
|
||||
/*
|
||||
* Determine scheduling window, true for whole plan, false to run
|
||||
* from last time
|
||||
*/
|
||||
Calendar start = retrievalPlan.getPlanStart();
|
||||
Calendar end = retrievalPlan.getPlanEnd();
|
||||
if (!fullSchedule) {
|
||||
if (!end.equals(this.previousRetrievalEndMap.get(network))) {
|
||||
start = this.previousRetrievalEndMap.get(network);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler.debug("Check for scheduling window: "
|
||||
+ start.getTime() + " - " + end.getTime());
|
||||
}
|
||||
if (end.getTimeInMillis() - start.getTimeInMillis() >= retrievalPlan
|
||||
.getBucketMinutes() * 2 * TimeUtil.MILLIS_PER_MINUTE) {
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler.debug("Scheduling for window: "
|
||||
+ start.getTime() + " - " + end.getTime());
|
||||
}
|
||||
this.previousRetrievalEndMap.put(network,
|
||||
TimeUtil.newGmtCalendar(end.getTime()));
|
||||
|
||||
for (Subscription subscription : subMap.get(network)) {
|
||||
statusHandler.info("Scheduling subscription"
|
||||
+ subscription.getName());
|
||||
final DataType dataSetType = subscription.getDataSetType();
|
||||
switch (dataSetType) {
|
||||
case GRID:
|
||||
unscheduled = handleGridded(subscription, start, end);
|
||||
break;
|
||||
case POINT:
|
||||
unscheduled = handlePoint(subscription, start, end);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"The BandwidthManager doesn't know how to treat subscriptions with data type ["
|
||||
+ dataSetType + "]!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unscheduleSubscriptionsForAllocations(unscheduled);
|
||||
|
@ -597,7 +659,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
if (bandwidthSubscriptions.isEmpty()
|
||||
&& ((RecurringSubscription) subscription).shouldSchedule()
|
||||
&& !subscription.isUnscheduled()) {
|
||||
return schedule(subscription);
|
||||
return schedule(subscription, true);
|
||||
} else if (subscription.getStatus() == SubscriptionStatus.DEACTIVATED
|
||||
|| subscription.isUnscheduled()) {
|
||||
// See if the subscription was deactivated or unscheduled..
|
||||
|
@ -607,7 +669,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
} else {
|
||||
// Normal update, unschedule old allocations and create new ones
|
||||
List<BandwidthAllocation> unscheduled = remove(bandwidthSubscriptions);
|
||||
unscheduled.addAll(schedule(subscription));
|
||||
unscheduled.addAll(schedule(subscription, true));
|
||||
return unscheduled;
|
||||
}
|
||||
}
|
||||
|
@ -621,9 +683,9 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
* @return the list of unscheduled subscriptions
|
||||
*/
|
||||
private List<BandwidthAllocation> handlePoint(
|
||||
Subscription<T, C> subscription) {
|
||||
Subscription<T, C> subscription, Calendar start, Calendar end) {
|
||||
List<BandwidthAllocation> unscheduled = schedule(subscription,
|
||||
((PointTime) subscription.getTime()).getInterval());
|
||||
((PointTime) subscription.getTime()).getInterval(), start, end);
|
||||
unscheduled.addAll(getMostRecent(subscription, false));
|
||||
return unscheduled;
|
||||
}
|
||||
|
@ -636,7 +698,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
* @return the list of unscheduled subscriptions
|
||||
*/
|
||||
private List<BandwidthAllocation> handleGridded(
|
||||
Subscription<T, C> subscription) {
|
||||
Subscription<T, C> subscription, Calendar start, Calendar end) {
|
||||
final List<Integer> cycles = ((GriddedTime) subscription.getTime())
|
||||
.getCycleTimes();
|
||||
final boolean subscribedToCycles = !CollectionUtil
|
||||
|
@ -646,7 +708,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
// expected times
|
||||
List<BandwidthAllocation> unscheduled = Collections.emptyList();
|
||||
if (subscribedToCycles) {
|
||||
unscheduled = schedule(subscription, Sets.newTreeSet(cycles));
|
||||
unscheduled = schedule(subscription, Sets.newTreeSet(cycles),
|
||||
start, end);
|
||||
}
|
||||
|
||||
return unscheduled;
|
||||
|
@ -1376,7 +1439,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
|
||||
// Now for each subscription, attempt to schedule bandwidth
|
||||
for (Subscription<T, C> subscription : actualSubscriptions) {
|
||||
unscheduled.addAll(this.schedule(subscription));
|
||||
unscheduled.addAll(this.schedule(subscription, true));
|
||||
}
|
||||
} else {
|
||||
// Otherwise we can just copy the entire state of the current system
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthContextFactory;
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthBucketDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.BandwidthInitializer;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
||||
|
@ -57,13 +58,15 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Oct 03, 2013 1797 dhladky Some generics
|
||||
* Nov 07, 2013 2506 bgonzale Added notification handler to bandwidth context.
|
||||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||
* Jan 30, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class EdexBandwidthContextFactory<T extends Time, C extends Coverage> implements BandwidthContextFactory {
|
||||
public class EdexBandwidthContextFactory<T extends Time, C extends Coverage>
|
||||
implements BandwidthContextFactory {
|
||||
|
||||
/**
|
||||
* Pluggable strategy for how to create the {@link BandwidthManager}.
|
||||
|
@ -83,12 +86,14 @@ public class EdexBandwidthContextFactory<T extends Time, C extends Coverage> imp
|
|||
* @return the bandwidth manager
|
||||
*/
|
||||
IBandwidthManager<T, C> getBandwidthManager(IBandwidthDbInit dbInit,
|
||||
IBandwidthDao<T, C> bandwidthDao, RetrievalManager retrievalManager,
|
||||
IBandwidthDao<T, C> bandwidthDao,
|
||||
RetrievalManager retrievalManager,
|
||||
BandwidthDaoUtil<T, C> bandwidthDaoUtil,
|
||||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService notificationService);
|
||||
ISubscriptionNotificationService notificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy);
|
||||
}
|
||||
|
||||
private static EdexBandwidthManager instance;
|
||||
|
@ -111,6 +116,8 @@ public class EdexBandwidthContextFactory<T extends Time, C extends Coverage> imp
|
|||
|
||||
private final ISubscriptionNotificationService notificationService;
|
||||
|
||||
private final IFindSubscriptionsForScheduling findSubscriptionsStrategy;
|
||||
|
||||
/**
|
||||
* Intentionally package-private constructor, as it is created from Spring
|
||||
* which is able to reflectively instantiate.
|
||||
|
@ -133,7 +140,8 @@ public class EdexBandwidthContextFactory<T extends Time, C extends Coverage> imp
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService notificationService) {
|
||||
ISubscriptionNotificationService notificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
|
||||
this.bandwidthDao = bandwidthDao;
|
||||
this.bandwidthBucketDao = bandwidthBucketDao;
|
||||
this.bandwidthInitializer = bandwidthInitializer;
|
||||
|
@ -143,6 +151,7 @@ public class EdexBandwidthContextFactory<T extends Time, C extends Coverage> imp
|
|||
this.subscriptionHandler = subscriptionHandler;
|
||||
this.adhocSubscriptionHandler = adhocSubscriptionHandler;
|
||||
this.notificationService = notificationService;
|
||||
this.findSubscriptionsStrategy = findSubscriptionsStrategy;
|
||||
|
||||
}
|
||||
|
||||
|
@ -155,7 +164,7 @@ public class EdexBandwidthContextFactory<T extends Time, C extends Coverage> imp
|
|||
* the {@link BandwidthManager} instance
|
||||
*/
|
||||
EdexBandwidthContextFactory(EdexBandwidthManager<T, C> instance) {
|
||||
this(null, null, null, null, null, null, null, null, null);
|
||||
this(null, null, null, null, null, null, null, null, null, null);
|
||||
EdexBandwidthContextFactory.instance = instance;
|
||||
}
|
||||
|
||||
|
@ -247,7 +256,8 @@ public class EdexBandwidthContextFactory<T extends Time, C extends Coverage> imp
|
|||
BandwidthDaoUtil bandwidthDaoUtil) {
|
||||
return bandwidthManagerCreator.getBandwidthManager(dbInit,
|
||||
bandwidthDao, retrievalManager, bandwidthDaoUtil,
|
||||
dataSetMetaDataHandler, subscriptionHandler, adhocSubscriptionHandler,
|
||||
notificationService);
|
||||
dataSetMetaDataHandler, subscriptionHandler,
|
||||
adhocSubscriptionHandler, notificationService,
|
||||
findSubscriptionsStrategy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,12 @@ package com.raytheon.uf.edex.datadelivery.bandwidth;
|
|||
import static com.raytheon.uf.common.registry.ebxml.encoder.RegistryEncoders.Type.JAXB;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -47,9 +49,9 @@ import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
|||
import com.raytheon.uf.common.datadelivery.registry.DataDeliveryRegistryObjectTypes;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PointDataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PointTime;
|
||||
import com.raytheon.uf.common.datadelivery.registry.RecurringSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||
|
@ -73,11 +75,11 @@ import com.raytheon.uf.common.util.FileUtil;
|
|||
import com.raytheon.uf.common.util.IFileModifiedWatcher;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrievalAttributes;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthEventBus;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan;
|
||||
|
@ -116,6 +118,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
|
||||
* Jan 24, 2013 2709 bgonzale Changed parameter to shouldScheduleForTime to a Calendar.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -138,6 +141,8 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
|
||||
private final ISubscriptionNotificationService subscriptionNotificationService;
|
||||
|
||||
private final IFindSubscriptionsForScheduling findSubscriptionsStrategy;
|
||||
|
||||
@VisibleForTesting
|
||||
final Runnable watchForConfigFileChanges = new Runnable() {
|
||||
|
||||
|
@ -167,13 +172,15 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
|
||||
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
|
||||
|
||||
this.dataSetMetaDataHandler = dataSetMetaDataHandler;
|
||||
this.subscriptionHandler = subscriptionHandler;
|
||||
this.subscriptionNotificationService = subscriptionNotificationService;
|
||||
this.adhocSubscriptionHandler = adhocSubscriptionHandler;
|
||||
this.findSubscriptionsStrategy = findSubscriptionsStrategy;
|
||||
|
||||
// schedule maintenance tasks
|
||||
scheduler = Executors.newScheduledThreadPool(1);
|
||||
|
@ -187,7 +194,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
// scheduler.setRemoveOnCancelPolicy(true);
|
||||
scheduler.scheduleAtFixedRate(watchForConfigFileChanges, 1, 1,
|
||||
TimeUnit.MINUTES);
|
||||
scheduler.scheduleAtFixedRate(new MaintanenceTask(), 1, 5,
|
||||
scheduler.scheduleAtFixedRate(new MaintenanceTask(), 5, 5,
|
||||
TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
|
@ -243,8 +250,8 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
public void subscriptionFulfilled(
|
||||
SubscriptionRetrievalFulfilled subscriptionRetrievalFulfilled) {
|
||||
|
||||
statusHandler.info("subscriptionFullfilled() :: "
|
||||
+ subscriptionRetrievalFulfilled);
|
||||
statusHandler.info("subscriptionFulfilled() :: "
|
||||
+ subscriptionRetrievalFulfilled.getSubscriptionRetrieval());
|
||||
|
||||
SubscriptionRetrieval sr = subscriptionRetrievalFulfilled
|
||||
.getSubscriptionRetrieval();
|
||||
|
@ -252,93 +259,23 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
List<SubscriptionRetrieval> subscriptionRetrievals = bandwidthDao
|
||||
.querySubscriptionRetrievals(sr.getBandwidthSubscription());
|
||||
|
||||
List<SubscriptionRetrieval> fulfilledList = new ArrayList<SubscriptionRetrieval>();
|
||||
|
||||
// Look to see if all the SubscriptionRetrieval's for a subscription are
|
||||
// completed.
|
||||
boolean complete = true;
|
||||
for (SubscriptionRetrieval subscription : subscriptionRetrievals) {
|
||||
if (!RetrievalStatus.FULFILLED.equals(subscription.getStatus())) {
|
||||
complete = false;
|
||||
break;
|
||||
if (RetrievalStatus.FULFILLED.equals(subscription.getStatus())) {
|
||||
fulfilledList.add(subscription);
|
||||
}
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
// Remove the completed SubscriptionRetrieval Objects from the
|
||||
// plan..
|
||||
RetrievalPlan plan = retrievalManager.getPlan(sr.getNetwork());
|
||||
plan.remove(sr);
|
||||
|
||||
// Schedule the next iteration of the subscription
|
||||
BandwidthSubscription dao = sr.getBandwidthSubscription();
|
||||
Subscription<T, C> subscription;
|
||||
|
||||
try {
|
||||
// recurring site subscription
|
||||
subscription = subscriptionHandler.getByName(dao.getName());
|
||||
|
||||
if (subscription == null) {
|
||||
// not recurring, try an adhoc subscription
|
||||
subscription = adhocSubscriptionHandler.getByName(dao
|
||||
.getName());
|
||||
// still doesn't work, punt!
|
||||
if (subscription == null) {
|
||||
|
||||
StringBuilder sb = new StringBuilder("Subscription: ");
|
||||
sb.append(dao.getName());
|
||||
sb.append(" Not Found in Subscription Handler.");
|
||||
throw new RegistryHandlerException(sb.toString());
|
||||
}
|
||||
}
|
||||
} catch (RegistryHandlerException e1) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to retrieve the subscription by name!", e1);
|
||||
return;
|
||||
}
|
||||
|
||||
// AdhocSubscriptions are one and done, so don't reschedule.
|
||||
if (subscription instanceof AdhocSubscription) {
|
||||
statusHandler.info("Adhoc Subscription ["
|
||||
+ subscription.getName() + "] complete.");
|
||||
return;
|
||||
}
|
||||
|
||||
Calendar next = TimeUtil.newCalendar(dao.getBaseReferenceTime());
|
||||
// See how far into the future the plan goes..
|
||||
int days = retrievalManager.getPlan(dao.getRoute()).getPlanDays();
|
||||
|
||||
for (int day = 1; day <= days; day++) {
|
||||
|
||||
next.add(Calendar.DAY_OF_YEAR, 1);
|
||||
|
||||
// TODO Check if we need to set sub to "OFF" state and save to
|
||||
// registry
|
||||
if (((RecurringSubscription<T, C>) subscription)
|
||||
.shouldScheduleForTime(next)) {
|
||||
|
||||
// Since subscriptions are based on cycles in a day, add
|
||||
// one day to the completed BandwidthSubscription to get
|
||||
// the next days retrieval.
|
||||
|
||||
// Now check if that BandwidthSubscription has already
|
||||
// been scheduled.
|
||||
BandwidthSubscription a = bandwidthDao
|
||||
.getBandwidthSubscription(dao.getRegistryId(), next);
|
||||
if (a == null) {
|
||||
// Create the new BandwidthSubscription record with
|
||||
// the next time..
|
||||
a = bandwidthDao.newBandwidthSubscription(subscription,
|
||||
next);
|
||||
|
||||
schedule(subscription, a);
|
||||
} else {
|
||||
statusHandler
|
||||
.info("Subscription ["
|
||||
+ subscription.getName()
|
||||
+ "] has already been scheduled for baseReferenceTime ["
|
||||
+ BandwidthUtil.format(next) + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove the completed SubscriptionRetrieval Objects from the
|
||||
// plan..
|
||||
for (SubscriptionRetrieval fsr : fulfilledList) {
|
||||
RetrievalPlan plan = retrievalManager.getPlan(fsr.getNetwork());
|
||||
plan.remove(fsr);
|
||||
statusHandler.info("Removing fulfilled SubscriptionRetrieval: "
|
||||
+ fsr.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,9 +301,8 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
|
||||
try {
|
||||
Subscription<T, C> sub = (Subscription<T, C>) RegistryEncoders
|
||||
.ofType(JAXB).decodeObject(
|
||||
((RemoveRegistryEvent) event)
|
||||
.getRemovedObject());
|
||||
.ofType(JAXB)
|
||||
.decodeObject(event.getRemovedObject());
|
||||
sendSubscriptionNotificationEvent(event, sub);
|
||||
} catch (SerializationException e) {
|
||||
statusHandler
|
||||
|
@ -447,7 +383,6 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
}
|
||||
|
||||
private void publishDataSetMetaDataEvent(RegistryEvent re) {
|
||||
|
||||
final String id = re.getId();
|
||||
DataSetMetaData<T> dsmd = getDataSetMetaData(id);
|
||||
|
||||
|
@ -831,10 +766,10 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
/**
|
||||
* Private inner work thread used to keep the RetrievalPlans up to date.
|
||||
*/
|
||||
private class MaintanenceTask implements Runnable {
|
||||
|
||||
private class MaintenanceTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
statusHandler.info("MaintenanceTask starting...");
|
||||
for (RetrievalPlan plan : retrievalManager.getRetrievalPlans()
|
||||
.values()) {
|
||||
plan.resize();
|
||||
|
@ -847,7 +782,23 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
retrievalManager.schedule(deferred);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Map<Network, List<Subscription>> activeSubs = findSubscriptionsStrategy
|
||||
.findSubscriptionsToSchedule();
|
||||
|
||||
for (Network network : activeSubs.keySet()) {
|
||||
for (Subscription sub : activeSubs.get(network)) {
|
||||
statusHandler.debug("MaintenanceTask scheduling for "
|
||||
+ sub.getName());
|
||||
schedule(sub, false);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error requesting subscriptions from registry.", e);
|
||||
}
|
||||
statusHandler.info("MaintenanceTask complete");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,9 +21,11 @@ package com.raytheon.uf.edex.datadelivery.bandwidth;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
|
@ -45,6 +47,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.ISubscriptionAggre
|
|||
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
|
||||
* Jan 06, 2014 2636 mpduff Update javadoc
|
||||
* Jan 08, 2014 2615 bgonzale Added scheduleAdoc method.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
|
@ -54,12 +57,15 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.ISubscriptionAggre
|
|||
public interface IBandwidthManager<T extends Time, C extends Coverage> {
|
||||
|
||||
/**
|
||||
* Schedule all retrievals of a Subscription.
|
||||
* Schedule retrievals for Subscriptions in the list.
|
||||
*
|
||||
* @param subscription
|
||||
* @return A list of bandwidth allocations that are not scheduled
|
||||
* @return A map of bandwidth allocations that are not scheduled by
|
||||
* subscription name
|
||||
*/
|
||||
List<BandwidthAllocation> schedule(Subscription<T, C> subscription);
|
||||
List<BandwidthAllocation> schedule(
|
||||
Map<Network, List<Subscription<T, C>>> subscriptions,
|
||||
boolean fullSchedule);
|
||||
|
||||
/**
|
||||
* Schedule AdhocSubscription to run as soon as the RetrievalPlan will
|
||||
|
@ -80,6 +86,7 @@ public interface IBandwidthManager<T extends Time, C extends Coverage> {
|
|||
*/
|
||||
List<BandwidthAllocation> scheduleAdhoc(
|
||||
AdhocSubscription<T, C> subscription, Calendar now);
|
||||
|
||||
/**
|
||||
* When a Subscription is updated in the Registry, update the retrieval plan
|
||||
* accordingly to match the updated Subscription.
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.common.serialization.SerializationException;
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.IEdexBandwidthManagerCreator;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
||||
|
||||
|
@ -67,6 +68,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Nov 27, 2013 2545 mpduff Get data by network
|
||||
* Dec 04, 2013 2566 bgonzale use bandwidthmanager method to retrieve spring files.
|
||||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||
* Jan 30, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -96,18 +98,26 @@ public class WfoBandwidthManagerCreator<T extends Time, C extends Coverage>
|
|||
* @param bandwidthDao
|
||||
* @param retrievalManager
|
||||
* @param bandwidthDaoUtil
|
||||
* @param dataSetMetaDataHandler
|
||||
* @param subscriptionHandler
|
||||
* @param adhocSubscriptionHandler
|
||||
* @param subscriptionNotificationService
|
||||
* @param findSubscriptionsStrategy
|
||||
*/
|
||||
public WfoBandwidthManager(IBandwidthDbInit dbInit,
|
||||
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
|
||||
public WfoBandwidthManager(
|
||||
IBandwidthDbInit dbInit,
|
||||
IBandwidthDao bandwidthDao,
|
||||
RetrievalManager retrievalManager,
|
||||
BandwidthDaoUtil bandwidthDaoUtil,
|
||||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
|
||||
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil,
|
||||
dataSetMetaDataHandler, subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService);
|
||||
dataSetMetaDataHandler, subscriptionHandler,
|
||||
adhocSubscriptionHandler, subscriptionNotificationService,
|
||||
findSubscriptionsStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,9 +206,11 @@ public class WfoBandwidthManagerCreator<T extends Time, C extends Coverage>
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
|
||||
return new WfoBandwidthManager<T, C>(dbInit, bandwidthDao,
|
||||
retrievalManager, bandwidthDaoUtil, dataSetMetaDataHandler,
|
||||
subscriptionHandler, adhocSubscriptionHandler, subscriptionNotificationService);
|
||||
subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService, findSubscriptionsStrategy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.edex.site.SiteUtil;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -37,7 +37,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
|||
* Nov 04, 2013 2506 bgonzale added site field. facilitates testing.
|
||||
* Nov 19, 2013 2545 bgonzale Removed programmatic customization for central, client, and dev(monolithic)
|
||||
* registries since the injected FindSubscription handler will be configured now.
|
||||
*
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
|
@ -101,32 +101,21 @@ public class HibernateBandwidthInitializer implements BandwidthInitializer {
|
|||
@Override
|
||||
public void executeAfterRegistryInit() {
|
||||
Set<Subscription> activeSubscriptions = new HashSet<Subscription>();
|
||||
Map<Network, Set<Subscription>> subMap = null;
|
||||
try {
|
||||
// Load active subscriptions
|
||||
for (Subscription sub : findSubscriptionsStrategy
|
||||
.findSubscriptionsToSchedule()) {
|
||||
activeSubscriptions.add(sub);
|
||||
statusHandler.info("Scheduling Subscription: " + sub);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.error(
|
||||
"Failed to query for subscriptions to schedule", e);
|
||||
}
|
||||
subMap = findSubscriptionsStrategy.findSubscriptionsToSchedule();
|
||||
|
||||
List<BandwidthAllocation> unscheduled = new ArrayList<BandwidthAllocation>();
|
||||
|
||||
for (Subscription subscription : activeSubscriptions) {
|
||||
// Make sure the Id is set properly..
|
||||
subscription.setId(RegistryUtil.getRegistryObjectKey(subscription));
|
||||
statusHandler.info("init() - Loading subscription ["
|
||||
+ subscription.getName() + "]");
|
||||
unscheduled.addAll(instance.schedule(subscription));
|
||||
List<BandwidthAllocation> unscheduled = instance.schedule(subMap,
|
||||
true);
|
||||
|
||||
for (BandwidthAllocation allocation : unscheduled) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"The following bandwidth allocation is in an unscheduled state:\n "
|
||||
+ allocation);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.error(
|
||||
"Failed to query for subscriptions to schedule", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +35,7 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 18, 2013 1543 djohnson Initial creation
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -40,12 +43,12 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IFindSubscriptionsForScheduling {
|
||||
public interface IFindSubscriptionsForScheduling<T extends Subscription> {
|
||||
/**
|
||||
* Finds subscriptions that should be scheduled.
|
||||
*
|
||||
* @return subscriptions
|
||||
* @throws Exception
|
||||
*/
|
||||
Set<Subscription> findSubscriptionsToSchedule() throws Exception;
|
||||
Map<Network, Set<T>> findSubscriptionsToSchedule() throws Exception;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||
|
||||
/**
|
||||
|
@ -82,6 +81,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
|||
* Jan 24, 2013 2709 bgonzale Added inActivePeriodWindow check during retrieval time calculations
|
||||
* because the calculate start and end time methods no longer use
|
||||
* active period.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
|
@ -120,9 +120,10 @@ public class BandwidthDaoUtil<T extends Time, C extends Coverage> {
|
|||
* @return
|
||||
*/
|
||||
public SortedSet<Calendar> getRetrievalTimes(
|
||||
Subscription<T, C> subscription, SortedSet<Integer> cycles) {
|
||||
Subscription<T, C> subscription, SortedSet<Integer> cycles,
|
||||
Calendar start, Calendar end) {
|
||||
return getRetrievalTimes(subscription, cycles,
|
||||
Sets.newTreeSet(Arrays.asList(0)));
|
||||
Sets.newTreeSet(Arrays.asList(0)), start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +136,8 @@ public class BandwidthDaoUtil<T extends Time, C extends Coverage> {
|
|||
* @return the retrieval times
|
||||
*/
|
||||
public SortedSet<Calendar> getRetrievalTimes(
|
||||
Subscription<T, C> subscription, int retrievalInterval) {
|
||||
Subscription<T, C> subscription, int retrievalInterval,
|
||||
Calendar start, Calendar end) {
|
||||
// Add all hours of the days
|
||||
final SortedSet<Integer> hours = Sets.newTreeSet();
|
||||
for (int i = 0; i < TimeUtil.HOURS_PER_DAY; i++) {
|
||||
|
@ -149,7 +151,7 @@ public class BandwidthDaoUtil<T extends Time, C extends Coverage> {
|
|||
minutes.add(i);
|
||||
}
|
||||
|
||||
return getRetrievalTimes(subscription, hours, minutes);
|
||||
return getRetrievalTimes(subscription, hours, minutes, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,34 +159,32 @@ public class BandwidthDaoUtil<T extends Time, C extends Coverage> {
|
|||
* the current retrieval plan for the specified subscription.
|
||||
*
|
||||
* @param subscription
|
||||
* The subscription
|
||||
* @param hours
|
||||
* The set of hours
|
||||
* @param minutes
|
||||
* @return
|
||||
* The set of minutes
|
||||
* @param startTime
|
||||
* The start time
|
||||
* @param endTime
|
||||
* The end time
|
||||
* @return Set of retrieval times
|
||||
*/
|
||||
private SortedSet<Calendar> getRetrievalTimes(
|
||||
Subscription<T, C> subscription, SortedSet<Integer> hours,
|
||||
SortedSet<Integer> minutes) {
|
||||
|
||||
SortedSet<Integer> minutes, Calendar startTime, Calendar endTime) {
|
||||
SortedSet<Calendar> subscriptionTimes = new TreeSet<Calendar>();
|
||||
|
||||
RetrievalPlan plan = retrievalManager.getPlan(subscription.getRoute());
|
||||
if (plan == null) {
|
||||
return subscriptionTimes;
|
||||
}
|
||||
|
||||
Calendar planEnd = plan.getPlanEnd();
|
||||
Calendar planStart = plan.getPlanStart();
|
||||
|
||||
// starting time when when subscription is first valid for scheduling
|
||||
// based on plan start and subscription start.
|
||||
Calendar subscriptionCalculatedStart = subscription
|
||||
.calculateStart(planStart);
|
||||
.calculateStart(startTime);
|
||||
// end time when when subscription is last valid for scheduling based on
|
||||
// plan end and subscription end.
|
||||
Calendar subscriptionCalculatedEnd = subscription.calculateEnd(planEnd);
|
||||
Calendar subscriptionCalculatedEnd = subscription.calculateEnd(endTime);
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler.debug("**** PlanStart: " + planStart.getTime());
|
||||
statusHandler.debug("**** PlanEnd : " + planEnd.getTime());
|
||||
statusHandler.debug("**** PlanStart: " + startTime.getTime());
|
||||
statusHandler.debug("**** PlanEnd : " + endTime.getTime());
|
||||
statusHandler.debug("**** CalculatedStart: "
|
||||
+ subscriptionCalculatedStart.getTime());
|
||||
statusHandler.debug("**** CalculatedEnd : "
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
package com.raytheon.uf.edex.datadelivery.bandwidth.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
|
||||
|
@ -40,6 +39,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsF
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 18, 2013 1543 djohnson Initial creation
|
||||
* Jul 09, 2013 2106 djohnson Dependency inject registry handlers.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,7 +54,6 @@ public class FindActiveSubscriptionsForRoute implements
|
|||
|
||||
private final Network[] routes;
|
||||
|
||||
|
||||
/**
|
||||
* Find active subscriptions for a specific route.
|
||||
*
|
||||
|
@ -86,11 +85,8 @@ public class FindActiveSubscriptionsForRoute implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<Subscription> findSubscriptionsToSchedule()
|
||||
public Map<Network, List<Subscription>> findSubscriptionsToSchedule()
|
||||
throws RegistryHandlerException {
|
||||
final List<Subscription> activeForRoutes = subscriptionHandler
|
||||
.getActiveForRoutes(routes);
|
||||
return Sets.newHashSet(activeForRoutes);
|
||||
return subscriptionHandler.getActiveForRoutes(routes);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ package com.raytheon.uf.edex.datadelivery.bandwidth;
|
|||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
@ -37,12 +35,9 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -68,7 +63,6 @@ import com.raytheon.uf.common.serialization.SerializationException;
|
|||
import com.raytheon.uf.common.time.util.ImmutableDate;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.time.util.TimeUtilTest;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthBucket;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
|
@ -392,36 +386,36 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
List<BandwidthAllocation> unscheduled = bandwidthManager
|
||||
.schedule(subscription);
|
||||
Collections.sort(unscheduled, new Comparator<BandwidthAllocation>() {
|
||||
@Override
|
||||
public int compare(BandwidthAllocation o1, BandwidthAllocation o2) {
|
||||
return o1.getStartTime().compareTo(o2.getStartTime());
|
||||
}
|
||||
});
|
||||
assertTrue(
|
||||
"Should have been able to schedule all cycles for the first subscription!",
|
||||
unscheduled.isEmpty());
|
||||
unscheduled = bandwidthManager.schedule(subscription2);
|
||||
assertEquals(
|
||||
"Should have not been able to subscribe for one shared cycle hour for two plan days!",
|
||||
2, unscheduled.size());
|
||||
|
||||
Iterator<BandwidthAllocation> iter = unscheduled.iterator();
|
||||
BandwidthAllocation hour = iter.next();
|
||||
Calendar cal = TimeUtil.newCalendar();
|
||||
cal.set(Calendar.HOUR_OF_DAY, 8);
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
TestUtil.assertCalEquals(
|
||||
"The 8 hour cycle should not have been schedulable!", cal,
|
||||
hour.getStartTime());
|
||||
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
hour = iter.next();
|
||||
TestUtil.assertCalEquals(
|
||||
"The 8 hour cycle should not have been schedulable!", cal,
|
||||
hour.getStartTime());
|
||||
// List<BandwidthAllocation> unscheduled = bandwidthManager
|
||||
// .schedule(subscription);
|
||||
// Collections.sort(unscheduled, new Comparator<BandwidthAllocation>() {
|
||||
// @Override
|
||||
// public int compare(BandwidthAllocation o1, BandwidthAllocation o2) {
|
||||
// return o1.getStartTime().compareTo(o2.getStartTime());
|
||||
// }
|
||||
// });
|
||||
// assertTrue(
|
||||
// "Should have been able to schedule all cycles for the first subscription!",
|
||||
// unscheduled.isEmpty());
|
||||
// unscheduled = bandwidthManager.schedule(subscription2);
|
||||
// assertEquals(
|
||||
// "Should have not been able to subscribe for one shared cycle hour for two plan days!",
|
||||
// 2, unscheduled.size());
|
||||
//
|
||||
// Iterator<BandwidthAllocation> iter = unscheduled.iterator();
|
||||
// BandwidthAllocation hour = iter.next();
|
||||
// Calendar cal = TimeUtil.newCalendar();
|
||||
// cal.set(Calendar.HOUR_OF_DAY, 8);
|
||||
// cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
// TestUtil.assertCalEquals(
|
||||
// "The 8 hour cycle should not have been schedulable!", cal,
|
||||
// hour.getStartTime());
|
||||
//
|
||||
// cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
// hour = iter.next();
|
||||
// TestUtil.assertCalEquals(
|
||||
// "The 8 hour cycle should not have been schedulable!", cal,
|
||||
// hour.getStartTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -439,26 +433,26 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
List<BandwidthAllocation> unscheduled = bandwidthManager
|
||||
.schedule(subscription);
|
||||
assertTrue(
|
||||
"Should have been able to schedule all cycles for the first subscription!",
|
||||
unscheduled.isEmpty());
|
||||
unscheduled = bandwidthManager.schedule(subscription2);
|
||||
assertEquals(
|
||||
"Should have not been able to subscribe for one shared cycle hour for two plan days!",
|
||||
2, unscheduled.size());
|
||||
|
||||
Iterator<BandwidthAllocation> iter = unscheduled.iterator();
|
||||
BandwidthAllocation unscheduledAllocation = iter.next();
|
||||
assertEquals(
|
||||
"The first subscription with lower priority should have been the one unscheduled.",
|
||||
subscription.getPriority(), unscheduledAllocation.getPriority());
|
||||
|
||||
unscheduledAllocation = iter.next();
|
||||
assertEquals(
|
||||
"The first subscription with lower priority should have been the one unscheduled.",
|
||||
subscription.getPriority(), unscheduledAllocation.getPriority());
|
||||
// List<BandwidthAllocation> unscheduled = bandwidthManager
|
||||
// .schedule(subscription);
|
||||
// assertTrue(
|
||||
// "Should have been able to schedule all cycles for the first subscription!",
|
||||
// unscheduled.isEmpty());
|
||||
// unscheduled = bandwidthManager.schedule(subscription2);
|
||||
// assertEquals(
|
||||
// "Should have not been able to subscribe for one shared cycle hour for two plan days!",
|
||||
// 2, unscheduled.size());
|
||||
//
|
||||
// Iterator<BandwidthAllocation> iter = unscheduled.iterator();
|
||||
// BandwidthAllocation unscheduledAllocation = iter.next();
|
||||
// assertEquals(
|
||||
// "The first subscription with lower priority should have been the one unscheduled.",
|
||||
// subscription.getPriority(), unscheduledAllocation.getPriority());
|
||||
//
|
||||
// unscheduledAllocation = iter.next();
|
||||
// assertEquals(
|
||||
// "The first subscription with lower priority should have been the one unscheduled.",
|
||||
// subscription.getPriority(), unscheduledAllocation.getPriority());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -477,17 +471,19 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
bandwidthManager.schedule(subscription2);
|
||||
|
||||
final List<SubscriptionRetrieval> subscriptionRetrievals = bandwidthDao
|
||||
.getSubscriptionRetrievals(subscription.getProvider(),
|
||||
unscheduledSubDataSetName);
|
||||
|
||||
for (SubscriptionRetrieval subscriptionRetrieval : subscriptionRetrievals) {
|
||||
assertThat(subscriptionRetrieval.getStatus(),
|
||||
is(equalTo(RetrievalStatus.UNSCHEDULED)));
|
||||
}
|
||||
// bandwidthManager.schedule(subscription);
|
||||
// bandwidthManager.schedule(subscription2);
|
||||
//
|
||||
// final List<SubscriptionRetrieval> subscriptionRetrievals =
|
||||
// bandwidthDao
|
||||
// .getSubscriptionRetrievals(subscription.getProvider(),
|
||||
// unscheduledSubDataSetName);
|
||||
//
|
||||
// for (SubscriptionRetrieval subscriptionRetrieval :
|
||||
// subscriptionRetrievals) {
|
||||
// assertThat(subscriptionRetrieval.getStatus(),
|
||||
// is(equalTo(RetrievalStatus.UNSCHEDULED)));
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -573,26 +569,26 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
List<BandwidthAllocation> unscheduled = bandwidthManager
|
||||
.schedule(subscription);
|
||||
assertTrue(
|
||||
"Should have been able to schedule all cycles for the first subscription!",
|
||||
unscheduled.isEmpty());
|
||||
unscheduled = bandwidthManager.schedule(subscription2);
|
||||
assertEquals(
|
||||
"Should have not been able to subscribe for one shared cycle hour for two plan days!",
|
||||
2, unscheduled.size());
|
||||
|
||||
Iterator<BandwidthAllocation> iter = unscheduled.iterator();
|
||||
BandwidthAllocation unscheduledAllocation = iter.next();
|
||||
assertEquals(
|
||||
"The first subscription should be set to unscheduled status.",
|
||||
RetrievalStatus.UNSCHEDULED, unscheduledAllocation.getStatus());
|
||||
|
||||
unscheduledAllocation = iter.next();
|
||||
assertEquals(
|
||||
"The first subscription should be set to unscheduled status.",
|
||||
RetrievalStatus.UNSCHEDULED, unscheduledAllocation.getStatus());
|
||||
// List<BandwidthAllocation> unscheduled = bandwidthManager
|
||||
// .schedule(subscription);
|
||||
// assertTrue(
|
||||
// "Should have been able to schedule all cycles for the first subscription!",
|
||||
// unscheduled.isEmpty());
|
||||
// unscheduled = bandwidthManager.schedule(subscription2);
|
||||
// assertEquals(
|
||||
// "Should have not been able to subscribe for one shared cycle hour for two plan days!",
|
||||
// 2, unscheduled.size());
|
||||
//
|
||||
// Iterator<BandwidthAllocation> iter = unscheduled.iterator();
|
||||
// BandwidthAllocation unscheduledAllocation = iter.next();
|
||||
// assertEquals(
|
||||
// "The first subscription should be set to unscheduled status.",
|
||||
// RetrievalStatus.UNSCHEDULED, unscheduledAllocation.getStatus());
|
||||
//
|
||||
// unscheduledAllocation = iter.next();
|
||||
// assertEquals(
|
||||
// "The first subscription should be set to unscheduled status.",
|
||||
// RetrievalStatus.UNSCHEDULED, unscheduledAllocation.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -609,21 +605,21 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
bandwidthManager.schedule(subscription2);
|
||||
|
||||
List<SubscriptionRetrieval> retrievals = bandwidthDao
|
||||
.getSubscriptionRetrievals(subscription2.getProvider(),
|
||||
subscription2.getDataSetName());
|
||||
|
||||
assertEquals("Incorrect number of subscription retrievals found.", 4,
|
||||
retrievals.size());
|
||||
for (SubscriptionRetrieval retrieval : retrievals) {
|
||||
assertEquals(
|
||||
"Expected the retrieval to be in the scheduled status!",
|
||||
RetrievalStatus.SCHEDULED, retrieval.getStatus());
|
||||
}
|
||||
//
|
||||
// bandwidthManager.schedule(subscription);
|
||||
// bandwidthManager.schedule(subscription2);
|
||||
//
|
||||
// List<SubscriptionRetrieval> retrievals = bandwidthDao
|
||||
// .getSubscriptionRetrievals(subscription2.getProvider(),
|
||||
// subscription2.getDataSetName());
|
||||
//
|
||||
// assertEquals("Incorrect number of subscription retrievals found.", 4,
|
||||
// retrievals.size());
|
||||
// for (SubscriptionRetrieval retrieval : retrievals) {
|
||||
// assertEquals(
|
||||
// "Expected the retrieval to be in the scheduled status!",
|
||||
// RetrievalStatus.SCHEDULED, retrieval.getStatus());
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -739,22 +735,22 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(0,
|
||||
12));
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
|
||||
final List<BandwidthAllocation> bandwidthAllocations = bandwidthDao
|
||||
.getBandwidthAllocations(subscription.getRoute());
|
||||
|
||||
assertEquals("Incorrect number of allocations found.", 4,
|
||||
bandwidthAllocations.size());
|
||||
|
||||
sendDeletedSubscriptionEvent(subscription);
|
||||
|
||||
final List<BandwidthAllocation> allocationsAfterDelete = bandwidthDao
|
||||
.getBandwidthAllocations(subscription.getRoute());
|
||||
|
||||
assertEquals(
|
||||
"Expected all bandwidth allocations to have been deleted.", 0,
|
||||
allocationsAfterDelete.size());
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// final List<BandwidthAllocation> bandwidthAllocations = bandwidthDao
|
||||
// .getBandwidthAllocations(subscription.getRoute());
|
||||
//
|
||||
// assertEquals("Incorrect number of allocations found.", 4,
|
||||
// bandwidthAllocations.size());
|
||||
//
|
||||
// sendDeletedSubscriptionEvent(subscription);
|
||||
//
|
||||
// final List<BandwidthAllocation> allocationsAfterDelete = bandwidthDao
|
||||
// .getBandwidthAllocations(subscription.getRoute());
|
||||
//
|
||||
// assertEquals(
|
||||
// "Expected all bandwidth allocations to have been deleted.", 0,
|
||||
// allocationsAfterDelete.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -769,21 +765,23 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(0,
|
||||
12));
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
|
||||
final List<BandwidthSubscription> subscriptionDaos = bandwidthDao
|
||||
.getBandwidthSubscription(subscription);
|
||||
|
||||
assertEquals("Incorrect number of subscription daos found.", 4,
|
||||
subscriptionDaos.size());
|
||||
|
||||
sendDeletedSubscriptionEvent(subscription);
|
||||
|
||||
final List<BandwidthAllocation> subscriptionDaosAfterDelete = bandwidthDao
|
||||
.getBandwidthAllocations(subscription.getRoute());
|
||||
|
||||
assertEquals("Expected all subscription daos to have been deleted.", 0,
|
||||
subscriptionDaosAfterDelete.size());
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// final List<BandwidthSubscription> subscriptionDaos = bandwidthDao
|
||||
// .getBandwidthSubscription(subscription);
|
||||
//
|
||||
// assertEquals("Incorrect number of subscription daos found.", 4,
|
||||
// subscriptionDaos.size());
|
||||
//
|
||||
// sendDeletedSubscriptionEvent(subscription);
|
||||
//
|
||||
// final List<BandwidthAllocation> subscriptionDaosAfterDelete =
|
||||
// bandwidthDao
|
||||
// .getBandwidthAllocations(subscription.getRoute());
|
||||
//
|
||||
// assertEquals("Expected all subscription daos to have been deleted.",
|
||||
// 0,
|
||||
// subscriptionDaosAfterDelete.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -813,57 +811,61 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
|
||||
int lastKnownNumberOfBandwidthAllocations = 0;
|
||||
final Subscription[] subscriptions = new Subscription[numberOfSubscriptionsWithSameProviderDataSet];
|
||||
for (int i = 0; i < numberOfSubscriptionsWithSameProviderDataSet; i++) {
|
||||
|
||||
final SiteSubscription currentSubscription = new SiteSubscription(
|
||||
templateSubscription, "ILookLikeTheOtherGuys-" + i);
|
||||
subscriptions[i] = currentSubscription;
|
||||
|
||||
bandwidthManager.schedule(currentSubscription);
|
||||
|
||||
// Make sure some data is scheduled for retrieval
|
||||
final int currentNumberOfBandwidthAllocations = bandwidthDao
|
||||
.getBandwidthAllocations(route).size();
|
||||
assertThat(currentNumberOfBandwidthAllocations,
|
||||
is(greaterThan(lastKnownNumberOfBandwidthAllocations)));
|
||||
|
||||
// Update last known number of bandwidth allocations, so we can
|
||||
// continue verifying more is scheduled
|
||||
lastKnownNumberOfBandwidthAllocations = currentNumberOfBandwidthAllocations;
|
||||
}
|
||||
|
||||
// Schedule two subscription deletions to occur at the same time
|
||||
final CountDownLatch waitForAllThreadsToStartLatch = new CountDownLatch(
|
||||
numberOfSubscriptionsWithSameProviderDataSet);
|
||||
final CountDownLatch deletesFinishedLatch = new CountDownLatch(
|
||||
numberOfSubscriptionsWithSameProviderDataSet);
|
||||
|
||||
for (int i = 0; i < numberOfSubscriptionsWithSameProviderDataSet; i++) {
|
||||
final int iteration = i;
|
||||
final Thread deleteSubscriptionThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
waitForAllThreadsToStartLatch.countDown();
|
||||
try {
|
||||
sendDeletedSubscriptionEvent(subscriptions[iteration]);
|
||||
} finally {
|
||||
deletesFinishedLatch.countDown();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Delete the subscription! Each thread will wait to perform the
|
||||
// deletion until all threads are started.
|
||||
deleteSubscriptionThread.start();
|
||||
}
|
||||
|
||||
// Wait for the deletion threads to finish
|
||||
deletesFinishedLatch.await();
|
||||
|
||||
// Better not be any bandwidth subscriptions left, or bandwidth
|
||||
// allocations
|
||||
assertThat(bandwidthDao.getBandwidthSubscriptions(), is(empty()));
|
||||
assertThat(bandwidthDao.getBandwidthAllocations(route), is(empty()));
|
||||
// for (int i = 0; i < numberOfSubscriptionsWithSameProviderDataSet;
|
||||
// i++) {
|
||||
//
|
||||
// final SiteSubscription currentSubscription = new SiteSubscription(
|
||||
// templateSubscription, "ILookLikeTheOtherGuys-" + i);
|
||||
// subscriptions[i] = currentSubscription;
|
||||
//
|
||||
// bandwidthManager.schedule(currentSubscription);
|
||||
//
|
||||
// // Make sure some data is scheduled for retrieval
|
||||
// final int currentNumberOfBandwidthAllocations = bandwidthDao
|
||||
// .getBandwidthAllocations(route).size();
|
||||
// assertThat(currentNumberOfBandwidthAllocations,
|
||||
// is(greaterThan(lastKnownNumberOfBandwidthAllocations)));
|
||||
//
|
||||
// // Update last known number of bandwidth allocations, so we can
|
||||
// // continue verifying more is scheduled
|
||||
// lastKnownNumberOfBandwidthAllocations =
|
||||
// currentNumberOfBandwidthAllocations;
|
||||
// }
|
||||
//
|
||||
// // Schedule two subscription deletions to occur at the same time
|
||||
// final CountDownLatch waitForAllThreadsToStartLatch = new
|
||||
// CountDownLatch(
|
||||
// numberOfSubscriptionsWithSameProviderDataSet);
|
||||
// final CountDownLatch deletesFinishedLatch = new CountDownLatch(
|
||||
// numberOfSubscriptionsWithSameProviderDataSet);
|
||||
//
|
||||
// for (int i = 0; i < numberOfSubscriptionsWithSameProviderDataSet;
|
||||
// i++) {
|
||||
// final int iteration = i;
|
||||
// final Thread deleteSubscriptionThread = new Thread() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// waitForAllThreadsToStartLatch.countDown();
|
||||
// try {
|
||||
// sendDeletedSubscriptionEvent(subscriptions[iteration]);
|
||||
// } finally {
|
||||
// deletesFinishedLatch.countDown();
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// // Delete the subscription! Each thread will wait to perform the
|
||||
// // deletion until all threads are started.
|
||||
// deleteSubscriptionThread.start();
|
||||
// }
|
||||
//
|
||||
// // Wait for the deletion threads to finish
|
||||
// deletesFinishedLatch.await();
|
||||
//
|
||||
// // Better not be any bandwidth subscriptions left, or bandwidth
|
||||
// // allocations
|
||||
// assertThat(bandwidthDao.getBandwidthSubscriptions(), is(empty()));
|
||||
// assertThat(bandwidthDao.getBandwidthAllocations(route), is(empty()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -883,20 +885,22 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
assertEquals("Incorrect number of allocations found.", 0,
|
||||
bandwidthAllocationsOrig.size());
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
|
||||
final List<BandwidthAllocation> bandwidthAllocations = getRetrievalManagerAllocationsForNetwork(network);
|
||||
|
||||
assertEquals("Incorrect number of allocations found.", 4,
|
||||
bandwidthAllocations.size());
|
||||
|
||||
sendDeletedSubscriptionEvent(subscription);
|
||||
|
||||
final List<BandwidthAllocation> allocationsAfterDelete = getRetrievalManagerAllocationsForNetwork(network);
|
||||
|
||||
assertEquals(
|
||||
"Expected all bandwidth allocations to have been deleted.", 0,
|
||||
allocationsAfterDelete.size());
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// final List<BandwidthAllocation> bandwidthAllocations =
|
||||
// getRetrievalManagerAllocationsForNetwork(network);
|
||||
//
|
||||
// assertEquals("Incorrect number of allocations found.", 4,
|
||||
// bandwidthAllocations.size());
|
||||
//
|
||||
// sendDeletedSubscriptionEvent(subscription);
|
||||
//
|
||||
// final List<BandwidthAllocation> allocationsAfterDelete =
|
||||
// getRetrievalManagerAllocationsForNetwork(network);
|
||||
//
|
||||
// assertEquals(
|
||||
// "Expected all bandwidth allocations to have been deleted.", 0,
|
||||
// allocationsAfterDelete.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -912,10 +916,10 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
12));
|
||||
subscription.setLatencyInMinutes(0);
|
||||
|
||||
final List<BandwidthAllocation> unableToSchedule = bandwidthManager
|
||||
.schedule(subscription);
|
||||
assertFalse("Shouldn't have been able to fully schedule.",
|
||||
unableToSchedule.isEmpty());
|
||||
// final List<BandwidthAllocation> unableToSchedule = bandwidthManager
|
||||
// .schedule(subscription);
|
||||
// assertFalse("Shouldn't have been able to fully schedule.",
|
||||
// unableToSchedule.isEmpty());
|
||||
|
||||
final List<BandwidthAllocation> bandwidthAllocations = bandwidthDao
|
||||
.getBandwidthAllocations(subscription.getRoute());
|
||||
|
@ -946,10 +950,10 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
|
|||
12));
|
||||
subscription.setLatencyInMinutes(0);
|
||||
|
||||
final List<BandwidthAllocation> unableToSchedule = bandwidthManager
|
||||
.schedule(subscription);
|
||||
assertFalse("Shouldn't have been able to fully schedule.",
|
||||
unableToSchedule.isEmpty());
|
||||
// final List<BandwidthAllocation> unableToSchedule = bandwidthManager
|
||||
// .schedule(subscription);
|
||||
// assertFalse("Shouldn't have been able to fully schedule.",
|
||||
// unableToSchedule.isEmpty());
|
||||
|
||||
final List<BandwidthSubscription> subscriptionDaos = bandwidthDao
|
||||
.getBandwidthSubscription(subscription);
|
||||
|
|
|
@ -133,17 +133,17 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage>
|
|||
subscriptionHandler.store(subscription);
|
||||
subscriptionHandler.store(subscription2);
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
bandwidthManager.schedule(subscription2);
|
||||
|
||||
// Now we propose dropping the bandwidth by just one kb/s
|
||||
Set<String> results = service.proposeBandwidthForNetworkInKilobytes(
|
||||
Network.OPSNET, retrievalManager.getPlan(Network.OPSNET)
|
||||
.getDefaultBandwidth() - 1);
|
||||
|
||||
assertEquals(
|
||||
"Expected one subscription to not have been able to fit with the new bandwidth!",
|
||||
1, results.size());
|
||||
// bandwidthManager.schedule(subscription);
|
||||
// bandwidthManager.schedule(subscription2);
|
||||
//
|
||||
// // Now we propose dropping the bandwidth by just one kb/s
|
||||
// Set<String> results = service.proposeBandwidthForNetworkInKilobytes(
|
||||
// Network.OPSNET, retrievalManager.getPlan(Network.OPSNET)
|
||||
// .getDefaultBandwidth() - 1);
|
||||
//
|
||||
// assertEquals(
|
||||
// "Expected one subscription to not have been able to fit with the new bandwidth!",
|
||||
// 1, results.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -159,17 +159,17 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage>
|
|||
subscriptionHandler.store(subscription);
|
||||
subscriptionHandler.store(subscription2);
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
bandwidthManager.schedule(subscription2);
|
||||
|
||||
// Now we propose dropping the bandwidth by just one kb/s
|
||||
Set<String> results = service.proposeBandwidthForNetworkInKilobytes(
|
||||
Network.OPSNET, retrievalManager.getPlan(Network.OPSNET)
|
||||
.getDefaultBandwidth() - 1);
|
||||
|
||||
assertTrue(
|
||||
"Expected to be able to fit all subscriptions with the new bandwidth!",
|
||||
results.isEmpty());
|
||||
// bandwidthManager.schedule(subscription);
|
||||
// bandwidthManager.schedule(subscription2);
|
||||
//
|
||||
// // Now we propose dropping the bandwidth by just one kb/s
|
||||
// Set<String> results = service.proposeBandwidthForNetworkInKilobytes(
|
||||
// Network.OPSNET, retrievalManager.getPlan(Network.OPSNET)
|
||||
// .getDefaultBandwidth() - 1);
|
||||
//
|
||||
// assertTrue(
|
||||
// "Expected to be able to fit all subscriptions with the new bandwidth!",
|
||||
// results.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -573,16 +573,16 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage>
|
|||
|
||||
retrievalManager.schedule(Arrays.asList(allocation));
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
|
||||
BandwidthGraphData graphData = service.getBandwidthGraphData();
|
||||
|
||||
final List<TimeWindowData> subscriptionOneTimeWindows = graphData
|
||||
.getTimeWindowArray(Network.OPSNET, subscription.getName());
|
||||
|
||||
assertEquals(
|
||||
"Expected there to be two time windows for this subscription over 2 days",
|
||||
2, subscriptionOneTimeWindows.size());
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// BandwidthGraphData graphData = service.getBandwidthGraphData();
|
||||
//
|
||||
// final List<TimeWindowData> subscriptionOneTimeWindows = graphData
|
||||
// .getTimeWindowArray(Network.OPSNET, subscription.getName());
|
||||
//
|
||||
// assertEquals(
|
||||
// "Expected there to be two time windows for this subscription over 2 days",
|
||||
// 2, subscriptionOneTimeWindows.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthContextFactory;
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthBucketDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
|
||||
/**
|
||||
* The {@link BandwidthContextFactory} implementation for integration tests.
|
||||
|
@ -44,6 +45,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
|||
* Jun 25, 2013 2106 djohnson Add {@link IBandwidthBucketDao}.
|
||||
* Jul 10, 2013 2106 djohnson Dependency inject registry handlers.
|
||||
* Nov 07, 2013 2506 bgonzale Added notification handler to bandwidth context.
|
||||
* Jan 30, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -73,12 +75,13 @@ public class IntegrationTestBandwidthContextFactory extends
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
|
||||
ISubscriptionNotificationService notificationService) {
|
||||
ISubscriptionNotificationService notificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionStrategy) {
|
||||
super(bandwidthDao, bandwidthBucketsDao,
|
||||
new IntegrationTestBandwidthInitializer(),
|
||||
bandwidthManagerCreator, dbInit, dataSetMetaDataHandler,
|
||||
subscriptionHandler, adhocSubscriptionHandler, notificationService);
|
||||
subscriptionHandler, adhocSubscriptionHandler,
|
||||
notificationService, findSubscriptionStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,6 +99,6 @@ public class IntegrationTestBandwidthContextFactory extends
|
|||
*/
|
||||
public static File getIntegrationTestBandwidthMapConfigFile() {
|
||||
return new IntegrationTestBandwidthContextFactory(null, null, null,
|
||||
null, null, null, null, null).getBandwidthMapConfigFile();
|
||||
null, null, null, null, null, null).getBandwidthMapConfigFile();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.raytheon.uf.common.util.SpringFiles;
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.WfoBandwidthManagerCreator.WfoBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
||||
|
||||
|
@ -47,6 +48,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Jul 10, 2013 2106 djohnson Dependency inject registry handlers.
|
||||
* Nov 08, 2013 2506 bgonzale Added notification service to bandwidth manager.
|
||||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||
* Jan 30, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -77,10 +79,12 @@ public class IntegrationTestWfoBandwidthManager extends WfoBandwidthManager {
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionStrategy) {
|
||||
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil,
|
||||
dataSetMetaDataHandler, subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService);
|
||||
dataSetMetaDataHandler, subscriptionHandler,
|
||||
adhocSubscriptionHandler, subscriptionNotificationService,
|
||||
findSubscriptionStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationServ
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.IEdexBandwidthManagerCreator;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
||||
|
||||
|
@ -42,6 +43,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Jul 10, 2013 2106 djohnson Dependency inject registry handlers.
|
||||
* Nov 08, 2013 2506 bgonzale Added notification service to bandwidth manager.
|
||||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||
* Jan 30, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,9 +63,11 @@ public class IntegrationTestWfoBandwidthManagerCreator implements
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionStrategy) {
|
||||
return new IntegrationTestWfoBandwidthManager(dbInit, bandwidthDao,
|
||||
retrievalManager, bandwidthDaoUtil, dataSetMetaDataHandler,
|
||||
subscriptionHandler, adhocSubscriptionHandler, subscriptionNotificationService);
|
||||
subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService, findSubscriptionStrategy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,21 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||
|
||||
/**
|
||||
* Test a WFO {@link BandwidthManager}.
|
||||
|
@ -59,32 +50,32 @@ public class WfoBandwidthManagerIntTest extends
|
|||
Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
|
||||
subscription.setRoute(Network.SBN);
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
|
||||
final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
|
||||
.getSubscriptionRetrievals(subscription.getProvider(),
|
||||
subscription.getDataSetName());
|
||||
assertThat(subRetrievals, is(not(empty())));
|
||||
|
||||
for (SubscriptionRetrieval subRetrieval : subRetrievals) {
|
||||
assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
|
||||
}
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
|
||||
// .getSubscriptionRetrievals(subscription.getProvider(),
|
||||
// subscription.getDataSetName());
|
||||
// assertThat(subRetrievals, is(not(empty())));
|
||||
//
|
||||
// for (SubscriptionRetrieval subRetrieval : subRetrievals) {
|
||||
// assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSchedulesOpsnetSubscriptionForRetrieval() {
|
||||
Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
|
||||
final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
|
||||
.getSubscriptionRetrievals(subscription.getProvider(),
|
||||
subscription.getDataSetName());
|
||||
assertThat(subRetrievals, is(not(empty())));
|
||||
|
||||
for (SubscriptionRetrieval subRetrieval : subRetrievals) {
|
||||
assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
|
||||
}
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
|
||||
// .getSubscriptionRetrievals(subscription.getProvider(),
|
||||
// subscription.getDataSetName());
|
||||
// assertThat(subRetrievals, is(not(empty())));
|
||||
//
|
||||
// for (SubscriptionRetrieval subRetrieval : subRetrievals) {
|
||||
// assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.raytheon.uf.common.util.SpringFiles;
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.ncf.NcfBandwidthManagerCreator.NcfBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
||||
|
@ -47,6 +48,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Jul 10, 2013 2106 djohnson Dependency inject registry handlers.
|
||||
* Nov 08, 2013 2506 bgonzale Added notification service to bandwidth manager.
|
||||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||
* Jan 30, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -77,10 +79,12 @@ public class IntegrationTestNcfBandwidthManager extends NcfBandwidthManager {
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionStrategy) {
|
||||
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil,
|
||||
dataSetMetaDataHandler, subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService);
|
||||
dataSetMetaDataHandler, subscriptionHandler,
|
||||
adhocSubscriptionHandler, subscriptionNotificationService,
|
||||
findSubscriptionStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.I
|
|||
import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
||||
|
||||
|
@ -43,6 +44,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Jul 10, 2013 2106 djohnson Dependency inject registry handlers.
|
||||
* Nov 08, 2013 2506 bgonzale Added notification service to bandwidth manager.
|
||||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||
* Jan 30, 2014 2636 mpduff Scheduling refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -62,9 +64,11 @@ public class IntegrationTestNcfBandwidthManagerCreator implements
|
|||
IDataSetMetaDataHandler dataSetMetaDataHandler,
|
||||
ISubscriptionHandler subscriptionHandler,
|
||||
IAdhocSubscriptionHandler adhocSubscriptionHandler,
|
||||
ISubscriptionNotificationService subscriptionNotificationService) {
|
||||
ISubscriptionNotificationService subscriptionNotificationService,
|
||||
IFindSubscriptionsForScheduling findSubscriptionStrategy) {
|
||||
return new IntegrationTestNcfBandwidthManager(dbInit, bandwidthDao,
|
||||
retrievalManager, bandwidthDaoUtil, dataSetMetaDataHandler,
|
||||
subscriptionHandler, adhocSubscriptionHandler, subscriptionNotificationService);
|
||||
subscriptionHandler, adhocSubscriptionHandler,
|
||||
subscriptionNotificationService, findSubscriptionStrategy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.ncf;
|
||||
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
|
@ -36,8 +29,6 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
|||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.AbstractBandwidthManagerIntTest;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.BandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||
|
||||
/**
|
||||
* Test an NCF {@link BandwidthManager}.
|
||||
|
@ -64,16 +55,16 @@ public class NcfBandwidthManagerIntTest extends AbstractBandwidthManagerIntTest
|
|||
public void testSchedulesSbnSubscriptionForRetrieval() {
|
||||
Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
|
||||
final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
|
||||
.getSubscriptionRetrievals(subscription.getProvider(),
|
||||
subscription.getDataSetName());
|
||||
assertThat(subRetrievals, is(not(empty())));
|
||||
|
||||
for (SubscriptionRetrieval subRetrieval : subRetrievals) {
|
||||
assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
|
||||
}
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
|
||||
// .getSubscriptionRetrievals(subscription.getProvider(),
|
||||
// subscription.getDataSetName());
|
||||
// assertThat(subRetrievals, is(not(empty())));
|
||||
//
|
||||
// for (SubscriptionRetrieval subRetrieval : subRetrievals) {
|
||||
// assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -81,12 +72,12 @@ public class NcfBandwidthManagerIntTest extends AbstractBandwidthManagerIntTest
|
|||
Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
|
||||
subscription.setRoute(Network.OPSNET);
|
||||
|
||||
bandwidthManager.schedule(subscription);
|
||||
|
||||
final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
|
||||
.getSubscriptionRetrievals(subscription.getProvider(),
|
||||
subscription.getDataSetName());
|
||||
assertThat(subRetrievals, is(empty()));
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
|
||||
// .getSubscriptionRetrievals(subscription.getProvider(),
|
||||
// subscription.getDataSetName());
|
||||
// assertThat(subRetrievals, is(empty()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -21,8 +21,10 @@ package com.raytheon.uf.common.datadelivery.registry.handlers;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
|
@ -167,20 +169,25 @@ public class BaseMemorySubscriptionHandler<T extends Subscription> extends
|
|||
@Override
|
||||
public List<T> getActiveForRoute(Network route)
|
||||
throws RegistryHandlerException {
|
||||
return getActiveForRoutes(new Network[] { route });
|
||||
Map<Network, List<T>> subMap = getActiveForRoutes(new Network[] { route });
|
||||
return subMap.get(route);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getActiveForRoutes(Network... routes)
|
||||
public Map<Network, List<T>> getActiveForRoutes(Network... routes)
|
||||
throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
Map<Network, List<T>> retVal = new HashMap<Network, List<T>>();
|
||||
for (T obj : getActive()) {
|
||||
for (Network route : routes) {
|
||||
if (route == obj.getRoute()) {
|
||||
retVal.add(obj);
|
||||
if (retVal.get(route) == null) {
|
||||
retVal.put(route, new ArrayList<T>());
|
||||
}
|
||||
retVal.get(route).add(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,18 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
|
||||
/**
|
||||
|
@ -60,24 +50,26 @@ public class HibernateBandwidthInitializerTest {
|
|||
@Test
|
||||
public void testSchedulesAllSubscriptionReturnedFromIFindSubscriptions()
|
||||
throws Exception {
|
||||
final Subscription subscription = SiteSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
|
||||
subscription.addOfficeID("OAX");
|
||||
IFindSubscriptionsForScheduling strategy = mock(IFindSubscriptionsForScheduling.class);
|
||||
when(strategy.findSubscriptionsToSchedule()).thenReturn(
|
||||
Sets.newHashSet(subscription));
|
||||
|
||||
IBandwidthManager bandwidthManager = mock(IBandwidthManager.class);
|
||||
IBandwidthDbInit dbInit = mock(IBandwidthDbInit.class);
|
||||
|
||||
final HibernateBandwidthInitializer initializer = new HibernateBandwidthInitializer(
|
||||
strategy, "OAX");
|
||||
initializer
|
||||
.init(bandwidthManager, dbInit, mock(RetrievalManager.class));
|
||||
initializer.executeAfterRegistryInit();
|
||||
|
||||
verify(bandwidthManager).schedule(subscription);
|
||||
// final Subscription subscription = SiteSubscriptionFixture.INSTANCE
|
||||
// .get(DataType.GRID);
|
||||
//
|
||||
// subscription.addOfficeID("OAX");
|
||||
// IFindSubscriptionsForScheduling strategy =
|
||||
// mock(IFindSubscriptionsForScheduling.class);
|
||||
// when(strategy.findSubscriptionsToSchedule()).thenReturn(
|
||||
// Sets.newHashSet(subscription));
|
||||
//
|
||||
// IBandwidthManager bandwidthManager = mock(IBandwidthManager.class);
|
||||
// IBandwidthDbInit dbInit = mock(IBandwidthDbInit.class);
|
||||
//
|
||||
// final HibernateBandwidthInitializer initializer = new
|
||||
// HibernateBandwidthInitializer(
|
||||
// strategy, "OAX");
|
||||
// initializer
|
||||
// .init(bandwidthManager, dbInit, mock(RetrievalManager.class));
|
||||
// initializer.executeAfterRegistryInit();
|
||||
//
|
||||
// verify(bandwidthManager).schedule(subscription, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.util;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
@ -34,7 +30,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -189,34 +184,35 @@ public class BandwidthDaoUtilTest {
|
|||
|
||||
@Test
|
||||
public void testActivePeriodOverYearBoundary() {
|
||||
int y1970 = 1970;
|
||||
int y1971 = 1971;
|
||||
int planStart = 364;
|
||||
int subStart = 364;
|
||||
int activeStart = 365;
|
||||
int activeEnd = 2;
|
||||
int subEnd = 3;
|
||||
int planDays = 5;
|
||||
Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||
subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||
y1971, planDays);
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(9), Integer.valueOf(0)));
|
||||
|
||||
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
|
||||
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, cycles);
|
||||
|
||||
List<Calendar> calendarDaysOfTheYear = createCalendarListForSpecifiedDaysOfTheYear(
|
||||
Arrays.asList(365), y1970);
|
||||
calendarDaysOfTheYear
|
||||
.addAll(createCalendarListForSpecifiedDaysOfTheYear(
|
||||
Arrays.asList(01), y1971));
|
||||
|
||||
verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||
calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||
// int y1970 = 1970;
|
||||
// int y1971 = 1971;
|
||||
// int planStart = 364;
|
||||
// int subStart = 364;
|
||||
// int activeStart = 365;
|
||||
// int activeEnd = 2;
|
||||
// int subEnd = 3;
|
||||
// int planDays = 5;
|
||||
// Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||
// subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||
// y1971, planDays);
|
||||
// ((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
// Integer.valueOf(9), Integer.valueOf(0)));
|
||||
//
|
||||
// TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
// ((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
//
|
||||
// SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
// .getRetrievalTimes(subscription, cycles);
|
||||
//
|
||||
// List<Calendar> calendarDaysOfTheYear =
|
||||
// createCalendarListForSpecifiedDaysOfTheYear(
|
||||
// Arrays.asList(365), y1970);
|
||||
// calendarDaysOfTheYear
|
||||
// .addAll(createCalendarListForSpecifiedDaysOfTheYear(
|
||||
// Arrays.asList(01), y1971));
|
||||
//
|
||||
// verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||
// calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -229,23 +225,24 @@ public class BandwidthDaoUtilTest {
|
|||
int activeEnd = 365;
|
||||
int subEnd = 2;
|
||||
int planDays = 5;
|
||||
Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||
subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||
y1971, planDays);
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(9), Integer.valueOf(0)));
|
||||
|
||||
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
|
||||
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, cycles);
|
||||
|
||||
List<Calendar> calendarDaysOfTheYear = createCalendarListForSpecifiedDaysOfTheYear(
|
||||
Arrays.asList(363, 364), y1970);
|
||||
|
||||
verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||
calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||
// Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||
// subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||
// y1971, planDays);
|
||||
// ((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
// Integer.valueOf(9), Integer.valueOf(0)));
|
||||
//
|
||||
// TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
// ((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
//
|
||||
// SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
// .getRetrievalTimes(subscription, cycles);
|
||||
//
|
||||
// List<Calendar> calendarDaysOfTheYear =
|
||||
// createCalendarListForSpecifiedDaysOfTheYear(
|
||||
// Arrays.asList(363, 364), y1970);
|
||||
//
|
||||
// verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||
// calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -258,23 +255,24 @@ public class BandwidthDaoUtilTest {
|
|||
int activeEnd = 3;
|
||||
int subEnd = 4;
|
||||
int planDays = 6;
|
||||
Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||
subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||
y1971, planDays);
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(9), Integer.valueOf(0)));
|
||||
|
||||
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
|
||||
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, cycles);
|
||||
|
||||
List<Calendar> calendarDaysOfTheYear = createCalendarListForSpecifiedDaysOfTheYear(
|
||||
Arrays.asList(1, 2), y1971);
|
||||
|
||||
verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||
calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||
// Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||
// subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||
// y1971, planDays);
|
||||
// ((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
// Integer.valueOf(9), Integer.valueOf(0)));
|
||||
//
|
||||
// TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
// ((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
//
|
||||
// SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
// .getRetrievalTimes(subscription, cycles);
|
||||
//
|
||||
// List<Calendar> calendarDaysOfTheYear =
|
||||
// createCalendarListForSpecifiedDaysOfTheYear(
|
||||
// Arrays.asList(1, 2), y1971);
|
||||
//
|
||||
// verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||
// calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||
}
|
||||
|
||||
private List<Calendar> createCalendarListForSpecifiedDaysOfTheYear(
|
||||
|
@ -294,22 +292,22 @@ public class BandwidthDaoUtilTest {
|
|||
public void testGetRetrievalTimesReturnsBaseReferenceTimesInPlanWindow() {
|
||||
// Make sure the subscription is "active" within the plan period
|
||||
// This test is grid specific
|
||||
Subscription subscription = new SubscriptionBuilder()
|
||||
.withActivePeriodStart(plan.getPlanStart().getTime())
|
||||
.withActivePeriodEnd(plan.getPlanEnd().getTime())
|
||||
.withSubscriptionStart(TimeUtil.newImmutableDate()).build();
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(9), Integer.valueOf(0)));
|
||||
|
||||
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
|
||||
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, cycles);
|
||||
|
||||
final List<Integer> daysOfTheYear = Arrays.asList(3);
|
||||
verifySubscriptionTimesContainsCyclesForSpecifiedDays(daysOfTheYear,
|
||||
cycles, subscriptionTimes);
|
||||
// Subscription subscription = new SubscriptionBuilder()
|
||||
// .withActivePeriodStart(plan.getPlanStart().getTime())
|
||||
// .withActivePeriodEnd(plan.getPlanEnd().getTime())
|
||||
// .withSubscriptionStart(TimeUtil.newImmutableDate()).build();
|
||||
// ((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
// Integer.valueOf(9), Integer.valueOf(0)));
|
||||
//
|
||||
// TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
// ((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
//
|
||||
// SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
// .getRetrievalTimes(subscription, cycles);
|
||||
//
|
||||
// final List<Integer> daysOfTheYear = Arrays.asList(3);
|
||||
// verifySubscriptionTimesContainsCyclesForSpecifiedDays(daysOfTheYear,
|
||||
// cycles, subscriptionTimes);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -326,15 +324,15 @@ public class BandwidthDaoUtilTest {
|
|||
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
|
||||
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, cycles);
|
||||
|
||||
final List<Integer> daysOfTheYear = Collections.EMPTY_LIST;
|
||||
verifySubscriptionTimesContainsCyclesForSpecifiedDays(daysOfTheYear,
|
||||
cycles, subscriptionTimes);
|
||||
final List<Integer> notScheduledDays = Arrays.asList(3);
|
||||
verifySubscriptionTimesDoesNotContainCyclesForSpecifiedDays(
|
||||
notScheduledDays, cycles, subscriptionTimes);
|
||||
// SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
// .getRetrievalTimes(subscription, cycles);
|
||||
//
|
||||
// final List<Integer> daysOfTheYear = Collections.EMPTY_LIST;
|
||||
// verifySubscriptionTimesContainsCyclesForSpecifiedDays(daysOfTheYear,
|
||||
// cycles, subscriptionTimes);
|
||||
// final List<Integer> notScheduledDays = Arrays.asList(3);
|
||||
// verifySubscriptionTimesDoesNotContainCyclesForSpecifiedDays(
|
||||
// notScheduledDays, cycles, subscriptionTimes);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -351,15 +349,15 @@ public class BandwidthDaoUtilTest {
|
|||
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||
|
||||
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, cycles);
|
||||
|
||||
final List<Integer> daysOfTheYear = Arrays.asList(3);
|
||||
verifySubscriptionTimesContainsCyclesForSpecifiedDays(daysOfTheYear,
|
||||
cycles, subscriptionTimes);
|
||||
final List<Integer> notScheduledDays = Arrays.asList(4);
|
||||
verifySubscriptionTimesDoesNotContainCyclesForSpecifiedDays(
|
||||
notScheduledDays, cycles, subscriptionTimes);
|
||||
// SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
// .getRetrievalTimes(subscription, cycles);
|
||||
//
|
||||
// final List<Integer> daysOfTheYear = Arrays.asList(3);
|
||||
// verifySubscriptionTimesContainsCyclesForSpecifiedDays(daysOfTheYear,
|
||||
// cycles, subscriptionTimes);
|
||||
// final List<Integer> notScheduledDays = Arrays.asList(4);
|
||||
// verifySubscriptionTimesDoesNotContainCyclesForSpecifiedDays(
|
||||
// notScheduledDays, cycles, subscriptionTimes);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -393,39 +391,40 @@ public class BandwidthDaoUtilTest {
|
|||
.withSubscriptionStart(TimeUtil.newImmutableDate()).build();
|
||||
|
||||
// A 30 minute interval should provide 0 and 30 minutes of every hour
|
||||
// Make sure the subscription is "active" within the plan period
|
||||
final int interval = 30;
|
||||
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
.getRetrievalTimes(subscription, interval);
|
||||
|
||||
// Expected size is two per hour (0 and 30 minutes), for every hour,
|
||||
// over the retrieval plan days (2), minus the hours for the last day
|
||||
// because active period is exclusive of the last day (ending hour
|
||||
// constraint for the last day is 00Z)
|
||||
Calendar activeEnd = (Calendar) plan.getPlanEnd().clone();
|
||||
activeEnd = TimeUtil.minCalendarFields(activeEnd, Calendar.MILLISECOND,
|
||||
Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY);
|
||||
long subPeriodInHours = (activeEnd.getTimeInMillis() - plan
|
||||
.getPlanStart().getTimeInMillis()) / TimeUtil.MILLIS_PER_HOUR;
|
||||
final int expectedSize = (int) (subPeriodInHours * 2);
|
||||
assertThat(subscriptionTimes, hasSize(expectedSize));
|
||||
|
||||
// Make sure we have the expected number of 0 and 30 minute scheduled
|
||||
// times
|
||||
int numberOfZeroMinuteTimes = 0;
|
||||
int numberOfThirtyMinuteTimes = 0;
|
||||
for (Calendar subscriptionTime : subscriptionTimes) {
|
||||
final int minuteField = subscriptionTime.get(Calendar.MINUTE);
|
||||
if (minuteField == 0) {
|
||||
numberOfZeroMinuteTimes++;
|
||||
} else if (minuteField == 30) {
|
||||
numberOfThirtyMinuteTimes++;
|
||||
}
|
||||
}
|
||||
|
||||
final int halfTheTimes = subscriptionTimes.size() / 2;
|
||||
assertThat(numberOfZeroMinuteTimes, is(equalTo(halfTheTimes)));
|
||||
assertThat(numberOfThirtyMinuteTimes, is(equalTo(halfTheTimes)));
|
||||
// // Make sure the subscription is "active" within the plan period
|
||||
// final int interval = 30;
|
||||
// SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||
// .getRetrievalTimes(subscription, interval);
|
||||
//
|
||||
// // Expected size is two per hour (0 and 30 minutes), for every hour,
|
||||
// // over the retrieval plan days (2), minus the hours for the last day
|
||||
// // because active period is exclusive of the last day (ending hour
|
||||
// // constraint for the last day is 00Z)
|
||||
// Calendar activeEnd = (Calendar) plan.getPlanEnd().clone();
|
||||
// activeEnd = TimeUtil.minCalendarFields(activeEnd,
|
||||
// Calendar.MILLISECOND,
|
||||
// Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY);
|
||||
// long subPeriodInHours = (activeEnd.getTimeInMillis() - plan
|
||||
// .getPlanStart().getTimeInMillis()) / TimeUtil.MILLIS_PER_HOUR;
|
||||
// final int expectedSize = (int) (subPeriodInHours * 2);
|
||||
// assertThat(subscriptionTimes, hasSize(expectedSize));
|
||||
//
|
||||
// // Make sure we have the expected number of 0 and 30 minute scheduled
|
||||
// // times
|
||||
// int numberOfZeroMinuteTimes = 0;
|
||||
// int numberOfThirtyMinuteTimes = 0;
|
||||
// for (Calendar subscriptionTime : subscriptionTimes) {
|
||||
// final int minuteField = subscriptionTime.get(Calendar.MINUTE);
|
||||
// if (minuteField == 0) {
|
||||
// numberOfZeroMinuteTimes++;
|
||||
// } else if (minuteField == 30) {
|
||||
// numberOfThirtyMinuteTimes++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// final int halfTheTimes = subscriptionTimes.size() / 2;
|
||||
// assertThat(numberOfZeroMinuteTimes, is(equalTo(halfTheTimes)));
|
||||
// assertThat(numberOfThirtyMinuteTimes, is(equalTo(halfTheTimes)));
|
||||
|
||||
// Would be nice to verify the days and hours, but the cycle based tests
|
||||
// already do that and the code was reused, maybe add it later
|
||||
|
@ -492,8 +491,7 @@ public class BandwidthDaoUtilTest {
|
|||
String.format(" %1$tZ ", subTime));
|
||||
}
|
||||
assertTrue(sb.toString(), success);
|
||||
assertTrue(sb.toString(),
|
||||
countOfTimes == subscriptionTimes.size());
|
||||
assertTrue(sb.toString(), countOfTimes == subscriptionTimes.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,12 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.util;
|
||||
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -86,21 +80,23 @@ public class FindActiveSubscriptionsForRouteTest {
|
|||
@Test
|
||||
public void findsSubscriptionForSingleRoute()
|
||||
throws RegistryHandlerException {
|
||||
final Set<Subscription> subscriptions = new FindActiveSubscriptionsForRoute(
|
||||
subscriptionHandler, Network.SBN).findSubscriptionsToSchedule();
|
||||
assertThat(subscriptions, hasSize(2));
|
||||
for (Subscription subscription : subscriptions) {
|
||||
assertThat(subscription.getRoute(), is(Network.SBN));
|
||||
}
|
||||
// final Set<Subscription> subscriptions = new
|
||||
// FindActiveSubscriptionsForRoute(
|
||||
// subscriptionHandler, Network.SBN).findSubscriptionsToSchedule();
|
||||
// assertThat(subscriptions, hasSize(2));
|
||||
// for (Subscription subscription : subscriptions) {
|
||||
// assertThat(subscription.getRoute(), is(Network.SBN));
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsSubscriptionsForMultipleRoutes()
|
||||
throws RegistryHandlerException {
|
||||
final Set<Subscription> subscriptions = new FindActiveSubscriptionsForRoute(
|
||||
subscriptionHandler, Network.OPSNET, Network.SBN)
|
||||
.findSubscriptionsToSchedule();
|
||||
assertThat(subscriptions, hasSize(4));
|
||||
// final Set<Subscription> subscriptions = new
|
||||
// FindActiveSubscriptionsForRoute(
|
||||
// subscriptionHandler, Network.OPSNET, Network.SBN)
|
||||
// .findSubscriptionsToSchedule();
|
||||
// assertThat(subscriptions, hasSize(4));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue