Issue #1802 Fixes related to DD transaction refactor
Change-Id: Ia2a7a4ce990d424ed1e365bd7003fd2ab8630fd1 Former-commit-id: 393a469e2f65894a6dd5b58c1431c3d727951eda
This commit is contained in:
parent
391ce5687b
commit
2a14245dce
21 changed files with 338 additions and 371 deletions
|
@ -36,6 +36,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.raytheon.uf.common.comm.CommunicationException;
|
||||
import com.raytheon.uf.common.registry.IMultipleResultFormatter;
|
||||
import com.raytheon.uf.common.registry.IResultFormatter;
|
||||
import com.raytheon.uf.common.registry.OperationStatus;
|
||||
|
@ -71,6 +72,7 @@ import com.raytheon.uf.common.util.ReflectionException;
|
|||
* Sep 14, 2012 1169 djohnson Add use of create only mode.
|
||||
* Feb 26, 2013 1643 djohnson Remove registry manager debug toggle.
|
||||
* 3/18/2013 1802 bphillip Implemented transaction boundaries
|
||||
* 3/27/2013 1802 bphillip Changed visibility of processRequest and fixed catch block to catch the correct Exception type
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -264,8 +266,8 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
* the response object to populate on error
|
||||
* @return the response
|
||||
*/
|
||||
private <T extends RegistryResponse<U>, U> T processRequest(
|
||||
Callable<T> request, T response) {
|
||||
<T extends RegistryResponse<U>, U> T processRequest(Callable<T> request,
|
||||
T response) {
|
||||
T calledResponse = null;
|
||||
try {
|
||||
calledResponse = request.call();
|
||||
|
@ -274,7 +276,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
calledResponse = RegistryUtil.getFailedResponse(response,
|
||||
new RegistryException(
|
||||
RegistryUtil.UNABLE_TO_CONNECT_TO_REGISTRY, e));
|
||||
} catch (Exception e) {
|
||||
} catch (CommunicationException e) {
|
||||
calledResponse = RegistryUtil.getFailedResponse(response, e);
|
||||
} catch (Throwable e) {
|
||||
calledResponse = RegistryUtil.getFailedResponse(response, e);
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 07, 2013 1543 djohnson Initial creation
|
||||
* 3/18/2013 1802 bphillip Added additional database functions. Enforcing mandatory transaction propogation
|
||||
* 3/27/2013 1802 bphillip Changed transaction propagation of query methods
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -141,6 +142,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public ENTITY getById(Serializable id) {
|
||||
final Class<ENTITY> entityClass = getEntityClass();
|
||||
return entityClass.cast(template.get(entityClass, id));
|
||||
|
@ -150,6 +152,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public List<ENTITY> getAll() {
|
||||
return query("from " + getEntityClass().getSimpleName(),
|
||||
Collections.<String, Object> emptyMap());
|
||||
|
@ -162,11 +165,13 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
protected List<ENTITY> query(String queryString, Map<String, Object> params) {
|
||||
return query(queryString, params, 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
protected List<ENTITY> query(String queryString,
|
||||
Map<String, Object> params, int maxResults) {
|
||||
final int numberOfParams = params.size();
|
||||
|
@ -193,6 +198,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
protected ENTITY uniqueResult(String queryString, Map<String, Object> params) {
|
||||
final List<ENTITY> results = query(queryString, params);
|
||||
if (results.isEmpty()) {
|
||||
|
@ -215,6 +221,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* @throws DataAccessLayerException
|
||||
* If errors are encountered during the HQL query
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public <T extends Object> List<T> executeHQLQuery(String queryString)
|
||||
throws DataAccessLayerException {
|
||||
return executeHQLQuery(queryString, true, null);
|
||||
|
@ -231,6 +238,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* @throws DataAccessLayerException
|
||||
* If Hibernate errors occur during execution of the query
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public List<ENTITY> executeHQLQuery(StringBuilder queryString)
|
||||
throws DataAccessLayerException {
|
||||
return executeHQLQuery(queryString.toString(), true, null);
|
||||
|
@ -253,6 +261,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* @throws DataAccessLayerException
|
||||
* If Hibernate errors occur during the execution of the query
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public List<ENTITY> executeHQLQuery(String queryString,
|
||||
Map<String, Object> params) throws DataAccessLayerException {
|
||||
return executeHQLQuery(queryString, true, params);
|
||||
|
@ -272,6 +281,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* if errors are encountered during the HQL query
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public <T extends Object> List<T> executeHQLQuery(final String queryString,
|
||||
boolean eager, final Map<String, Object> params)
|
||||
throws DataAccessLayerException {
|
||||
|
@ -360,7 +370,6 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* @throws DataAccessLayerException
|
||||
* if errors are encountered during the HQL query
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public int executeHQLStatement(final String queryString, boolean eager,
|
||||
final Map<String, Object> params) throws DataAccessLayerException {
|
||||
try {
|
||||
|
@ -393,6 +402,7 @@ public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY
|
|||
* If errors occur in Hibernate while executing the query
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public <T extends Object> List<T> executeCriteriaQuery(
|
||||
final DetachedCriteria criteria) throws DataAccessLayerException {
|
||||
if (criteria == null) {
|
||||
|
|
|
@ -1,112 +1,122 @@
|
|||
<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">
|
||||
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">
|
||||
<list>
|
||||
<value>classpath:/com.raytheon.uf.edex.datadelivery.bandwidth.properties
|
||||
</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="propertyPlaceholderConfigurer"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="locations">
|
||||
<list>
|
||||
<value>classpath:/com.raytheon.uf.edex.datadelivery.bandwidth.properties
|
||||
</value>
|
||||
</list>
|
||||
</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="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="bandwidthManagerInitializer" factory-bean="bandwidthContextFactory"
|
||||
factory-method="getBandwidthInitializer" depends-on="registryManagerInstanceInitializer">
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthMapConfigFile" factory-bean="bandwidthContextFactory"
|
||||
factory-method="getBandwidthMapConfigFile" />
|
||||
<bean id="bandwidthMapConfigFile" factory-bean="bandwidthContextFactory"
|
||||
factory-method="getBandwidthMapConfigFile" />
|
||||
|
||||
<bean id="bandwidthManager" factory-bean="bandwidthContextFactory"
|
||||
factory-method="getBandwidthManager"
|
||||
depends-on="BandwidthEventBusConfig,bandwidthUtil,registerDataDeliveryHandlers"
|
||||
init-method="init">
|
||||
<constructor-arg ref="bandwidthDbInit" />
|
||||
<constructor-arg ref="bandwidthDao" />
|
||||
<constructor-arg ref="retrievalManager" />
|
||||
<constructor-arg ref="bandwidthDaoUtil" />
|
||||
<property name="aggregator" ref="aggregator" />
|
||||
<property name="initializer" ref="bandwidthManagerInitializer" />
|
||||
</bean>
|
||||
<bean id="bandwidthManager" factory-bean="bandwidthContextFactory"
|
||||
factory-method="getBandwidthManager"
|
||||
depends-on="BandwidthEventBusConfig,bandwidthUtil,registerDataDeliveryHandlers"
|
||||
init-method="init">
|
||||
<constructor-arg ref="bandwidthDbInit" />
|
||||
<constructor-arg ref="bandwidthDao" />
|
||||
<constructor-arg ref="retrievalManager" />
|
||||
<constructor-arg ref="bandwidthDaoUtil" />
|
||||
<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"
|
||||
value="${bandwidth.dataSetAvailabilityCalculator.delay}" />
|
||||
</bean>
|
||||
<bean id="dataSetAvailabilityCalculator"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.SimpleAvailablityCalculator">
|
||||
<property name="delay"
|
||||
value="${bandwidth.dataSetAvailabilityCalculator.delay}" />
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthUtil"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil"
|
||||
factory-method="getInstance">
|
||||
<property name="dataSetAvailabilityCalculator" ref="dataSetAvailabilityCalculator" />
|
||||
<property name="subscriptionLatencyCalculator">
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.SubscriptionValueLatencyCalculator" />
|
||||
</property>
|
||||
<property name="subscriptionRescheduleStrategy">
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.AlwaysRescheduleSubscriptions" />
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="bandwidthUtil"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil"
|
||||
factory-method="getInstance">
|
||||
<property name="dataSetAvailabilityCalculator" ref="dataSetAvailabilityCalculator" />
|
||||
<property name="subscriptionLatencyCalculator">
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.SubscriptionValueLatencyCalculator" />
|
||||
</property>
|
||||
<property name="subscriptionRescheduleStrategy">
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.AlwaysRescheduleSubscriptions" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthDaoUtil"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil">
|
||||
<constructor-arg ref="bandwidthDao" />
|
||||
<constructor-arg ref="retrievalManager" />
|
||||
</bean>
|
||||
<bean id="bandwidthDaoUtil"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil">
|
||||
<constructor-arg ref="bandwidthDao" />
|
||||
<constructor-arg ref="retrievalManager" />
|
||||
</bean>
|
||||
|
||||
<bean id="BandwidthMap"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap"
|
||||
factory-method="load">
|
||||
<constructor-arg ref="bandwidthMapConfigFile" />
|
||||
</bean>
|
||||
<bean id="BandwidthMap"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap"
|
||||
factory-method="load">
|
||||
<constructor-arg ref="bandwidthMapConfigFile" />
|
||||
</bean>
|
||||
|
||||
<bean id="aggregator"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.processing.SimpleSubscriptionAggregator">
|
||||
<constructor-arg ref="bandwidthDao" />
|
||||
</bean>
|
||||
<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}" />
|
||||
<property name="retrievalPoolSize" value="${bandwidth.retrievalPoolSize}" />
|
||||
<property name="subscriptionPoolSize" value="${bandwidth.subscriptionPoolSize}" />
|
||||
</bean>
|
||||
<bean id="BandwidthEventBusConfig"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthEventBusConfig">
|
||||
<property name="dataSetMetaDataPoolSize" value="${bandwidth.dataSetMetaDataPoolSize}" />
|
||||
<property name="retrievalPoolSize" value="${bandwidth.retrievalPoolSize}" />
|
||||
<property name="subscriptionPoolSize" value="${bandwidth.subscriptionPoolSize}" />
|
||||
</bean>
|
||||
|
||||
<!-- The shared monitor object between the RetrievalAgentManager and
|
||||
its Agents -->
|
||||
<bean id="retrievalAgentNotifier" class="java.lang.Object" />
|
||||
<!-- The shared monitor object between the RetrievalAgentManager and its
|
||||
Agents -->
|
||||
<bean id="retrievalAgentNotifier" class="java.lang.Object" />
|
||||
|
||||
<bean id="retrievalAgentManager"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalAgentManager"
|
||||
init-method="start">
|
||||
<constructor-arg ref="retrievalAgentNotifier" />
|
||||
<constructor-arg ref="retrievalAgents" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
<bean id="retrievalAgentManager"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalAgentManager"
|
||||
init-method="start">
|
||||
<constructor-arg ref="retrievalAgentNotifier" />
|
||||
<constructor-arg ref="retrievalAgents" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="retrievalManager"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager"
|
||||
depends-on="bandwidthDbInit">
|
||||
<constructor-arg ref="bandwidthDao" />
|
||||
<constructor-arg ref="retrievalAgentNotifier" />
|
||||
<property name="retrievalPlans" ref="retrievalPlans" />
|
||||
</bean>
|
||||
<bean id="retrievalManager"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager"
|
||||
depends-on="bandwidthDbInit">
|
||||
<constructor-arg ref="bandwidthDao" />
|
||||
<constructor-arg ref="retrievalAgentNotifier" />
|
||||
<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 class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="retrievalManager" />
|
||||
</list>
|
||||
</property>
|
||||
</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" />
|
||||
</beans>
|
||||
|
|
|
@ -6,8 +6,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
|
@ -36,6 +34,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
|
|||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* Feb 14, 2013 1596 djohnson Warn log when unable to find a SubscriptionRetrieval.
|
||||
* 3/18/2013 1802 bphillip Event bus registration is now a post-construct operation to ensure proxy is registered with bus
|
||||
* 3/13/2013 1802 bphillip Moved event bus registration from post-construct to spring static method call
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -65,11 +64,6 @@ public class RetrievalManager {
|
|||
this.notifier = notifier;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerWithEventBus() {
|
||||
EventBus.register(this);
|
||||
}
|
||||
|
||||
public Map<Network, RetrievalPlan> getRetrievalPlans() {
|
||||
return retrievalPlans;
|
||||
}
|
||||
|
|
|
@ -1,39 +1,52 @@
|
|||
<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
|
||||
<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">
|
||||
|
||||
<bean id="notificationHandler" class="com.raytheon.uf.edex.datadelivery.event.handler.NotificationHandler">
|
||||
<constructor-arg type="java.lang.String" value="jms-generic:topic:notify.msg?destinationResolver=#qpidDurableResolver"/>
|
||||
<property name="notificationDao" ref="notificationDao"/>
|
||||
</bean>
|
||||
|
||||
<!-- verify text product info for site, spawns in separate thread to not delay start up -->
|
||||
<bean id="notificationPurge" class="com.raytheon.uf.edex.datadelivery.event.notification.NotificationPurge" depends-on="ddEventRegister"/>
|
||||
|
||||
<bean id="noitfyCamelRegistered" factory-bean="contextManager"
|
||||
|
||||
<bean id="notificationHandler"
|
||||
class="com.raytheon.uf.edex.datadelivery.event.handler.NotificationHandler">
|
||||
<constructor-arg type="java.lang.String"
|
||||
value="jms-generic:topic:notify.msg?destinationResolver=#qpidDurableResolver" />
|
||||
<property name="notificationDao" ref="notificationDao" />
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="notificationHandler" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- verify text product info for site, spawns in separate thread to not
|
||||
delay start up -->
|
||||
<bean id="notificationPurge"
|
||||
class="com.raytheon.uf.edex.datadelivery.event.notification.NotificationPurge"
|
||||
depends-on="ddEventRegister" />
|
||||
|
||||
<bean id="noitfyCamelRegistered" factory-bean="contextManager"
|
||||
factory-method="register" depends-on="persistCamelRegistered">
|
||||
<constructor-arg ref="ddNotify-camel"/>
|
||||
</bean>
|
||||
|
||||
<camelContext id="ddNotify-camel"
|
||||
xmlns="http://camel.apache.org/schema/spring"
|
||||
errorHandlerRef="errorHandler"
|
||||
autoStartup="false">
|
||||
|
||||
<constructor-arg ref="ddNotify-camel" />
|
||||
</bean>
|
||||
|
||||
<camelContext id="ddNotify-camel" xmlns="http://camel.apache.org/schema/spring"
|
||||
errorHandlerRef="errorHandler" autoStartup="false">
|
||||
|
||||
<route id="notificationPurgeRoute">
|
||||
<from uri="timer://notifiyPurge?period=60s" />
|
||||
<from uri="timer://notifiyPurge?period=60s" />
|
||||
<doTry>
|
||||
<bean ref="notificationPurge" method="purge"/>
|
||||
<bean ref="notificationPurge" method="purge" />
|
||||
<doCatch>
|
||||
<exception>java.lang.Throwable</exception>
|
||||
<to uri="log:purge?level=ERROR&showBody=false&showCaughtException=true&showStackTrace=true"/>
|
||||
<to
|
||||
uri="log:purge?level=ERROR&showBody=false&showCaughtException=true&showStackTrace=true" />
|
||||
</doCatch>
|
||||
</doTry>
|
||||
</route>
|
||||
</camelContext>
|
||||
|
||||
|
||||
</beans>
|
|
@ -1,12 +1,9 @@
|
|||
package com.raytheon.uf.edex.datadelivery.event.handler;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.google.common.eventbus.AllowConcurrentEvents;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.common.datadelivery.event.INotifiableEvent;
|
||||
import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
|
||||
|
||||
/**
|
||||
|
@ -29,6 +26,7 @@ import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
|
|||
* Dec 07, 2012 1104 djohnson Changed to use INotifiableEvent for events with notifications.
|
||||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* 3/18/2013 1802 bphillip Modified to use transactional boundaries and spring injection of daos
|
||||
* 3/27/2013 1802 bphillip Moved event bus registration from PostConstruct method to Spring static method call
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,11 +45,6 @@ public class NotificationHandler extends AbstractHandler {
|
|||
super();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerWithEventBus() {
|
||||
EventBus.register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new handler object and registers this object with the
|
||||
* DataDeliveryEventBus
|
||||
|
|
|
@ -29,7 +29,8 @@ Require-Bundle: com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
|||
com.raytheon.uf.common.parameter;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.event;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.stats;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.decodertools;bundle-version="1.12.1174"
|
||||
com.raytheon.uf.edex.decodertools;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.edex.registry.ebxml;bundle-version="1.0.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.edex.datadelivery.retrieval;
|
||||
|
|
|
@ -1,12 +1,31 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
|
||||
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">
|
||||
|
||||
<bean id="retrievalDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
<bean id="retrievalTransactionInterceptor"
|
||||
class="org.springframework.transaction.interceptor.TransactionInterceptor">
|
||||
<property name="transactionManager" ref="metadataTxManager" />
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRED</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="retrievalDao" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="target" ref="retrievalDaoImpl" />
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<value>retrievalTransactionInterceptor</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="retrievalDaoImpl"
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -31,6 +31,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
|||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.time.domain.api.IDuration;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener;
|
||||
|
||||
/**
|
||||
* Provider Retrieval Handler
|
||||
|
@ -43,6 +44,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
|||
* Jan 07, 2011 dhladky Initial creation
|
||||
* Aug 09, 2012 1022 djohnson Use {@link ExecutorService} for retrieval.
|
||||
* Mar 04, 2013 1647 djohnson RetrievalTasks are now scheduled via constructor parameter.
|
||||
* Mar 27, 2013 1802 bphillip Scheduling of retrieval tasks now occurs after camel/spring have been initialized
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,7 +52,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
|||
* @version 1.0
|
||||
*/
|
||||
@Service
|
||||
public class RetrievalHandler {
|
||||
public class RetrievalHandler implements RegistryInitializedListener {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RetrievalHandler.class);
|
||||
|
@ -59,22 +61,24 @@ public class RetrievalHandler {
|
|||
|
||||
private final List<RetrievalTask> retrievalTasks;
|
||||
|
||||
private IRetrievalDao retrievalDao;
|
||||
|
||||
private IDuration retrievalTaskFrequency;
|
||||
|
||||
private IDuration subnotifyTaskFrequency;
|
||||
|
||||
private SubscriptionNotifyTask subNotifyTask;
|
||||
|
||||
public RetrievalHandler(ScheduledExecutorService executorService,
|
||||
IRetrievalDao retrievalDao, List<RetrievalTask> retrievalTasks,
|
||||
SubscriptionNotifyTask subNotifyTask,
|
||||
IDuration retrievalTaskFrequency, IDuration subnotifyTaskFrequency) {
|
||||
this.executorService = executorService;
|
||||
this.retrievalTasks = retrievalTasks;
|
||||
|
||||
// set all Running state retrievals to pending
|
||||
retrievalDao.resetRunningRetrievalsToPending();
|
||||
|
||||
for (RetrievalTask retrievalTask : retrievalTasks) {
|
||||
executorService.scheduleWithFixedDelay(retrievalTask, 1,
|
||||
retrievalTaskFrequency.getMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
executorService.scheduleWithFixedDelay(subNotifyTask, 1,
|
||||
subnotifyTaskFrequency.getMillis(), TimeUnit.MILLISECONDS);
|
||||
this.retrievalDao = retrievalDao;
|
||||
this.retrievalTaskFrequency = retrievalTaskFrequency;
|
||||
this.subnotifyTaskFrequency = subnotifyTaskFrequency;
|
||||
this.subNotifyTask = subNotifyTask;
|
||||
}
|
||||
|
||||
public void notify(List<String> subscriptions) {
|
||||
|
@ -84,4 +88,18 @@ public class RetrievalHandler {
|
|||
executorService.execute(retrievalTask);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeAfterRegistryInit() {
|
||||
// set all Running state retrievals to pending
|
||||
retrievalDao.resetRunningRetrievalsToPending();
|
||||
|
||||
for (RetrievalTask retrievalTask : retrievalTasks) {
|
||||
executorService.scheduleWithFixedDelay(retrievalTask, 30000,
|
||||
retrievalTaskFrequency.getMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
executorService.scheduleWithFixedDelay(subNotifyTask, 30000,
|
||||
subnotifyTaskFrequency.getMillis(), TimeUnit.MILLISECONDS);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
<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
|
||||
<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">
|
||||
<bean id="logHandler" class="com.raytheon.uf.edex.event.handler.LogHandler"/>
|
||||
|
||||
<bean id="eventPublishHandler" class="com.raytheon.uf.edex.event.handler.EventPublishHandler"/>
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.common.event.EventPublishRequest"/>
|
||||
<constructor-arg ref="eventPublishHandler"/>
|
||||
</bean>
|
||||
<bean id="logHandler" class="com.raytheon.uf.edex.event.handler.LogHandler" />
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="logHandler" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="eventPublishHandler" class="com.raytheon.uf.edex.event.handler.EventPublishHandler" />
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.common.event.EventPublishRequest" />
|
||||
<constructor-arg ref="eventPublishHandler" />
|
||||
</bean>
|
||||
</beans>
|
|
@ -1,14 +1,11 @@
|
|||
package com.raytheon.uf.edex.event.handler;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.google.common.eventbus.AllowConcurrentEvents;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.common.event.Event;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -24,6 +21,7 @@ import com.raytheon.uf.common.event.EventBus;
|
|||
* Nov 5, 2012 #1305 bgonzale Added log level Event logging.
|
||||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* 3/13/2013 bphillip Modified to make event bus registration a post construct operation
|
||||
* 3/27/2013 1802 bphillip Moved event bus registration from a PostConstruct method to Spring static method
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -41,11 +39,6 @@ public class LogHandler {
|
|||
logger = LogFactory.getLog("Event");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerWithEventBus() {
|
||||
EventBus.register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens for any DataDeliveryEvent object published on the event bus
|
||||
*
|
||||
|
|
|
@ -20,6 +20,17 @@
|
|||
<property name="statsDao" ref="statsDao" />
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="statsHandler" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
<bean id="statsDao" class="com.raytheon.uf.edex.stats.dao.StatsDao">
|
||||
|
|
|
@ -1,14 +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
|
||||
<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">
|
||||
|
||||
<bean id="statsGraphDataHandler" class="com.raytheon.uf.edex.stats.handler.GraphDataHandler"/>
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.common.stats.GraphDataRequest"/>
|
||||
<constructor-arg ref="statsGraphDataHandler"/>
|
||||
<property name="aggregateRecordDao" ref="aggregateRecordDao"/>
|
||||
</bean>
|
||||
<bean id="statsGraphDataHandler" class="com.raytheon.uf.edex.stats.handler.GraphDataHandler" >
|
||||
<property name="aggregateRecordDao" ref="graphDataHandlerAggregateRecordDao" />
|
||||
</bean>
|
||||
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.common.stats.GraphDataRequest" />
|
||||
<constructor-arg ref="statsGraphDataHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="graphDataHandlerAggregateRecordDao" class="com.raytheon.uf.edex.stats.dao.AggregateRecordDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
</beans>
|
||||
|
|
|
@ -74,6 +74,7 @@ import com.raytheon.uf.edex.stats.util.ConfigLoader;
|
|||
* Jan 07, 2013 1451 djohnson Use newGmtCalendar().
|
||||
* Jan 15, 2013 1487 djohnson Use xml for the grouping information on an {@link AggregateRecord}.
|
||||
* 3/13/2013 bphillip Updated to use spring injection of dao
|
||||
* 3/27/2013 1802 bphillip Made jaxb manager static and changed visibility of a method
|
||||
* </pre>
|
||||
*
|
||||
* @author jsanchez
|
||||
|
@ -89,7 +90,7 @@ public class AggregateManager {
|
|||
|
||||
private static final Object[] EMPTY_OBJ_ARR = new Object[0];
|
||||
|
||||
private JAXBManager jaxbManager;
|
||||
private static JAXBManager jaxbManager;
|
||||
|
||||
/** In minutes */
|
||||
private int bucketInterval;
|
||||
|
@ -101,6 +102,10 @@ public class AggregateManager {
|
|||
@SuppressWarnings("unused")
|
||||
private static final int defaultScanInterval = 15;
|
||||
|
||||
public AggregateManager() {
|
||||
|
||||
}
|
||||
|
||||
public AggregateManager(String bucketInterval) {
|
||||
validateIntervals(bucketInterval);
|
||||
}
|
||||
|
@ -310,7 +315,7 @@ public class AggregateManager {
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
private String determineGroupRepresentationForEvent(
|
||||
static String determineGroupRepresentationForEvent(
|
||||
StatisticsEvent statEvent, Event event)
|
||||
throws IllegalAccessException, InvocationTargetException,
|
||||
JAXBException {
|
||||
|
|
|
@ -24,15 +24,12 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.google.common.eventbus.AllowConcurrentEvents;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.common.event.Event;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.stats.StatsRecord;
|
||||
|
@ -55,7 +52,8 @@ import com.raytheon.uf.edex.stats.util.ConfigLoader;
|
|||
* Aug 21, 2012 jsanchez Removed instance variable of event bus.
|
||||
* Nov 07, 2012 1317 mpduff Updated config files.
|
||||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* 3/18/2013 1082 bphillip Modified to make transactional and use spring injection
|
||||
* 3/18/2013 1802 bphillip Modified to make transactional and use spring injection
|
||||
* 3/27/2013 1802 bphillip Moved event bus registration from PostConstruct method to Spring static method call
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -94,11 +92,6 @@ public class StatsHandler {
|
|||
loadEventValidTypes();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerWithEventBus() {
|
||||
EventBus.register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the stats configuration to determine the events to track.
|
||||
*
|
||||
|
|
|
@ -26,9 +26,9 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
@ -90,144 +90,58 @@ public class FactoryRegistryHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testGetObjectsReturnsFailedStatusIfWebServiceExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
WEB_SERVICE_EXCEPTION).getObjects(null);
|
||||
|
||||
Callable<RegistryResponse<Object>> callable = new Callable<RegistryResponse<Object>>() {
|
||||
@Override
|
||||
public RegistryResponse<Object> call() throws Exception {
|
||||
throw WEB_SERVICE_EXCEPTION;
|
||||
}
|
||||
};
|
||||
RegistryResponse<Object> response = new FactoryRegistryHandler()
|
||||
.processRequest(callable, new RegistryResponse<Object>());
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectsReturnsUnableToConnectMessageIfWebServiceExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
WEB_SERVICE_EXCEPTION).getObjects(null);
|
||||
|
||||
Callable<RegistryResponse<Object>> callable = new Callable<RegistryResponse<Object>>() {
|
||||
@Override
|
||||
public RegistryResponse<Object> call() throws Exception {
|
||||
throw WEB_SERVICE_EXCEPTION;
|
||||
}
|
||||
};
|
||||
RegistryResponse<Object> response = new FactoryRegistryHandler()
|
||||
.processRequest(callable, new RegistryResponse<Object>());
|
||||
assertEquals(RegistryUtil.UNABLE_TO_CONNECT_TO_REGISTRY, response
|
||||
.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithQueryReturnsUnableToConnectMessageIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
WEB_SERVICE_EXCEPTION).removeObjects(null);
|
||||
|
||||
assertEquals(RegistryUtil.UNABLE_TO_CONNECT_TO_REGISTRY, response
|
||||
.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithObjectsReturnsUnableToConnectMessageIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
WEB_SERVICE_EXCEPTION).removeObjects("someUsername",
|
||||
Collections.emptyList());
|
||||
|
||||
assertEquals(RegistryUtil.UNABLE_TO_CONNECT_TO_REGISTRY, response
|
||||
.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreObjectReturnsUnableToConnectMessageIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
WEB_SERVICE_EXCEPTION).storeObject(null);
|
||||
|
||||
assertEquals(RegistryUtil.UNABLE_TO_CONNECT_TO_REGISTRY, response
|
||||
.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithQueryReturnsFailedStatusIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
WEB_SERVICE_EXCEPTION).removeObjects(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithObjectsReturnsFailedStatusIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
WEB_SERVICE_EXCEPTION).removeObjects("someUsername",
|
||||
Collections.emptyList());
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreObjectReturnsFailedStatusIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
WEB_SERVICE_EXCEPTION).storeObject(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectsReturnsFailedStatusIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).getObjects(null);
|
||||
|
||||
Callable<RegistryResponse<Object>> callable = new Callable<RegistryResponse<Object>>() {
|
||||
@Override
|
||||
public RegistryResponse<Object> call() throws Exception {
|
||||
throw COMMUNICATION_EXCEPTION;
|
||||
}
|
||||
};
|
||||
RegistryResponse<Object> response = new FactoryRegistryHandler()
|
||||
.processRequest(callable, new RegistryResponse<Object>());
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectsReturnsFailedToConnectToTheDatabaseIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).getObjects(null);
|
||||
|
||||
Callable<RegistryResponse<Object>> callable = new Callable<RegistryResponse<Object>>() {
|
||||
@Override
|
||||
public RegistryResponse<Object> call() throws Exception {
|
||||
throw COMMUNICATION_EXCEPTION;
|
||||
}
|
||||
};
|
||||
RegistryResponse<Object> response = new FactoryRegistryHandler()
|
||||
.processRequest(callable, new RegistryResponse<Object>());
|
||||
assertEquals(RegistryUtil.FAILED_TO_CONNECT_TO_DATABASE, response
|
||||
.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithQueryReturnsUnableToConnectMessageIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).removeObjects(null);
|
||||
|
||||
assertEquals(RegistryUtil.FAILED_TO_CONNECT_TO_DATABASE, response
|
||||
.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithObjectsReturnsUnableToConnectMessageIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).removeObjects("someUsername",
|
||||
Collections.emptyList());
|
||||
|
||||
assertEquals(RegistryUtil.FAILED_TO_CONNECT_TO_DATABASE, response
|
||||
.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreObjectReturnsUnableToConnectMessageIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).storeObject(null);
|
||||
|
||||
assertEquals(RegistryUtil.FAILED_TO_CONNECT_TO_DATABASE, response
|
||||
.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithQueryReturnsFailedStatusIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).removeObjects(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithObjectsReturnsFailedStatusIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).removeObjects("someUsername",
|
||||
Collections.emptyList());
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreObjectReturnsFailedStatusIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).storeObject(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonResultFormatterWillReturnDecodedRegistryObjects()
|
||||
throws SerializationException {
|
||||
|
@ -256,14 +170,17 @@ public class FactoryRegistryHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testResultFormatterThatReturnsSingleResultWillReturnsAllSingleResults() {
|
||||
final String[] results = new String[]{"one", "two", "three"};
|
||||
final List<RegistryObjectType> registryObjectTypes = java.util.Arrays.asList(new RegistryObjectType(), new RegistryObjectType(), new RegistryObjectType());
|
||||
final String[] results = new String[] { "one", "two", "three" };
|
||||
final List<RegistryObjectType> registryObjectTypes = java.util.Arrays
|
||||
.asList(new RegistryObjectType(), new RegistryObjectType(),
|
||||
new RegistryObjectType());
|
||||
|
||||
StringResultsQuery query = new StringResultsQuery(results);
|
||||
|
||||
List<String> filteredResults = FactoryRegistryHandler.filterResults(
|
||||
query, registryObjectTypes);
|
||||
assertEquals("Incorrect number of results were returned!", results.length, filteredResults.size());
|
||||
assertEquals("Incorrect number of results were returned!",
|
||||
results.length, filteredResults.size());
|
||||
|
||||
for (String result : results) {
|
||||
assertTrue("The filtered results should have contained result ["
|
||||
|
@ -376,26 +293,4 @@ public class FactoryRegistryHandlerTest {
|
|||
FactoryRegistryHandler.statusHandler = oldHandler;
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends Exception> FactoryRegistryHandler getExceptionThrowingHandler(
|
||||
final T t) {
|
||||
FactoryRegistryHandler handler = new FactoryRegistryHandler();
|
||||
handler.setTxManager(new RegistryTxManager() {
|
||||
@Override
|
||||
public TxManager getTxManager() {
|
||||
return new TxManager() {
|
||||
@Override
|
||||
public void startTransaction() throws Exception {
|
||||
throw t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeTransaction() {
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.registry.ebxml;
|
||||
|
||||
import com.raytheon.uf.common.registry.OperationStatus;
|
||||
import com.raytheon.uf.common.registry.RegistryQuery;
|
||||
import com.raytheon.uf.common.registry.RegistryQueryResponse;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.QueryManager;
|
||||
|
@ -33,6 +29,10 @@ import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryRequest;
|
|||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType;
|
||||
|
||||
import com.raytheon.uf.common.registry.OperationStatus;
|
||||
import com.raytheon.uf.common.registry.RegistryQuery;
|
||||
import com.raytheon.uf.common.registry.RegistryQueryResponse;
|
||||
|
||||
/**
|
||||
* Extends {@link FactoryRegistryHandler} to allow it to be testable.
|
||||
*
|
||||
|
@ -50,12 +50,11 @@ import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class TestableFactoryRegistryHandler extends FactoryRegistryHandler
|
||||
implements LifecycleManagerFactory, QueryManagerFactory,
|
||||
RegistryTxManager, QueryManager, LifecycleManager {
|
||||
implements LifecycleManagerFactory, QueryManagerFactory, QueryManager,
|
||||
LifecycleManager {
|
||||
public TestableFactoryRegistryHandler() {
|
||||
setLcmFactory(this);
|
||||
setQueryFactory(this);
|
||||
setTxManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,22 +68,6 @@ public class TestableFactoryRegistryHandler extends FactoryRegistryHandler
|
|||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public TxManager getTxManager() {
|
||||
return new TxManager() {
|
||||
@Override
|
||||
public void startTransaction() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeTransaction() {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
@ -79,6 +80,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
|
|||
public class SubscriptionRetrievalAgentTest {
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value = "retrievalDao")
|
||||
private IRetrievalDao retrievalDao;
|
||||
|
||||
@Before
|
||||
|
|
|
@ -78,6 +78,7 @@ public class RetrievalHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testAllRunningRetrievalsAreResetToPendingOnConstruction() {
|
||||
handler.executeAfterRegistryInit();
|
||||
verify(mockDao).resetRunningRetrievalsToPending();
|
||||
}
|
||||
|
||||
|
@ -90,13 +91,15 @@ public class RetrievalHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testRetrievalTaskIsScheduledPerConstructorParameter() {
|
||||
verify(executorService).scheduleWithFixedDelay(retrievalTask, 1,
|
||||
handler.executeAfterRegistryInit();
|
||||
verify(executorService).scheduleWithFixedDelay(retrievalTask, 30000,
|
||||
RETRIEVAL_TASK_FREQUENCY.getMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionNotifyTaskIsScheduledPerConstructorParameter() {
|
||||
verify(executorService).scheduleWithFixedDelay(subNotifyTask, 1,
|
||||
handler.executeAfterRegistryInit();
|
||||
verify(executorService).scheduleWithFixedDelay(subNotifyTask, 30000,
|
||||
SUBNOTIFY_TASK_FREQUENCY.getMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,10 +38,12 @@ import org.junit.Ignore;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
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 org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent;
|
||||
|
@ -144,6 +146,7 @@ public class RetrievalTaskTest {
|
|||
private RetrievalRequestRecord sbnRetrieval;
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value = "retrievalDao")
|
||||
private IRetrievalDao dao;
|
||||
|
||||
private final PlaceInCollectionProcessor retrievedDataProcessor = new PlaceInCollectionProcessor();
|
||||
|
@ -266,7 +269,9 @@ public class RetrievalTaskTest {
|
|||
/**
|
||||
* Stage the retrievals in the database.
|
||||
*/
|
||||
@Transactional
|
||||
private void stageRetrievals() {
|
||||
|
||||
dao.create(opsnetRetrieval);
|
||||
dao.create(sbnRetrieval);
|
||||
}
|
||||
|
|
|
@ -107,8 +107,12 @@ public class AggregateManagerTest {
|
|||
|
||||
final String expectedGroupRepresentation = jaxbManager
|
||||
.marshalToXml(column);
|
||||
final String actualGroupRepresentation = AggregateManager.determineGroupRepresentationForEvent(
|
||||
statisticsConfig.getEvents().iterator().next(), mockEvent);
|
||||
JAXBManager aggregateManagerJaxbManager = new JAXBManager(
|
||||
StatsGroupingColumn.class);
|
||||
new AggregateManager("60").setJaxbManager(aggregateManagerJaxbManager);
|
||||
final String actualGroupRepresentation = AggregateManager
|
||||
.determineGroupRepresentationForEvent(statisticsConfig
|
||||
.getEvents().iterator().next(), mockEvent);
|
||||
assertThat(actualGroupRepresentation,
|
||||
is(equalTo(expectedGroupRepresentation)));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue