Merge "Issue #1543 Use separate RetrievalPlan configurations for NCF and WFO - Change new registry modes to explicitly list includes/excludes. - Add separate bandwidth manager creation capabilities for NCF and WFO. - Add deltaScript to add a "route" slot to subscriptions. - Remove unnecessary schemas from Spring files." into development

Former-commit-id: 8256f182c2 [formerly b6602f9468] [formerly a9e976eed8] [formerly cb1380af90 [formerly a9e976eed8 [formerly 1d4453fdcdfd5c34d943f1a595a31820fedd133c]]]
Former-commit-id: cb1380af90
Former-commit-id: 48d8590ebfaa96f41ee4b9def3d4c9a8b17d1c3c [formerly 5031ae4d66]
Former-commit-id: f552967bf3
This commit is contained in:
Dustin Johnson 2013-02-20 16:17:20 -06:00 committed by Gerrit Code Review
commit 18cfc1ee4d
44 changed files with 1454 additions and 163 deletions

View file

@ -0,0 +1,23 @@
#!/bin/bash
SQL_SCRIPT="addRouteToSubscriptionSlots.sql"
# ensure that the sql script is present
if [ ! -f ${SQL_SCRIPT} ]; then
echo "ERROR: the required sql script - ${SQL_SCRIPT} was not found."
echo "FATAL: the update has failed!"
exit 1
fi
echo "INFO: update started"
# run the update
/awips2/psql/bin/psql -U awips -d ebxml -f ${SQL_SCRIPT}
if [ $? -ne 0 ]; then
echo "FATAL: the update has failed!"
exit 1
fi
echo "INFO: the update has completed successfully!"
exit 0

View file

@ -0,0 +1,72 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
\set ON_ERROR_STOP 1
\connect ebxml;
-- Create a function that will load plpgsql
CREATE OR REPLACE FUNCTION make_plpgsql()
RETURNS VOID
LANGUAGE SQL
AS $$
CREATE LANGUAGE plpgsql;
$$;
-- Load plpgsql if it is not already loaded
SELECT
CASE
WHEN EXISTS(
SELECT 1
FROM pg_catalog.pg_language
WHERE lanname='plpgsql'
)
THEN NULL
ELSE make_plpgsql() END;
-- The function to add a route slot to subscriptions
CREATE OR REPLACE FUNCTION addRouteSlot() RETURNS void AS $$
DECLARE
registryobject_record RECORD;
value_key INTEGER;
slot_key INTEGER;
registryobjectslot_key INTEGER;
BEGIN
-- Find all subscription registry objects
FOR registryobject_record IN SELECT id from registryobject where objecttype like '%Subscription' LOOP
-- Create the value for the slot
SELECT INTO value_key nextval('hibernate_sequence');
INSERT INTO value (dtype, key, stringvalue) VALUES ('StringValueType', value_key, 'OPSNET');
-- Create the slot entry itself
SELECT INTO slot_key nextval('hibernate_sequence');
INSERT INTO slot (key, name, slotvalue_key) VALUES (slot_key, 'route', value_key);
-- Create the registryobject_slot entry
SELECT INTO registryobjectslot_key nextval('hibernate_sequence');
INSERT INTO registryobject_slot (registryobject_id, child_slot_key) VALUES (registryobject_record.id, slot_key);
END LOOP;
END;
$$ LANGUAGE plpgsql;
-- Add the route slots to subscriptions
SELECT addRouteSlot();
-- Drop functions
DROP FUNCTION make_plpgsql();
DROP FUNCTION addRouteSlot();

View file

@ -187,14 +187,21 @@
<include>ebxml.*\.xml</include>
<includeMode>statsTemplate</includeMode>
<includeMode>dataDeliveryTemplate</includeMode>
<exclude>.*datadelivery-ncf.*</exclude>
</mode>
<!-- Eventually these two modes will either become the production versions,
or the existing registry server will be migrated to one or the other. -->
<mode name="ncfRegistry">
<includeMode>registry</includeMode>
<include>ebxml.*\.xml</include>
<includeMode>statsTemplate</includeMode>
<includeMode>dataDeliveryTemplate</includeMode>
<exclude>.*datadelivery-wfo.*</exclude>
</mode>
<mode name="wfoRegistry">
<includeMode>registry</includeMode>
<include>ebxml.*\.xml</include>
<includeMode>statsTemplate</includeMode>
<includeMode>dataDeliveryTemplate</includeMode>
<exclude>.*datadelivery-ncf.*</exclude>
<exclude>harvester-*</exclude>
<exclude>crawler-*</exclude>
</mode>

View file

@ -54,6 +54,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Dec 12, 2012 1433 bgonzale Refactored Subscription copy ctor into two ctors.
* Jan 03, 2013 1441 djohnson Default to no group.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
* Feb 20, 2013 1543 djohnson Route is now a slot.
*
* </pre>
*
@ -151,6 +152,9 @@ public class Subscription implements ISerializableObject, Serializable {
/** Owner slot */
public static final String OWNER_SLOT = "owner";
/** Route slot */
public static final String ROUTE_SLOT = "route";
/**
* Constructor.
*/
@ -329,6 +333,7 @@ public class Subscription implements ISerializableObject, Serializable {
@XmlAttribute
@DynamicSerializeElement
@SlotAttribute(Subscription.ROUTE_SLOT)
private Network route = Network.OPSNET;
@XmlAttribute

View file

@ -1,11 +1,14 @@
package com.raytheon.uf.common.datadelivery.registry.ebxml;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.registry.ebxml.AdhocRegistryQuery;
import com.raytheon.uf.common.registry.ebxml.BooleanAttribute;
import com.raytheon.uf.common.registry.ebxml.CalendarAttribute;
@ -29,6 +32,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
* Aug 02, 2012 955 djohnson Add generics and results retrieval to registry queries.
* Oct 03, 2012 1241 djohnson Move query parameters in from SubscriptionQuery.
* Oct 10, 2012 0726 djohnson Add {@link #setActive(boolean)}.
* Feb 20, 2013 1543 djohnson Add ability to filter on routes.
*
* </pre>
*
@ -158,4 +162,18 @@ public abstract class SubscriptionFilterableQuery<T> extends
public void setProviderNames(List<String> providerNames) {
setAttribute("provider", new StringAttribute(providerNames));
}
/**
* Set the routes to match.
*
* @param routes
* the routes
*/
public void setRoutes(List<Network> routes) {
List<String> enumValues = new ArrayList<String>(routes.size());
for (Network route : routes) {
enumValues.add(route.toString());
}
setAttribute(Subscription.ROUTE_SLOT, new StringAttribute(enumValues));
}
}

View file

@ -19,10 +19,12 @@
**/
package com.raytheon.uf.common.datadelivery.registry.handlers;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.ebxml.SubscriptionDataSetNameQuery;
import com.raytheon.uf.common.datadelivery.registry.ebxml.SubscriptionFilterableQuery;
@ -43,6 +45,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
* Sep 18, 2012 1169 djohnson Initial creation
* Oct 03, 2012 1241 djohnson More query methods.
* Oct 10, 2012 0726 djohnson Add {@link #getActive()}.
* Feb 20, 2013 1543 djohnson Add ability to filter on routes.
*
* </pre>
*
@ -155,4 +158,32 @@ abstract class BaseSubscriptionHandler<T extends Subscription, QUERY extends Sub
return response.getResults();
}
/**
* {@inheritDoc}
*/
@Override
public List<T> getActiveForRoute(Network route)
throws RegistryHandlerException {
return getActiveForRoutes(route);
}
/**
* {@inheritDoc}
*/
@Override
public List<T> getActiveForRoutes(Network... routes)
throws RegistryHandlerException {
SubscriptionFilterableQuery<T> query = getQuery();
query.setActive(true);
query.setRoutes(Arrays.asList(routes));
RegistryQueryResponse<T> response = RegistryManager
.getRegistyObjects(query);
checkResponse(response, "getActiveForRoutes");
return response.getResults();
}
}

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.common.datadelivery.registry.handlers;
import java.util.List;
import java.util.Set;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.registry.handler.IRegistryObjectHandler;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
@ -39,6 +40,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
* Sep 18, 2012 1169 djohnson Initial creation
* Oct 03, 2012 1241 djohnson More query methods.
* Oct 10, 2012 0726 djohnson Add {@link #getActive()}.
* Feb 20, 2013 1543 djohnson Add ability to filter on routes.
*
* </pre>
*
@ -110,4 +112,27 @@ public interface IBaseSubscriptionHandler<T extends Subscription> extends
* on error
*/
List<T> getActive() throws RegistryHandlerException;
/**
* Retrieve all active subscriptions for the specified route.
*
* @param route
* the route
* @return the list of subscriptions meeting the criteria
* @throws RegistryHandlerException
* on error
*/
List<T> getActiveForRoute(Network route) throws RegistryHandlerException;
/**
* Retrieve all active subscriptions for the specified route.
*
* @param routes
* the routes
* @return the list of subscriptions meeting the criteria
* @throws RegistryHandlerException
* on error
*/
List<T> getActiveForRoutes(Network... routes)
throws RegistryHandlerException;
}

View file

@ -1,9 +1,7 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean id="bandwidthAllocationDao"
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthAllocationDao">
@ -14,12 +12,12 @@
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthSubscriptionDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="subscriptionRetrievalDao"
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.SubscriptionRetrievalDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="bandwidthDataSetUpdateDao"
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthDataSetUpdateDao">
<property name="sessionFactory" ref="metadataSessionFactory" />

View file

@ -1,6 +1,5 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
@ -12,11 +11,26 @@
<!-- This bean version is used to set the EDEX instance of BandwidthManager -->
<constructor-arg ref="bandwidthManager" />
</bean>
<!-- Used as the context for creating the BandwidthManager -->
<bean id="bandwidthContextFactory"
class="com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory">
<!-- Used as the context for creating the BandwidthManager -->
<!-- The bandwidth dao implementation -->
<constructor-arg ref="hibernateBandwidthDao" />
<!-- The bandwidth manager initializer -->
<constructor-arg>
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthInitializer">
<constructor-arg>
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.FindActiveSubscriptionsForRoute">
<constructor-arg ref="subscriptionRoutesToSchedule" />
</bean>
</constructor-arg>
</bean>
</constructor-arg>
<!-- The strategy for how to create the bandwidth manager -->
<constructor-arg ref="bandwidthManagerCreator" />
</bean>
<util:map id="retrievalAgents">

View file

@ -1,19 +1,18 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- Separated from the other beans because we want to be able to use
any DAO implementation along with the other Spring files (e.g. in-memory
version in order to test proposed changes and inform the user of their effects) -->
<bean id="bandwidthContextFactory"
class="com.raytheon.uf.edex.datadelivery.bandwidth.InMemoryBandwidthContextFactory" />
<bean id="retrievalAgents" class="java.util.Collections" factory-method="emptyMap">
<bean id="retrievalAgents" class="java.util.Collections"
factory-method="emptyMap">
<!-- No retrievals for in-memory -->
</bean>
<bean id="registryManagerInstanceInitializer" class="java.lang.String">
<!-- required for depends-on -->
</bean>

View file

@ -0,0 +1,9 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean id="bandwidthManagerCreator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.NcfBandwidthManagerCreator" />
</beans>

View file

@ -0,0 +1,27 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<util:list id="subscriptionRoutesToSchedule">
<value>SBN</value>
</util:list>
<bean id="SBNRetrievalPlan"
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan">
<constructor-arg value="SBN" />
<constructor-arg ref="BandwidthMap" />
<constructor-arg ref="bandwidthDao" />
<property name="scheduler">
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.PriorityRetrievalScheduler" />
</property>
</bean>
<util:map id="retrievalPlans">
<entry key="SBN">
<ref local="SBNRetrievalPlan" />
</entry>
</util:map>
</beans>

View file

@ -0,0 +1,9 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean id="bandwidthManagerCreator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.WfoBandwidthManagerCreator" />
</beans>

View file

@ -0,0 +1,44 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<util:list id="subscriptionRoutesToSchedule">
<value>OPSNET</value>
<value>SBN</value>
</util:list>
<bean id="OPSNETRetrievalPlan"
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan">
<constructor-arg value="OPSNET" />
<constructor-arg ref="BandwidthMap" />
<constructor-arg ref="bandwidthDao" />
<property name="scheduler">
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.PriorityRetrievalScheduler" />
</property>
</bean>
<!-- SBN routed subscriptions are scheduled for retrieval at the WFO,
but the actual retrieval occurs at the NCF -->
<bean id="SBNRetrievalPlan"
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan">
<constructor-arg value="SBN" />
<constructor-arg ref="BandwidthMap" />
<constructor-arg ref="bandwidthDao" />
<property name="scheduler">
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.PriorityRetrievalScheduler" />
</property>
</bean>
<util:map id="retrievalPlans">
<entry key="OPSNET">
<ref local="OPSNETRetrievalPlan" />
</entry>
<entry key="SBN">
<ref local="SBNRetrievalPlan" />
</entry>
</util:map>
</beans>

View file

@ -1,9 +1,7 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
@ -14,27 +12,22 @@
</property>
</bean>
<bean id="bandwidthDao"
factory-bean="bandwidthContextFactory"
factory-method="getBandwidthDao"/>
<bean id="bandwidthDao" factory-bean="bandwidthContextFactory"
factory-method="getBandwidthDao" />
<bean id="bandwidthDbInit"
factory-bean="bandwidthContextFactory"
factory-method="getBandwidthDbInit"
init-method="init" />
<bean id="bandwidthManagerInitializer"
factory-bean="bandwidthContextFactory"
factory-method="getBandwidthInitializer"
depends-on="registryManagerInstanceInitializer">
<bean id="bandwidthDbInit" factory-bean="bandwidthContextFactory"
factory-method="getBandwidthDbInit" init-method="init" />
<bean id="bandwidthManagerInitializer" factory-bean="bandwidthContextFactory"
factory-method="getBandwidthInitializer" depends-on="registryManagerInstanceInitializer">
</bean>
<bean id="bandwidthMapConfigFile"
factory-bean="bandwidthContextFactory"
<bean id="bandwidthMapConfigFile" factory-bean="bandwidthContextFactory"
factory-method="getBandwidthMapConfigFile" />
<bean id="bandwidthManager" factory-bean="bandwidthContextFactory"
factory-method="getBandwidthManager" depends-on="BandwidthEventBusConfig,bandwidthUtil,registerDataDeliveryHandlers"
factory-method="getBandwidthManager"
depends-on="BandwidthEventBusConfig,bandwidthUtil,registerDataDeliveryHandlers"
init-method="init">
<constructor-arg ref="bandwidthDbInit" />
<constructor-arg ref="bandwidthDao" />
@ -43,7 +36,7 @@
<property name="aggregator" ref="aggregator" />
<property name="initializer" ref="bandwidthManagerInitializer" />
</bean>
<bean id="dataSetAvailabilityCalculator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.SimpleAvailablityCalculator">
<property name="delay"
@ -55,14 +48,17 @@
factory-method="getInstance">
<property name="dataSetAvailabilityCalculator" ref="dataSetAvailabilityCalculator" />
<property name="subscriptionLatencyCalculator">
<bean class="com.raytheon.uf.edex.datadelivery.bandwidth.util.SubscriptionValueLatencyCalculator" />
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.SubscriptionValueLatencyCalculator" />
</property>
<property name="subscriptionRescheduleStrategy">
<bean class="com.raytheon.uf.edex.datadelivery.bandwidth.util.AlwaysRescheduleSubscriptions" />
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.AlwaysRescheduleSubscriptions" />
</property>
</bean>
<bean id="bandwidthDaoUtil" class="com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil">
<bean id="bandwidthDaoUtil"
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil">
<constructor-arg ref="bandwidthDao" />
<constructor-arg ref="retrievalManager" />
</bean>
@ -72,11 +68,12 @@
factory-method="load">
<constructor-arg ref="bandwidthMapConfigFile" />
</bean>
<bean id="aggregator" class="com.raytheon.uf.edex.datadelivery.bandwidth.processing.SimpleSubscriptionAggregator">
<bean id="aggregator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.processing.SimpleSubscriptionAggregator">
<constructor-arg ref="bandwidthDao" />
</bean>
<bean id="BandwidthEventBusConfig"
class="com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthEventBusConfig">
<property name="dataSetMetaDataPoolSize" value="${bandwidth.dataSetMetaDataPoolSize}" />
@ -84,19 +81,10 @@
<property name="subscriptionPoolSize" value="${bandwidth.subscriptionPoolSize}" />
</bean>
<bean id="OPSNETRetrievalPlan"
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan">
<constructor-arg value="OPSNET" />
<constructor-arg ref="BandwidthMap" />
<constructor-arg ref="bandwidthDao" />
<property name="scheduler">
<bean class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.PriorityRetrievalScheduler" />
</property>
</bean>
<!-- The shared monitor object between the RetrievalAgentManager and its Agents -->
<!-- The shared monitor object between the RetrievalAgentManager and
its Agents -->
<bean id="retrievalAgentNotifier" class="java.lang.Object" />
<bean id="subscriptionRetrievalAgentPrototype"
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.SubscriptionRetrievalAgent"
scope="prototype">
@ -122,21 +110,15 @@
depends-on="bandwidthDbInit">
<constructor-arg ref="bandwidthDao" />
<constructor-arg ref="retrievalAgentNotifier" />
<property name="retrievalPlans">
<map>
<entry key="OPSNET">
<ref local="OPSNETRetrievalPlan" />
</entry>
</map>
</property>
<property name="retrievalPlans" ref="retrievalPlans" />
</bean>
<bean id="BandwidthManagerProcessor"
class="com.raytheon.uf.edex.datadelivery.bandwidth.processing.Processor" />
<bean id="BandwidthManagerRetrieval"
class="com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerationHandler">
<constructor-arg ref="retrievalDao" />
</bean>
<bean id="SubscriptionBundleSeparator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.separator.SubscriptionBundleSeparator" />
<bean id="BandwidthManagerProcessor"
class="com.raytheon.uf.edex.datadelivery.bandwidth.processing.Processor" />
<bean id="BandwidthManagerRetrieval"
class="com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerationHandler">
<constructor-arg ref="retrievalDao" />
</bean>
<bean id="SubscriptionBundleSeparator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.separator.SubscriptionBundleSeparator" />
</beans>

View file

@ -1,20 +1,19 @@
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="bandwidthService"
class="com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService" />
<bean id="bandwidthHandler" class="com.raytheon.uf.edex.datadelivery.bandwidth.handler.GraphDataHandler">
<bean id="bandwidthHandler"
class="com.raytheon.uf.edex.datadelivery.bandwidth.handler.GraphDataHandler">
<constructor-arg ref="bandwidthService" />
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.datadelivery.bandwidth.request.GraphDataRequest"/>
<constructor-arg ref="bandwidthHandler"/>
<constructor-arg
value="com.raytheon.uf.common.datadelivery.bandwidth.request.GraphDataRequest" />
<constructor-arg ref="bandwidthHandler" />
</bean>
</beans>

View file

@ -1,7 +1,6 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="bandwidthHandlerRegistry" class="com.raytheon.uf.edex.auth.HandlerRegistry"
factory-method="getInstance" />

View file

@ -100,6 +100,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Feb 05, 2013 1580 mpduff EventBus refactor.
* Feb 14, 2013 1595 djohnson Check with BandwidthUtil whether or not to reschedule subscriptions on update.
* Feb 14, 2013 1596 djohnson Do not reschedule allocations when a subscription is removed.
* Feb 20, 2013 1543 djohnson Add try/catch blocks during the shutdown process.
* </pre>
*
* @author dhladky
@ -1464,10 +1465,30 @@ abstract class BandwidthManager extends
*/
@VisibleForTesting
void shutdown() {
EventBus.unregister(this);
BandwidthEventBus.unregister(this);
retrievalManager.shutdown();
scheduler.shutdownNow();
try {
EventBus.unregister(this);
} catch (Exception e) {
statusHandler.handle(Priority.WARN,
"Unable to unregister from the EventBus.", e);
}
try {
BandwidthEventBus.unregister(this);
} catch (Exception e) {
statusHandler.handle(Priority.WARN,
"Unable to unregister from the BandwidthEventBus.", e);
}
try {
retrievalManager.shutdown();
} catch (Exception e) {
statusHandler.handle(Priority.WARN,
"Unable to shutdown the retrievalManager.", e);
}
try {
scheduler.shutdownNow();
} catch (Exception e) {
statusHandler.handle(Priority.WARN,
"Unable to shutdown the scheduler.", e);
}
}
/**

View file

@ -32,7 +32,6 @@ 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.HibernateBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDbInit;
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthInitializer;
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;
@ -48,6 +47,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2012 1286 djohnson Initial creation
* Feb 20, 2013 1543 djohnson Add IEdexBandwidthManagerCreator.
*
* </pre>
*
@ -56,28 +56,63 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
*/
class EdexBandwidthContextFactory implements BandwidthContextFactory {
/**
* Pluggable strategy for how to create the {@link BandwidthManager}.
* Intentionally package-private.
*/
static interface IEdexBandwidthManagerCreator {
/**
* Get the bandwidth manaager.
*
* @param dbInit
* @param bandwidthDao
* @param retrievalManager
* @param bandwidthDaoUtil
* @return the bandwidth manager
*/
IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil);
}
private static BandwidthManager instance;
private IBandwidthDao bandwidthDao;
private final IBandwidthDao bandwidthDao;
private final BandwidthInitializer bandwidthInitializer;
private final IEdexBandwidthManagerCreator bandwidthManagerCreator;
/**
* Intentionally package-private constructor, as it is created from Spring
* which is able to reflectively instantiate.
*
* @param instance
* the {@link BandwidthManager} instance
* @param bandwidthDao
* @param findSubscriptionStrategy
*/
EdexBandwidthContextFactory(IBandwidthDao bandwidthDao) {
EdexBandwidthContextFactory(IBandwidthDao bandwidthDao,
BandwidthInitializer bandwidthInitializer,
IEdexBandwidthManagerCreator bandwidthManagerCreator) {
this.bandwidthDao = bandwidthDao;
this.bandwidthInitializer = bandwidthInitializer;
this.bandwidthManagerCreator = bandwidthManagerCreator;
}
/**
* Intentionally package-private constructor, as it is created from Spring
* which is able to reflectively instantiate.
* Intentionally private constructor, as it is created from Spring which is
* able to reflectively instantiate. It is only used to set the
* {@link BandwidthManager} instance.
*
* @param instance
* the {@link BandwidthManager} instance
*/
@SuppressWarnings("unused")
private EdexBandwidthContextFactory(BandwidthManager instance) {
EdexBandwidthContextFactory.instance = instance;
this.bandwidthDao = null;
this.bandwidthInitializer = null;
this.bandwidthManagerCreator = null;
}
/**
@ -128,7 +163,7 @@ class EdexBandwidthContextFactory implements BandwidthContextFactory {
*/
@Override
public BandwidthInitializer getBandwidthInitializer() {
return new HibernateBandwidthInitializer();
return bandwidthInitializer;
}
/**
@ -146,7 +181,7 @@ class EdexBandwidthContextFactory implements BandwidthContextFactory {
public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
return new EdexBandwidthManager(dbInit, bandwidthDao, retrievalManager,
bandwidthDaoUtil);
return bandwidthManagerCreator.getBandwidthManager(dbInit,
bandwidthDao, retrievalManager, bandwidthDaoUtil);
}
}

View file

@ -42,6 +42,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 30, 2012 1286 djohnson Initial creation
* Feb 20, 2013 1543 djohnson For now assume all in-memory bandwidth managers are WFOs.
*
* </pre>
*
@ -53,9 +54,12 @@ class InMemoryBandwidthManager extends BandwidthManager {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(InMemoryBandwidthManager.class);
// TODO DPJ: The NCF and WFO bandwidth managers probably each need an
// in-memory version
public static final String[] IN_MEMORY_BANDWIDTH_MANAGER_FILES = new String[] {
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-inmemory-impl.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml") };
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-wfo.xml") };
/**
* {@link BandwidthInitializer} which will make a copy of the current

View file

@ -0,0 +1,89 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
import com.raytheon.uf.common.util.JarUtil;
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.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* {@link IEdexBandwidthManagerCreator} for an NCF bandwidth manager.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 20, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class NcfBandwidthManagerCreator implements IEdexBandwidthManagerCreator {
/**
* NCF {@link BandwidthManager} implementation.
*/
private static class NcfBandwidthManager extends BandwidthManager {
private static final String[] NCF_BANDWIDTH_MANAGER_FILES = new String[] {
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-edex-impl.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml"),
JarUtil.getResResourcePath("/spring/thrift-bandwidth.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-ncf.xml") };
/**
* Constructor.
*
* @param dbInit
* @param bandwidthDao
* @param retrievalManager
* @param bandwidthDaoUtil
*/
public NcfBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
}
@Override
protected String[] getSpringFilesForNewInstance() {
return NCF_BANDWIDTH_MANAGER_FILES;
}
}
/**
* {@inheritDoc}
*/
@Override
public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
return new NcfBandwidthManager(dbInit, bandwidthDao, retrievalManager,
bandwidthDaoUtil);
}
}

View file

@ -0,0 +1,89 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
import com.raytheon.uf.common.util.JarUtil;
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.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* {@link IEdexBandwidthManagerCreator} for a WFO bandwidth manager.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 20, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class WfoBandwidthManagerCreator implements IEdexBandwidthManagerCreator {
/**
* WFO {@link BandwidthManager} implementation.
*/
private static class WfoBandwidthManager extends BandwidthManager {
private static final String[] WFO_BANDWIDTH_MANAGER_FILES = new String[] {
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-edex-impl.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml"),
JarUtil.getResResourcePath("/spring/thrift-bandwidth.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-wfo.xml") };
/**
* Constructor.
*
* @param dbInit
* @param bandwidthDao
* @param retrievalManager
* @param bandwidthDaoUtil
*/
public WfoBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
}
@Override
protected String[] getSpringFilesForNewInstance() {
return WFO_BANDWIDTH_MANAGER_FILES;
}
}
/**
* {@inheritDoc}
*/
@Override
public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
return new WfoBandwidthManager(dbInit, bandwidthDao, retrievalManager,
bandwidthDaoUtil);
}
}

View file

@ -4,13 +4,12 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.hibernate.cfg.AnnotationConfiguration;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -19,11 +18,38 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.BandwidthInitializer;
/**
*
* {@link BandwidthInitializer} that uses Hibernate.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 20, 2013 1543 djohnson Add SW history, separate how to find subscriptions.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class HibernateBandwidthInitializer implements BandwidthInitializer {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(HibernateBandwidthInitializer.class);
private final IFindSubscriptionsForScheduling findSubscriptionsStrategy;
/**
* @param strategy
*/
public HibernateBandwidthInitializer(
IFindSubscriptionsForScheduling findSubscriptionsStrategy) {
this.findSubscriptionsStrategy = findSubscriptionsStrategy;
}
@Override
public boolean init(IBandwidthManager instance, IBandwidthDbInit dbInit) {
@ -31,8 +57,8 @@ public class HibernateBandwidthInitializer implements BandwidthInitializer {
// fulfilled. In the case were DD has been down for a while
// BEFORE removing the tables...
// Empty the bandwidth tables (other than BandwidthDataSetUpdate) on each
// start and reload..
// Empty the bandwidth tables (other than BandwidthDataSetUpdate) on
// each start and reload..
AnnotationConfiguration aConfig = new AnnotationConfiguration();
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval.class);
@ -46,14 +72,14 @@ public class HibernateBandwidthInitializer implements BandwidthInitializer {
return false;
}
List<Subscription> activeSubscriptions = Collections.emptyList();
Set<Subscription> activeSubscriptions = Collections.emptySet();
try {
// Load active subscriptions
activeSubscriptions = DataDeliveryHandlers.getSubscriptionHandler()
.getActive();
} catch (RegistryHandlerException e) {
statusHandler
.error("Failed to query for available active subscriptions");
activeSubscriptions = findSubscriptionsStrategy
.findSubscriptionsToSchedule();
} catch (Exception e) {
statusHandler.error(
"Failed to query for subscriptions to schedule", e);
return false;
}

View file

@ -0,0 +1,51 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
import java.util.Set;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
/**
* Finds subscriptions that should be scheduled for bandwidth management.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 18, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface IFindSubscriptionsForScheduling {
/**
* Finds subscriptions that should be scheduled.
*
* @return subscriptions
* @throws Exception
*/
Set<Subscription> findSubscriptionsToSchedule() throws Exception;
}

View file

@ -0,0 +1,85 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.bandwidth.util;
import java.util.List;
import java.util.Set;
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.DataDeliveryHandlers;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.IFindSubscriptionsForScheduling;
/**
* Returns active subscriptions in the registry.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 18, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class FindActiveSubscriptionsForRoute implements
IFindSubscriptionsForScheduling {
private final Network[] routes;
/**
* Find active subscriptions for a specific route.
*
* @param route
* the route
*/
public FindActiveSubscriptionsForRoute(Network route) {
this(new Network[] { route });
}
/**
* Find active subscriptions for specific routes.
*
* @param routes
* the routes
*/
public FindActiveSubscriptionsForRoute(Network... routes) {
this.routes = routes;
}
/**
* {@inheritDoc}
*/
@Override
public Set<Subscription> findSubscriptionsToSchedule()
throws RegistryHandlerException {
final List<Subscription> activeForRoutes = DataDeliveryHandlers
.getSubscriptionHandler().getActiveForRoutes(routes);
return Sets.newHashSet(activeForRoutes);
}
}

View file

@ -2,4 +2,6 @@
<!-- bandwidth is specified in kilobytes/second (kB/s) -->
<bandwidthMap>
<route planDays="2" network="OPSNET" defaultBandwidth="768" bucketSizeMinutes="3" />
<!-- TODO: What is the bandwidth allocated on the SBN for data delivery? -->
<route planDays="2" network="SBN" defaultBandwidth="768" bucketSizeMinutes="3" />
</bandwidthMap>

View file

@ -19,6 +19,11 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.util.Properties;
@ -39,6 +44,7 @@ import com.raytheon.uf.common.time.util.TimeUtilTest;
import com.raytheon.uf.common.util.PropertiesUtil;
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.util.BandwidthUtil;
/**
@ -55,6 +61,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Dec 11, 2012 1286 djohnson Use a synchronous event bus for tests.
* Dec 11, 2012 1403 djohnson No longer valid to run without bandwidth management.
* Feb 07, 2013 1543 djohnson Remove unnecessary test setup methods.
* Feb 20, 2013 1543 djohnson Delegate to sub-classes for which route to create subscriptions for.
*
* </pre>
*
@ -118,7 +125,8 @@ public abstract class AbstractBandwidthManagerIntTest {
bandwidthDao = IBandwidthDao.class
.cast(context.getBean("bandwidthDao"));
fullBucketSize = retrievalManager.getPlan(Network.OPSNET)
fullBucketSize = retrievalManager
.getPlan(getRouteToUseForSubscription())
.getBucket(TimeUtil.currentTimeMillis()).getBucketSize();
halfBucketSize = fullBucketSize / 2;
thirdBucketSizeInBytes = fullBucketSize / 3;
@ -186,6 +194,41 @@ public abstract class AbstractBandwidthManagerIntTest {
.get(subscriptionSeed++);
subscription.setDataSetSize(BandwidthUtil
.convertBytesToKilobytes(bytes));
subscription.setRoute(getRouteToUseForSubscription());
return subscription;
}
/**
* Retrieve the {@link Network} that subscriptions should be created for.
*
* @return the {@link Network}
*/
protected abstract Network getRouteToUseForSubscription();
/**
* Verify the bandwidth manager has a retrieval plan configured for the
* specified route.
*
* @param route
*/
protected void verifyRetrievalPlanExistsForRoute(Network route) {
final RetrievalPlan retrievalPlan = EdexBandwidthContextFactory
.getInstance().retrievalManager.getPlan(route);
assertThat(retrievalPlan, is(notNullValue(RetrievalPlan.class)));
}
/**
* Verify the bandwidth manager does not have a retrieval plan configured
* for the specified route.
*
* @param route
*/
protected void verifyRetrievalPlanDoesNotExistForRoute(Network route) {
final RetrievalPlan retrievalPlan = EdexBandwidthContextFactory
.getInstance().retrievalManager.getPlan(route);
assertThat(retrievalPlan, is(nullValue(RetrievalPlan.class)));
}
}

View file

@ -110,8 +110,10 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_XML })
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML })
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
@ -993,4 +995,12 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
return allocations;
}
/**
* {@inheritDoc}
*/
@Override
protected Network getRouteToUseForSubscription() {
return Network.OPSNET;
}
}

View file

@ -75,6 +75,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Oct 22, 2012 1286 djohnson Initial creation
* Nov 20, 2012 1286 djohnson Add tests for proposeSchedule methods.
* Dec 06, 2012 1397 djohnson Add tests for getting bandwidth graph data.
* Feb 20, 2013 1543 djohnson Use WFO bandwidth manager.
*
* </pre>
*
@ -85,8 +86,10 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_XML })
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML })
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
@ -633,4 +636,12 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
subscription.getName(), unscheduledSubscriptions.iterator()
.next());
}
/**
* {@inheritDoc}
*/
@Override
protected Network getRouteToUseForSubscription() {
return Network.OPSNET;
}
}

View file

@ -24,9 +24,6 @@ import java.io.File;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthContextFactory;
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.interfaces.BandwidthInitializer;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* The {@link BandwidthContextFactory} implementation for integration tests.
@ -38,6 +35,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2012 1286 djohnson Initial creation
* Feb 20, 2013 1543 djohnson Pass additional super-class constructor arguments.
*
* </pre>
*
@ -53,8 +51,10 @@ public class IntegrationTestBandwidthContextFactory extends
* @param bandwidthDao
* the bandwidthDao
*/
IntegrationTestBandwidthContextFactory(IBandwidthDao bandwidthDao) {
super(bandwidthDao);
IntegrationTestBandwidthContextFactory(IBandwidthDao bandwidthDao,
IEdexBandwidthManagerCreator bandwidthManagerCreator) {
super(bandwidthDao, new IntegrationTestBandwidthInitializer(),
bandwidthManagerCreator);
}
/**
@ -65,32 +65,14 @@ public class IntegrationTestBandwidthContextFactory extends
return new IntegrationTestDbInit();
}
/**
* {@inheritDoc}
*/
@Override
public BandwidthInitializer getBandwidthInitializer() {
return new IntegrationTestBandwidthInitializer();
}
/**
* {@inheritDoc}
*/
@Override
public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
return new IntegrationTestBandwidthManager(dbInit, bandwidthDao,
retrievalManager, bandwidthDaoUtil);
}
/**
* Get the integration test bandwidth map config file.
*
* @return the file
*/
public static File getIntegrationTestBandwidthMapConfigFile() {
return new IntegrationTestBandwidthContextFactory((IBandwidthDao) null)
return new IntegrationTestBandwidthContextFactory((IBandwidthDao) null,
(IEdexBandwidthManagerCreator) null)
.getBandwidthMapConfigFile();
}
}

View file

@ -19,15 +19,16 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
import com.raytheon.uf.common.util.JarUtil;
import com.raytheon.uf.common.util.SpringFiles;
import com.raytheon.uf.common.util.TestUtil;
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.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* {@link IBandwidthManager} implementation that runs in EDEX. Intentionally
* package-private to hide implementation details.
* An NCF {@link IBandwidthManager} that runs as an integration test, outside of
* the EDEX container.
*
* <pre>
*
@ -35,7 +36,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 30, 2012 1286 djohnson Initial creation
* Feb 18, 2013 1543 djohnson Initial creation
*
* </pre>
*
@ -43,12 +44,12 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
* @version 1.0
*/
class EdexBandwidthManager extends BandwidthManager {
public class IntegrationTestNcfBandwidthManager extends BandwidthManager {
private static final String[] EDEX_BANDWIDTH_MANAGER_FILES = new String[] {
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-edex-impl.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml"),
JarUtil.getResResourcePath("/spring/thrift-bandwidth.xml") };
static final String[] INTEGRATION_TEST_SPRING_FILES = new String[] {
"/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml",
TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_XML),
TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_NCF_XML) };
/**
* Constructor.
@ -58,14 +59,17 @@ class EdexBandwidthManager extends BandwidthManager {
* @param retrievalManager
* @param bandwidthDaoUtil
*/
public EdexBandwidthManager(IBandwidthDbInit dbInit,
public IntegrationTestNcfBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
}
/**
* {@inheritDoc}
*/
@Override
protected String[] getSpringFilesForNewInstance() {
return EDEX_BANDWIDTH_MANAGER_FILES;
return INTEGRATION_TEST_SPRING_FILES;
}
}

View file

@ -0,0 +1,57 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
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.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* Creates {@link IntegrationTestNcfBandwidthManager} instances.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 20, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class IntegrationTestNcfBandwidthManagerCreator implements
IEdexBandwidthManagerCreator {
/**
* {@inheritDoc}
*/
@Override
public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
return new IntegrationTestNcfBandwidthManager(dbInit, bandwidthDao,
retrievalManager, bandwidthDaoUtil);
}
}

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
import com.raytheon.uf.common.util.SpringFiles;
import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
@ -26,8 +27,8 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* An {@link IBandwidthManager} that runs as an integration test, outside of the
* EDEX container.
* A WFO {@link IBandwidthManager} that runs as an integration test, outside of
* the EDEX container.
*
* <pre>
*
@ -43,11 +44,12 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
* @version 1.0
*/
public class IntegrationTestBandwidthManager extends BandwidthManager {
public class IntegrationTestWfoBandwidthManager extends BandwidthManager {
static final String[] INTEGRATION_TEST_SPRING_FILES = new String[] {
"/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml",
TestUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml") };
TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_XML),
TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML) };
/**
* Constructor.
@ -57,7 +59,7 @@ public class IntegrationTestBandwidthManager extends BandwidthManager {
* @param retrievalManager
* @param bandwidthDaoUtil
*/
public IntegrationTestBandwidthManager(IBandwidthDbInit dbInit,
public IntegrationTestWfoBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);

View file

@ -0,0 +1,57 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
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.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* Creates {@link IntegrationTestWfoBandwidthManager} instances.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 20, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class IntegrationTestWfoBandwidthManagerCreator implements
IEdexBandwidthManagerCreator {
/**
* {@inheritDoc}
*/
@Override
public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
return new IntegrationTestWfoBandwidthManager(dbInit, bandwidthDao,
retrievalManager, bandwidthDaoUtil);
}
}

View file

@ -0,0 +1,118 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
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 org.junit.runner.RunWith;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
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.common.util.SpringFiles;
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
/**
* Test an NCF {@link BandwidthManager}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 19, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_NCF_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_NCF_XML })
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class NcfBandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
@Test
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));
}
}
@Test
public void testDoesNotScheduleOpsnetSubscriptionForRetrieval() {
Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
subscription.setRoute(Network.OPSNET);
bandwidthManager.schedule(subscription);
final List<SubscriptionRetrieval> subRetrievals = bandwidthDao
.getSubscriptionRetrievals(subscription.getProvider(),
subscription.getDataSetName());
assertThat(subRetrievals, is(empty()));
}
@Test
public void testReinitializeUsesCorrectSpringFiles() throws Exception {
final IBandwidthRequest request = new IBandwidthRequest();
request.setRequestType(RequestType.REINITIALIZE);
bandwidthManager.handleRequest(request);
verifyRetrievalPlanDoesNotExistForRoute(Network.OPSNET);
}
/**
* {@inheritDoc}
*/
@Override
protected Network getRouteToUseForSubscription() {
return Network.SBN;
}
}

View file

@ -0,0 +1,122 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
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 org.junit.runner.RunWith;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
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.common.util.SpringFiles;
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
/**
* Test a WFO {@link BandwidthManager}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 19, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML })
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class WfoBandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
@Test
public void testSchedulesSbnSubscriptionForRetrieval() {
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));
}
}
@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));
}
}
@Test
public void testReinitializeUsesCorrectSpringFiles() throws Exception {
final IBandwidthRequest request = new IBandwidthRequest();
request.setRequestType(RequestType.REINITIALIZE);
bandwidthManager.handleRequest(request);
verifyRetrievalPlanExistsForRoute(Network.OPSNET);
}
/**
* {@inheritDoc}
*/
@Override
protected Network getRouteToUseForSubscription() {
return Network.OPSNET;
}
}

View file

@ -1,12 +1,11 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="bandwidthContextFactory"
class="com.raytheon.uf.edex.datadelivery.bandwidth.IntegrationTestBandwidthContextFactory">
<constructor-arg ref="hibernateBandwidthDao" />
<constructor-arg ref="bandwidthManagerCreator" />
</bean>
<bean

View file

@ -0,0 +1,8 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="bandwidthManagerCreator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.IntegrationTestNcfBandwidthManagerCreator" />
</beans>

View file

@ -0,0 +1,8 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="bandwidthManagerCreator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.IntegrationTestWfoBandwidthManagerCreator" />
</beans>

View file

@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
@ -37,6 +38,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 17, 2012 0726 djohnson Initial creation
* Feb 20, 2013 1543 djohnson Implement route filtering.
*
* </pre>
*
@ -138,4 +140,30 @@ public class BaseMemorySubscriptionHandler<T extends Subscription> extends
return retVal;
}
/**
* {@inheritDoc}
*/
@Override
public List<T> getActiveForRoute(Network route)
throws RegistryHandlerException {
return getActiveForRoutes(new Network[] { route });
}
/**
* {@inheritDoc}
*/
@Override
public List<T> getActiveForRoutes(Network... routes)
throws RegistryHandlerException {
List<T> retVal = new ArrayList<T>();
for (T obj : getActive()) {
for (Network route : routes) {
if (route == obj.getRoute()) {
retVal.add(obj);
}
}
}
return retVal;
}
}

View file

@ -52,5 +52,13 @@ public class SpringFiles {
public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml";
public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_NCF_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-ncf-impl.xml";
public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-wfo-impl.xml";
public static final String BANDWIDTH_DATADELIVERY_XML = "/spring/bandwidth-datadelivery.xml";
}
public static final String BANDWIDTH_DATADELIVERY_NCF_XML = "/spring/bandwidth-datadelivery-ncf.xml";
public static final String BANDWIDTH_DATADELIVERY_WFO_XML = "/spring/bandwidth-datadelivery-wfo.xml";
}

View file

@ -0,0 +1,69 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
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.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionFixture;
import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
/**
* Test {@link HibernateBandwidthInitializer}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 18, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class HibernateBandwidthInitializerTest {
@Test
public void testSchedulesAllSubscriptionReturnedFromIFindSubscriptions()
throws Exception {
final Subscription subscription = SubscriptionFixture.INSTANCE.get();
IFindSubscriptionsForScheduling strategy = mock(IFindSubscriptionsForScheduling.class);
when(strategy.findSubscriptionsToSchedule()).thenReturn(
Sets.newHashSet(subscription));
IBandwidthManager bandwidthManager = mock(IBandwidthManager.class);
IBandwidthDbInit dbInit = mock(IBandwidthDbInit.class);
new HibernateBandwidthInitializer(strategy).init(bandwidthManager,
dbInit);
verify(bandwidthManager).schedule(subscription);
}
}

View file

@ -0,0 +1,101 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
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;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBuilder;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
/**
* Test {@link FindActiveSubscriptionsForRoute}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 19, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class FindActiveSubscriptionsForRouteTest {
@BeforeClass
public static void classSetUp() throws RegistryHandlerException {
RegistryObjectHandlersUtil.initMemory();
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
.getSubscriptionHandler();
// Two OPSNET subscriptions
final Subscription opsnetSub1 = new SubscriptionBuilder()
.withName("opsnetSub1").withRoute(Network.OPSNET).build();
final Subscription opsnetSub2 = new Subscription(opsnetSub1,
"opsnetSub2");
// Two SBN subscriptions
final Subscription sbnSub1 = new SubscriptionBuilder()
.withName("sbnSub1").withRoute(Network.SBN).build();
final Subscription sbnSub2 = new Subscription(sbnSub1, "sbnSub2");
// Store all subscriptions
for (Subscription sub : new Subscription[] { opsnetSub1, opsnetSub2,
sbnSub1, sbnSub2 }) {
subscriptionHandler.store(sub);
}
}
@Test
public void findsSubscriptionForSingleRoute()
throws RegistryHandlerException {
final Set<Subscription> subscriptions = new FindActiveSubscriptionsForRoute(
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(
Network.OPSNET, Network.SBN).findSubscriptionsToSchedule();
assertThat(subscriptions, hasSize(4));
}
}

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<bandwidthMap>
<route planDays="2" network="OPSNET" defaultBandwidth="768" bucketSizeMinutes="3"/>
<route planDays="2" network="SBN" defaultBandwidth="768" bucketSizeMinutes="3" />
</bandwidthMap>