Merge "Issue #1543 Add testing of current OpenDAP type retrievals. - Add test for current behavior of SBN-like retrievals. - Change session management to use a factory implementation. - Add service locator strategy to find jaxbables. - Tests cleanup. - Add mock versions of OpenDAP service classes to test more OpenDAP retrieval functionality." into development

Former-commit-id: 62367c9726 [formerly bc8fb2f4ea] [formerly 2457359c0f] [formerly 6a4a11536e [formerly 2457359c0f [formerly 4d055580ddea29eb35983dbe4e9e01a611f23ba1]]]
Former-commit-id: 6a4a11536e
Former-commit-id: 6cf7d657faf40e30bb698517e95835a8e4204694 [formerly da9072b0f1]
Former-commit-id: ecbd1896dc
This commit is contained in:
Dustin Johnson 2013-02-12 07:58:39 -06:00 committed by Gerrit Code Review
commit c48d48089f
104 changed files with 2462 additions and 1418 deletions

View file

@ -46,12 +46,6 @@ public class DConnect {
private static final int MAX_NUMBER_OF_URL_ATTEMPTS_TO_MAKE = 4;
private static final int CONNECTION_TIMEOUT = Integer.getInteger(
DODS_CONNECTION_TIMEOUT_MILLISECONDS, 0);
private static final int SOCKET_TIMEOUT = Integer.getInteger(
DODS_SOCKET_TIMEOUT_MILLISECONDS, 0);
private static final String HTTP_CONNECT_STRATEGY = System
.getProperty("dods.http.connect.strategy");
@ -177,8 +171,10 @@ public class DConnect {
this.httpStrategy = httpStrategy;
// Prevent connections from having unlimited time (unless using default
// values)
httpStrategy.setConnectionTimeout(CONNECTION_TIMEOUT);
httpStrategy.setSocketTimeout(SOCKET_TIMEOUT);
httpStrategy.setConnectionTimeout(Integer.getInteger(
DODS_CONNECTION_TIMEOUT_MILLISECONDS, 0));
httpStrategy.setSocketTimeout(Integer.getInteger(
DODS_SOCKET_TIMEOUT_MILLISECONDS, 0));
if (proxyHost != null && proxyPort != null) {
httpStrategy.setProxy(proxyHost, Integer.parseInt(proxyPort));

View file

@ -1,15 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd">
http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<tx:annotation-driven transaction-manager="metadataTxManager" proxy-target-class="true" />
<!-- specify the connection to the broker (qpid) -->
<!-- MaxPrefetch set at 0, due to DataPool routers getting messages backed up behind long running tasks -->

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.common.datadelivery.retrieval.xml;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@ -48,7 +49,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 07, 2011 191 dhladky Initial creation
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Feb 07, 2013 1543 djohnson Never have null attributes.
*
* </pre>
*
@ -78,7 +80,7 @@ public class Retrieval implements ISerializableObject, Serializable {
@XmlElement
@DynamicSerializeElement
private String owner;
@XmlElement
@DynamicSerializeElement
private ProviderType providerType;
@ -93,7 +95,7 @@ public class Retrieval implements ISerializableObject, Serializable {
@XmlElements({ @XmlElement(name = "attribute", type = RetrievalAttribute.class) })
@DynamicSerializeElement
private ArrayList<RetrievalAttribute> attribute;
private List<RetrievalAttribute> attributes = new ArrayList<RetrievalAttribute>();
/**
* Add another Attribute entry
@ -101,16 +103,11 @@ public class Retrieval implements ISerializableObject, Serializable {
* @param pdo
*/
public void addAttribute(RetrievalAttribute att) {
if (attribute != null) {
attribute.add(att);
} else {
attribute = new ArrayList<RetrievalAttribute>();
attribute.add(att);
}
attributes.add(att);
}
public ArrayList<RetrievalAttribute> getAttribute() {
return attribute;
public List<RetrievalAttribute> getAttributes() {
return attributes;
}
public Connection getConnection() {
@ -128,7 +125,7 @@ public class Retrieval implements ISerializableObject, Serializable {
* @return
*/
public RetrievalAttribute getProviderAttributeByName(String name) {
for (RetrievalAttribute att : getAttribute()) {
for (RetrievalAttribute att : getAttributes()) {
if (att.getParameter().getName().equals(att)) {
return att;
}
@ -151,13 +148,11 @@ public class Retrieval implements ISerializableObject, Serializable {
* @param pdo
*/
public void removeAttribute(RetrievalAttribute att) {
if (attribute != null) {
attribute.remove(att);
}
attributes.remove(att);
}
public void setAttribute(ArrayList<RetrievalAttribute> attribute) {
this.attribute = attribute;
public void setAttributes(List<RetrievalAttribute> attribute) {
this.attributes = attribute;
}
public void setConnection(Connection connection) {

View file

@ -33,7 +33,8 @@ Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.11.5",
com.raytheon.uf.common.serialization,
org.springframework;bundle-version="2.5.6",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.edex.database
com.raytheon.uf.edex.database,
com.raytheon.uf.common.util;bundle-version="1.12.1174"
Import-Package: com.raytheon.uf.common.datastorage,
com.raytheon.uf.common.time,
com.raytheon.uf.edex.database.plugin

View file

@ -0,0 +1,50 @@
/**
* 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.common.serialization;
import java.util.List;
/**
* Defines a strategy for finding JAXBable classes.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 06, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface IJaxbableClassesLocator {
/**
* Get the classes that can be JAXBed.
*
* @return the list of JAXBable classes
*/
List<Class<ISerializableObject>> getJaxbables();
}

View file

@ -55,17 +55,18 @@ import com.raytheon.uf.common.serialization.jaxb.JaxbDummyObject;
* ------------ ---------- ----------- --------------------------
* Aug 11, 2008 njensen Initial creation
* Aug 31, 2009 2924 rjpeter Added Embeddable.
* Feb 07, 2013 1543 djohnson Implement IJaxbableClassesLocator.
* </pre>
*
* @author njensen
* @version 1.0
*/
public class SerializableManager {
public class SerializableManager implements IJaxbableClassesLocator {
private static SerializableManager instance;
private Map<String, List<Class<ISerializableObject>>> hibernatables = new HashMap<String, List<Class<ISerializableObject>>>();
private final Map<String, List<Class<ISerializableObject>>> hibernatables = new HashMap<String, List<Class<ISerializableObject>>>();
private ArrayList<Class<ISerializableObject>> jaxbables = new ArrayList<Class<ISerializableObject>>();
@ -223,6 +224,7 @@ public class SerializableManager {
*
* @return
*/
@Override
public List<Class<ISerializableObject>> getJaxbables() {
return jaxbables;
}

View file

@ -30,6 +30,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
import com.raytheon.uf.common.util.ServiceLoaderUtil;
/**
* Provides utilities for serialization support
@ -43,6 +44,7 @@ import com.raytheon.uf.common.serialization.DynamicSerializationManager.Serializ
* Sep 07, 2012 1102 djohnson Overload jaxbUnmarshall and transformFromThrift methods
* to accept class parameter, deprecate old versions. Improve performance
* of getJaxbManager().
* Feb 07, 2013 1543 djohnson Use ServiceLoader to find how to load jaxbable classes, defaulting to SerializableManager.
*
* </pre>
*
@ -52,8 +54,11 @@ import com.raytheon.uf.common.serialization.DynamicSerializationManager.Serializ
public final class SerializationUtil {
// @VisibleForTesting
static volatile JAXBManager jaxbManager;
private static final IJaxbableClassesLocator jaxbableClassesLocator = ServiceLoaderUtil
.load(IJaxbableClassesLocator.class,
SerializableManager.getInstance());
private static volatile JAXBManager jaxbManager;
private SerializationUtil() {
@ -74,8 +79,8 @@ public final class SerializationUtil {
synchronized (SerializationUtil.class) {
result = jaxbManager;
if (result == null) {
List<Class<ISerializableObject>> jaxbClasses = SerializableManager
.getInstance().getJaxbables();
List<Class<ISerializableObject>> jaxbClasses = jaxbableClassesLocator
.getJaxbables();
jaxbManager = result = new JAXBManager(
jaxbClasses.toArray(new Class[jaxbClasses.size()]));

View file

@ -0,0 +1,53 @@
/**
* 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.common.util.session;
/**
* A factory to create a session context instance.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 07, 2013 1543 djohnson Initial creation.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface SessionContextFactory<T extends SessionContext> {
/**
* Returns the session context instance that should be used.
*
* @return the session context
*/
T getSessionContext();
/**
* Returns the session context class instance for the implementation.
*
* @return the session context class
*/
Class<T> getSessionContextClass();
}

View file

@ -25,7 +25,6 @@ import java.util.Map;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.ReflectionUtil;
/**
* Provides the functionality to manage a 'session'. Each thread has its own
@ -40,6 +39,7 @@ import com.raytheon.uf.common.util.ReflectionUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 26, 2012 1195 djohnson Initial creation
* Feb 07, 2013 1543 djohnson Use SessionContextFactory to create the session context.
*
* </pre>
*
@ -57,6 +57,7 @@ public final class SessionManager {
*/
private static class SessionContextTracker {
private int openRequests;
private final SessionContext sessionContext;
/**
@ -91,25 +92,26 @@ public final class SessionManager {
* the context class for the session type
*/
public static <T extends SessionContext> T openSession(
Class<T> contextClass) {
SessionContextFactory<T> sessionContextFactory) {
final Map<String, SessionContextTracker> map = context.get();
final Class<T> contextClass = sessionContextFactory
.getSessionContextClass();
final String key = contextClass.getName();
SessionContextTracker ctxTracker = map.get(key);
if (ctxTracker == null) {
SessionContext ctx = ReflectionUtil.newInstanceOfAssignableType(
SessionContext.class, contextClass);
SessionContext ctx = sessionContextFactory.getSessionContext();
ctx.open();
ctxTracker = new SessionContextTracker(ctx);
map.put(key, ctxTracker);
}
ctxTracker.openRequests++;
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
statusHandler.debug(String.format(
" context [%s] openRequests [%s]", contextClass.getName(),
" context [%s] openRequests [%s]", key,
ctxTracker.openRequests));
}
@ -126,16 +128,19 @@ public final class SessionManager {
* if the session is not open
*/
public static <T extends SessionContext> void closeSession(
Class<T> contextClass) {
SessionContextFactory<T> sessionContextFactory) {
final Map<String, SessionContextTracker> map = context.get();
final Class<T> contextClass = sessionContextFactory
.getSessionContextClass();
final String key = contextClass.getName();
SessionContextTracker ctxTracker = map.get(key);
if (ctxTracker == null) {
throw new IllegalStateException(
"Unable to close a session that is not opened! "
statusHandler
.warn("Unable to close a session that is not opened! "
+ "Please be sure to pair the closeSession() request with a prior openSession() request.");
return;
}
ctxTracker.openRequests--;
@ -168,8 +173,10 @@ public final class SessionManager {
* if the session is not open
*/
public static <T extends SessionContext> T getSessionContext(
Class<T> contextClass) {
SessionContextFactory<T> sessionContextFactory) {
final Map<String, SessionContextTracker> map = context.get();
final Class<T> contextClass = sessionContextFactory
.getSessionContextClass();
final String key = contextClass.getName();
SessionContextTracker ctxTracker = map.get(key);

View file

@ -127,6 +127,20 @@ public class EDEXUtil implements ApplicationContextAware {
}
/**
* Retrieve an object from the ESB context This object could be a Spring
* Bean, a context or a property container
*
* @param clazz
* the return class type
* @param name
* the name of the component
* @return The casted instance
*/
public static <T> T getESBComponent(Class<T> clazz, String name) {
return clazz.cast(getESBComponent(name));
}
public static boolean isRunning() {
return "Operational".equals(System.getProperty("System.status"));
}
@ -263,4 +277,5 @@ public class EDEXUtil implements ApplicationContextAware {
public static String getAlertendpoint() {
return alertEndpoint;
}
}

View file

@ -20,7 +20,8 @@ Require-Bundle: com.raytheon.uf.common.dataquery;bundle-version="1.0.0",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
org.geotools;bundle-version="2.6.4",
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.common.spatial
com.raytheon.uf.common.spatial,
com.raytheon.uf.common.util
Export-Package: com.raytheon.uf.edex.database,
com.raytheon.uf.edex.database.cluster,
com.raytheon.uf.edex.database.cluster.handler,

View file

@ -0,0 +1,142 @@
/**
* 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.database.dao;
import java.io.Serializable;
import java.util.Collection;
import org.hibernate.Criteria;
import org.hibernate.LockOptions;
import org.hibernate.Query;
import org.hibernate.dialect.Dialect;
import org.hibernate.jdbc.Work;
import com.raytheon.uf.common.util.session.SessionContext;
/**
* Defines the public API of a DAO session context.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 07, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface IDaoSessionContext extends SessionContext {
/**
* Create a query for execution given the specified string.
*
* @param queryString
* the query string
* @return the query
*/
Query createQuery(final String queryString);
/**
* Create the query criteria for the specified class.
*
*
*
* @param clazz
* the class of the entity type
* @return the criteria
*/
<T> Criteria createCriteria(Class<T> clazz);
/**
* Get an object exclusively.
*
* @param <T>
* the type of the object
* @param clazz
* the object class
* @param pk
* the primary key
* @param lockOptions
* the lock options
* @return the object, or null if it can't be locked
*/
<T> T get(Class<T> clazz, Serializable pk, LockOptions lockOptions);
/**
* Create the entity in the database.
*
* @param obj
*/
void create(Object obj);
/**
* Update the entity in the database.
*
* @param rval
*/
<T> void update(T rval);
/**
* Create, or update, an entity in the database.
*
* @param objs
*/
void createOrUpdate(Object obj);
/**
* Create, or update, all of the entities in the database.
*
* @param objs
*/
void persistAll(Collection<? extends Object> objs);
/**
* Do some database work.
*
* @param work
* the work instance
*/
void doWork(Work work);
/**
* Delete the entities from the database.
*
* @param entities
*/
void deleteAll(Collection<?> entities);
/**
* Delete the entity from the database.
*
* @param entity
*/
void delete(Object entity);
/**
* Get the Hibernate dialect.
*
* @return
*/
Dialect getDialect();
}

View file

@ -0,0 +1,182 @@
/**
* 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.database.dao;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* A CoreDao mimic that is session managed. A Dao will never open its own
* transaction, nor will it commit/rollback transactions. Any number of Daos
* should be utilizable in the same transaction from a service that demarcates
* the transaction boundaries.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 07, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Repository
@Transactional
public class SessionManagedDao {
protected static final IUFStatusHandler statusHandler = UFStatus
.getHandler(SessionManagedDao.class);
protected HibernateTemplate template;
/**
* Sets Hibernate session factory.
*/
@Autowired
public void setSessionFactory(SessionFactory sessionFactory) {
template = new HibernateTemplate(sessionFactory);
}
/**
* Creates the object entry in the database
*
* @param obj
* The object to be created in the database
*/
public void create(final Object obj) {
template.save(obj);
}
/**
* Updates the object entry in the database
*
* @param obj
* The object to be created in the database
*/
public void update(final Object obj) {
template.update(obj);
}
/**
* Creates the object entry in the database
*
* @param obj
* The object to be created in the database
*/
public void createOrUpdate(final Object obj) {
template.saveOrUpdate(obj);
}
/**
* Persists all objects in the collection.
*
* @param objs
* The objects to be persisted to the database
*/
public void persistAll(final Collection<?> objs) {
for (Object obj : objs) {
createOrUpdate(obj);
}
}
/**
* Deletes the object entry in the database
*
* @param obj
* The object to be created in the database
*/
public void delete(final Object obj) {
Object toDelete = template.merge(obj);
template.delete(toDelete);
}
/**
* Delete all of the entities.
*
* @param objs
*/
public void deleteAll(final Collection<?> objs) {
for (Object obj : objs) {
delete(obj);
}
}
/**
* Internal convenience method for querying.
*
* @param <T>
* @param queryString
* @param params
* @return
*/
@SuppressWarnings("unchecked")
protected <T extends Object> List<T> query(String queryString,
Map<String, Object> params) {
final int numberOfParams = params.size();
String[] paramNames = new String[numberOfParams];
Object[] paramValues = new Object[numberOfParams];
Iterator<Map.Entry<String, Object>> iter = params.entrySet().iterator();
for (int i = 0; i < numberOfParams; i++) {
final Entry<String, Object> entry = iter.next();
paramNames[i] = entry.getKey();
paramValues[i] = entry.getValue();
}
return template.findByNamedParam(queryString, paramNames, paramValues);
}
/**
* Internal convenience method for returning a single result.
*
* @param <T>
* @param queryString
* @param params
* @return
*/
@SuppressWarnings("unchecked")
protected <T extends Object> T uniqueResult(String queryString,
Map<String, Object> params) {
final List<Object> results = query(queryString, params);
if (results.isEmpty()) {
return null;
} else if (results.size() > 1) {
statusHandler.warn("More than one result returned for query ["
+ queryString + "], only returning the first!");
}
return (T) results.get(0);
}
}

View file

@ -1,5 +1,5 @@
com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao
com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao
com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate
com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription
com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval
com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation
com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap

View file

@ -0,0 +1 @@
com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthAsyncEventBusFactory

View file

@ -17,6 +17,21 @@
<bean id="bandwidthContextFactory"
class="com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory">
<!-- Used as the context for creating the BandwidthManager -->
<constructor-arg ref="hibernateBandwidthDao" />
</bean>
<bean id="bandwidthAllocationDao" class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthAllocationDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="bandwidthSubscriptionDao" class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthSubscriptionDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="hibernateBandwidthDao" class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
<property name="bandwidthAllocationDao" ref="bandwidthAllocationDao" />
<property name="bandwidthSubscriptionDao" ref="bandwidthSubscriptionDao" />
</bean>
<util:map id="retrievalAgents">

View file

@ -38,7 +38,7 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthReservation;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
@ -123,7 +123,7 @@ class BandwidthGraphDataAdapter {
final SubscriptionRetrieval subRetrieval = (SubscriptionRetrieval) allocation;
retrievals.put(allocation.getId(), subRetrieval);
subNameToRetrievals.put(subRetrieval
.getSubscriptionDao().getName(), subRetrieval);
.getBandwidthSubscription().getName(), subRetrieval);
}
}
@ -139,7 +139,7 @@ class BandwidthGraphDataAdapter {
// them with an reservations they have
for (Entry<Long, SubscriptionRetrieval> entry : retrievals.entrySet()) {
final SubscriptionRetrieval value = entry.getValue();
SubscriptionDao dao = value.getSubscriptionDao();
BandwidthSubscription dao = value.getBandwidthSubscription();
final String subName = dao.getName();
try {
priorityMap.put(subName, dao.getSubscription().getPriority());

View file

@ -59,10 +59,10 @@ import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.BandwidthInitializer;
import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.ISubscriptionAggregator;
@ -256,7 +256,7 @@ abstract class BandwidthManager extends
*/
private void updateDataSetMetaDataWithoutCycle(
GriddedDataSetMetaData dataSetMetaData) throws ParseException {
bandwidthDao.newDataSetMetaDataDao(dataSetMetaData);
bandwidthDao.newBandwidthDataSetUpdate(dataSetMetaData);
// Looking for active subscriptions to the dataset.
try {
@ -299,8 +299,8 @@ abstract class BandwidthManager extends
*/
private void updateDataSetMetaDataWithCycle(
GriddedDataSetMetaData dataSetMetaData) throws ParseException {
DataSetMetaDataDao dataset = bandwidthDao
.newDataSetMetaDataDao(dataSetMetaData);
BandwidthDataSetUpdate dataset = bandwidthDao
.newBandwidthDataSetUpdate(dataSetMetaData);
// Looking for active subscriptions to the dataset.
List<SubscriptionRetrieval> subscriptions = bandwidthDao
@ -356,7 +356,7 @@ abstract class BandwidthManager extends
} else {
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
statusHandler
.debug("No Subscriptions scheduled for DataSetMetaDataDao ["
.debug("No Subscriptions scheduled for BandwidthDataSetUpdate ["
+ dataset.getIdentifier()
+ "] base time ["
+ BandwidthUtil.format(dataset
@ -401,8 +401,8 @@ abstract class BandwidthManager extends
// Retrieve all the current subscriptions by provider, dataset name
// and base time.
List<SubscriptionDao> subscriptions = bandwidthDao
.getSubscriptions(subscription.getProvider(),
List<BandwidthSubscription> subscriptions = bandwidthDao
.getBandwidthSubscriptions(subscription.getProvider(),
subscription.getDataSetName(), retrievalTime);
statusHandler.info("schedule() - Scheduling subscription ["
@ -414,7 +414,7 @@ abstract class BandwidthManager extends
// Add the current subscription to the ones BandwidthManager already
// knows about.
try {
subscriptions.add(bandwidthDao.newSubscriptionDao(subscription,
subscriptions.add(bandwidthDao.newBandwidthSubscription(subscription,
retrievalTime));
} catch (SerializationException e) {
statusHandler.error(
@ -429,12 +429,12 @@ abstract class BandwidthManager extends
return unscheduled;
}
private List<BandwidthAllocation> schedule(SubscriptionDao dao) {
private List<BandwidthAllocation> schedule(BandwidthSubscription dao) {
Calendar retrievalTime = dao.getBaseReferenceTime();
// Retrieve all the current subscriptions by provider, dataset name and
// base time.
List<SubscriptionDao> subscriptions = bandwidthDao.getSubscriptions(
List<BandwidthSubscription> subscriptions = bandwidthDao.getBandwidthSubscriptions(
dao.getProvider(), dao.getDataSetName(), retrievalTime);
statusHandler.info("schedule() - Scheduling subscription ["
@ -449,15 +449,15 @@ abstract class BandwidthManager extends
/**
* Aggregate subscriptions for a given base time and dataset.
*
* @param subscriptionDaos
* @param bandwidthSubscriptions
* A List of SubscriptionDaos that have the same base time and
* dataset.
*/
private List<BandwidthAllocation> aggregate(
List<SubscriptionDao> subscriptionDaos) {
List<BandwidthSubscription> bandwidthSubscriptions) {
List<SubscriptionRetrieval> retrievals = getAggregator().aggregate(
subscriptionDaos);
bandwidthSubscriptions);
// Create a separate list of BandwidthReservations to schedule
// as the aggregation process may return all subsumed
@ -480,8 +480,8 @@ abstract class BandwidthManager extends
.getStatus().equals(RetrievalStatus.PROCESSING))
&& !retrieval.isSubsumed()) {
SubscriptionDao dao = retrieval.getSubscriptionDao();
Calendar retrievalTime = dao.getBaseReferenceTime();
BandwidthSubscription bandwidthSubscription = retrieval.getBandwidthSubscription();
Calendar retrievalTime = bandwidthSubscription.getBaseReferenceTime();
Calendar startTime = BandwidthUtil.copy(retrievalTime);
int delayMinutes = retrieval.getDataSetAvailablityDelay();
@ -515,10 +515,10 @@ abstract class BandwidthManager extends
// Check to see if the data subscribed to is available..
// if so, mark the status of the BandwidthReservation as
// READY.
List<DataSetMetaDataDao> z = bandwidthDao
.getDataSetMetaDataDao(dao.getProvider(),
dao.getDataSetName(),
dao.getBaseReferenceTime());
List<BandwidthDataSetUpdate> z = bandwidthDao
.getBandwidthDataSetUpdate(bandwidthSubscription.getProvider(),
bandwidthSubscription.getDataSetName(),
bandwidthSubscription.getBaseReferenceTime());
if (z.size() > 0) {
retrieval.setStatus(RetrievalStatus.READY);
}
@ -552,8 +552,8 @@ abstract class BandwidthManager extends
+ event.getId() + "]");
// Need to locate and remove all BandwidthReservations for the
// given subscription..
List<SubscriptionDao> l = bandwidthDao
.getSubscriptionDaoByRegistryId(event.getId());
List<BandwidthSubscription> l = bandwidthDao
.getBandwidthSubscriptionByRegistryId(event.getId());
if (!l.isEmpty()) {
remove(l, true);
}
@ -617,12 +617,12 @@ abstract class BandwidthManager extends
@Override
public List<BandwidthAllocation> schedule(AdhocSubscription subscription) {
List<SubscriptionDao> subscriptions = new ArrayList<SubscriptionDao>();
List<BandwidthSubscription> subscriptions = new ArrayList<BandwidthSubscription>();
Calendar now = BandwidthUtil.now();
// Store the AdhocSubscription with a base time of now..
try {
subscriptions.add(bandwidthDao
.newSubscriptionDao(subscription, now));
.newBandwidthSubscription(subscription, now));
} catch (SerializationException e) {
statusHandler.error(
"Trapped Exception trying to schedule AdhocSubscription["
@ -692,12 +692,12 @@ abstract class BandwidthManager extends
// Dealing with a 'normal' subscription
else {
// First see if BandwidthManager has seen the subscription before.
List<SubscriptionDao> subscriptionDaos = bandwidthDao
.getSubscriptionDao(subscription);
List<BandwidthSubscription> bandwidthSubscriptions = bandwidthDao
.getBandwidthSubscription(subscription);
// If BandwidthManager does not know about the subscription, and
// it's active, attempt to add it..
if (subscriptionDaos.isEmpty() && subscription.isActive()
if (bandwidthSubscriptions.isEmpty() && subscription.isActive()
&& !subscription.isUnscheduled()) {
final boolean subscribedToCycles = !subscription.getTime()
.getCycleTimes().isEmpty();
@ -731,7 +731,7 @@ abstract class BandwidthManager extends
// See if the subscription was inactivated or unscheduled..
// Need to remove BandwidthReservations for this
// subscription.
return remove(subscriptionDaos, true);
return remove(bandwidthSubscriptions, true);
} else {
// Compare the 'updated' Subscription with the stored
@ -740,7 +740,7 @@ abstract class BandwidthManager extends
// BandwidthReservations
// already in place for this subscription.
Subscription old = subscriptionDaos.get(0).getSubscription();
Subscription old = bandwidthSubscriptions.get(0).getSubscription();
// Check to see if estimated size changed. If there was a change
// to
@ -755,9 +755,9 @@ abstract class BandwidthManager extends
// OK, have to remove the old Subscriptions and add the new
// ones..
List<BandwidthAllocation> unscheduled = remove(
subscriptionDaos, false);
bandwidthSubscriptions, false);
// No need to check anything else since all the
// SubscriptionDao's have been replaced.
// BandwidthSubscription's have been replaced.
unscheduled.addAll(schedule(subscription));
return unscheduled;
}
@ -790,14 +790,14 @@ abstract class BandwidthManager extends
if (oldCycles.size() > 0) {
// Create a List of SubscriptionDaos that need to be
// removed..
List<SubscriptionDao> remove = new ArrayList<SubscriptionDao>();
SubscriptionDao dao = null;
Iterator<SubscriptionDao> itr = subscriptionDaos
List<BandwidthSubscription> remove = new ArrayList<BandwidthSubscription>();
BandwidthSubscription bandwidthSubscription = null;
Iterator<BandwidthSubscription> itr = bandwidthSubscriptions
.iterator();
while (itr.hasNext()) {
dao = itr.next();
if (oldCycles.contains(dao.getCycle())) {
remove.add(dao);
bandwidthSubscription = itr.next();
if (oldCycles.contains(bandwidthSubscription.getCycle())) {
remove.add(bandwidthSubscription);
itr.remove();
}
}
@ -810,9 +810,9 @@ abstract class BandwidthManager extends
}
// Update the remaining dao's with the current subscription...
for (SubscriptionDao dao : subscriptionDaos) {
dao.setSubscription(subscription);
bandwidthDao.update(dao);
for (BandwidthSubscription bandwidthSubscription : bandwidthSubscriptions) {
bandwidthSubscription.setSubscription(subscription);
bandwidthDao.update(bandwidthSubscription);
}
return unscheduled;
@ -856,33 +856,33 @@ abstract class BandwidthManager extends
}
/**
* Remove SubscriptionDao's (and dependent Objects) from any RetrievalPlans
* Remove BandwidthSubscription's (and dependent Objects) from any RetrievalPlans
* they are in and adjust the RetrievalPlans accordingly.
*
* @param subscriptionDaos
* @param bandwidthSubscriptions
* The subscriptionDao's to remove.
* @param reschedule
* @return
*/
private List<BandwidthAllocation> remove(
List<SubscriptionDao> subscriptionDaos, boolean reschedule) {
List<BandwidthSubscription> bandwidthSubscriptions, boolean reschedule) {
List<BandwidthAllocation> unscheduled = new ArrayList<BandwidthAllocation>();
// If we need to reschedule other bandwidth reservations when we
// remove the provided SubscriptionDao's then we have to retrieve
// remove the provided BandwidthSubscription's then we have to retrieve
// all the SubscriptionRetrieval records that are scheduled for
// the same base time.
if (reschedule) {
// First create a map of base times to subscriptions
Multimap<Calendar, SubscriptionDao> map = ArrayListMultimap
Multimap<Calendar, BandwidthSubscription> map = ArrayListMultimap
.create();
for (SubscriptionDao subscriptionDao : subscriptionDaos) {
for (BandwidthSubscription bandwidthSubscription : bandwidthSubscriptions) {
Calendar time = subscriptionDao.getBaseReferenceTime();
map.put(time, subscriptionDao);
Calendar time = bandwidthSubscription.getBaseReferenceTime();
map.put(time, bandwidthSubscription);
}
// Now process each time group by dataset..
@ -890,20 +890,20 @@ abstract class BandwidthManager extends
// For each date, get a unique set of provider & dataset name
Set<String> providerDataSet = new HashSet<String>();
for (SubscriptionDao dao : map.get(baseTime)) {
String key = dao.getProvider() + "::"
+ dao.getDataSetName();
for (BandwidthSubscription bandwidthSubscription : map.get(baseTime)) {
String key = bandwidthSubscription.getProvider() + "::"
+ bandwidthSubscription.getDataSetName();
providerDataSet.add(key);
bandwidthDaoUtil.remove(dao);
bandwidthDaoUtil.remove(bandwidthSubscription);
}
// Query for and reschedule any SubscriptionRetrieval
// Objects associated with the Queried SubscriptionDao's
// Objects associated with the Queried BandwidthSubscription's
for (String providerDataSetName : providerDataSet) {
String[] key = providerDataSetName.split("::");
String provider = key[0];
String dataSetName = key[1];
List<SubscriptionDao> m = bandwidthDao.getSubscriptions(
List<BandwidthSubscription> m = bandwidthDao.getBandwidthSubscriptions(
provider, dataSetName, baseTime);
unscheduled.addAll(aggregate(m));
@ -912,8 +912,8 @@ abstract class BandwidthManager extends
} else {
for (SubscriptionDao subscriptionDao : subscriptionDaos) {
bandwidthDaoUtil.remove(subscriptionDao);
for (BandwidthSubscription bandwidthSubscription : bandwidthSubscriptions) {
bandwidthDaoUtil.remove(bandwidthSubscription);
}
}
@ -935,7 +935,7 @@ abstract class BandwidthManager extends
.getSubscriptionRetrieval();
List<SubscriptionRetrieval> subscriptionRetrievals = bandwidthDao
.querySubscriptionRetrievals(sr.getSubscriptionDao());
.querySubscriptionRetrievals(sr.getBandwidthSubscription());
// Look to see if all the SubscriptionRetrieval's for a subscription are
// completed.
@ -954,13 +954,13 @@ abstract class BandwidthManager extends
plan.remove(sr);
// Schedule the next iteration of the subscription
SubscriptionDao dao = sr.getSubscriptionDao();
BandwidthSubscription dao = sr.getBandwidthSubscription();
Subscription subscription = null;
try {
subscription = dao.getSubscription();
} catch (SerializationException e) {
statusHandler.error(
"Failed to extract Subscription from SubscriptionDao ["
"Failed to extract Subscription from BandwidthSubscription ["
+ dao.getIdentifier() + "]", e);
// No sense in continuing
return;
@ -980,20 +980,20 @@ abstract class BandwidthManager extends
next.add(Calendar.DAY_OF_YEAR, 1);
// Since subscriptions are based on cycles in a day, add one day
// to the
// completed SubscriptionDao to get the next days retrieval.
// completed BandwidthSubscription to get the next days retrieval.
// Now check if that SubscriptionDao has already been scheduled.
SubscriptionDao a = bandwidthDao.getSubscriptionDao(
// Now check if that BandwidthSubscription has already been scheduled.
BandwidthSubscription a = bandwidthDao.getBandwidthSubscription(
dao.getRegistryId(), next);
if (a == null) {
// Create the new SubscriptionDao record with the next
// Create the new BandwidthSubscription record with the next
// time..
try {
a = bandwidthDao.newSubscriptionDao(subscription, next);
a = bandwidthDao.newBandwidthSubscription(subscription, next);
} catch (SerializationException e) {
statusHandler.error(
"Failed to create new SubscriptionDao from Subscription ["
"Failed to create new BandwidthSubscription from Subscription ["
+ subscription.getId()
+ "] baseReferenceTime ["
+ BandwidthUtil.format(next) + "]", e);
@ -1172,23 +1172,23 @@ abstract class BandwidthManager extends
* @return the estimated completion time
*/
private Date getEstimatedCompletionTime(AdhocSubscription subscription) {
final List<SubscriptionDao> subscriptionDaos = bandwidthDao
.getSubscriptionDaoByRegistryId(subscription.getId());
final List<BandwidthSubscription> bandwidthSubscriptions = bandwidthDao
.getBandwidthSubscriptionByRegistryId(subscription.getId());
if (subscriptionDaos.isEmpty()) {
if (bandwidthSubscriptions.isEmpty()) {
statusHandler
.warn("Unable to find subscriptionDaos for subscription ["
+ subscription + "]. Returning current time.");
return new Date();
} else if (subscriptionDaos.size() > 1) {
} else if (bandwidthSubscriptions.size() > 1) {
statusHandler
.warn("Found more than one subscriptionDaos for subscription ["
+ subscription
+ "]. Ignoring list and using the first item.");
}
SubscriptionDao dao = subscriptionDaos.get(0);
long id = dao.getId();
BandwidthSubscription bandwidthSubscription = bandwidthSubscriptions.get(0);
long id = bandwidthSubscription.getId();
final List<BandwidthAllocation> bandwidthAllocations = bandwidthDao
.getBandwidthAllocations(id);
@ -1494,7 +1494,7 @@ abstract class BandwidthManager extends
IBandwidthDao fromDao = copyFrom.bandwidthDao;
Set<Subscription> actualSubscriptions = new HashSet<Subscription>();
for (SubscriptionDao subscription : fromDao.getSubscriptions()) {
for (BandwidthSubscription subscription : fromDao.getBandwidthSubscriptions()) {
try {
Subscription actualSubscription = subscription
.getSubscription();

View file

@ -58,6 +58,8 @@ class EdexBandwidthContextFactory implements BandwidthContextFactory {
private static BandwidthManager instance;
private IBandwidthDao bandwidthDao;
/**
* Intentionally package-private constructor, as it is created from Spring
* which is able to reflectively instantiate.
@ -65,7 +67,8 @@ class EdexBandwidthContextFactory implements BandwidthContextFactory {
* @param instance
* the {@link BandwidthManager} instance
*/
EdexBandwidthContextFactory() {
EdexBandwidthContextFactory(IBandwidthDao bandwidthDao) {
this.bandwidthDao = bandwidthDao;
}
/**
@ -108,7 +111,8 @@ class EdexBandwidthContextFactory implements BandwidthContextFactory {
*/
@Override
public IBandwidthDbInit getBandwidthDbInit() {
return new HibernateBandwidthDbInit(HibernateBandwidthDao.getInstance());
return new HibernateBandwidthDbInit(
HibernateBandwidthDao.class.cast(getBandwidthDao()));
}
/**
@ -116,7 +120,7 @@ class EdexBandwidthContextFactory implements BandwidthContextFactory {
*/
@Override
public IBandwidthDao getBandwidthDao() {
return HibernateBandwidthDao.getInstance();
return bandwidthDao;
}
/**

View file

@ -126,7 +126,7 @@ public interface IBandwidthManager {
/**
* The callback method for BandwidthEventBus to use to notify
* BandwidthManager that retrievalManager has completed the retrievals for a
* Subscription. The updated SubscriptionDao Object is placed on the
* Subscription. The updated BandwidthSubscription Object is placed on the
* BandwidthEventBus.
*
* @param subscription

View file

@ -36,9 +36,9 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.ReflectionUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
@ -72,9 +72,9 @@ class InMemoryBandwidthDao implements IBandwidthDao {
// type to be concurrently safe
private final ConcurrentLinkedQueue<BandwidthAllocation> bandwidthAllocations = new ConcurrentLinkedQueue<BandwidthAllocation>();
private final ConcurrentLinkedQueue<SubscriptionDao> subscriptionDaos = new ConcurrentLinkedQueue<SubscriptionDao>();
private final ConcurrentLinkedQueue<BandwidthSubscription> bandwidthSubscriptions = new ConcurrentLinkedQueue<BandwidthSubscription>();
private final ConcurrentLinkedQueue<DataSetMetaDataDao> dataSetMetaDataDaos = new ConcurrentLinkedQueue<DataSetMetaDataDao>();
private final ConcurrentLinkedQueue<BandwidthDataSetUpdate> bandwidthDataSetUpdates = new ConcurrentLinkedQueue<BandwidthDataSetUpdate>();
/**
* {@inheritDoc}
@ -87,7 +87,7 @@ class InMemoryBandwidthDao implements IBandwidthDao {
.hasNext();) {
BandwidthAllocation current = iter.next();
if ((current instanceof SubscriptionRetrieval)
&& ((SubscriptionRetrieval) current).getSubscriptionDao()
&& ((SubscriptionRetrieval) current).getBandwidthSubscription()
.getId() == subscriptionId) {
continue;
}
@ -158,13 +158,13 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public List<DataSetMetaDataDao> getDataSetMetaDataDao(String providerName,
public List<BandwidthDataSetUpdate> getBandwidthDataSetUpdate(String providerName,
String dataSetName) {
ArrayList<DataSetMetaDataDao> results = clone(dataSetMetaDataDaos);
ArrayList<BandwidthDataSetUpdate> results = clone(bandwidthDataSetUpdates);
for (Iterator<DataSetMetaDataDao> iter = results.iterator(); iter
for (Iterator<BandwidthDataSetUpdate> iter = results.iterator(); iter
.hasNext();) {
DataSetMetaDataDao current = iter.next();
BandwidthDataSetUpdate current = iter.next();
if (providerName.equals(current.getProviderName())
&& dataSetName.equals(current.getDataSetName())) {
continue;
@ -180,14 +180,14 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public List<DataSetMetaDataDao> getDataSetMetaDataDao(String providerName,
public List<BandwidthDataSetUpdate> getBandwidthDataSetUpdate(String providerName,
String dataSetName, Calendar baseReferenceTime) {
List<DataSetMetaDataDao> results = getDataSetMetaDataDao(providerName,
List<BandwidthDataSetUpdate> results = getBandwidthDataSetUpdate(providerName,
dataSetName);
for (Iterator<DataSetMetaDataDao> iter = results.iterator(); iter
for (Iterator<BandwidthDataSetUpdate> iter = results.iterator(); iter
.hasNext();) {
DataSetMetaDataDao current = iter.next();
BandwidthDataSetUpdate current = iter.next();
if (current.getDataSetBaseTime().getTimeInMillis() == baseReferenceTime
.getTimeInMillis()) {
continue;
@ -222,9 +222,9 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public SubscriptionDao getSubscriptionDao(long identifier) {
ArrayList<SubscriptionDao> subscriptionDaos = clone(this.subscriptionDaos);
for (SubscriptionDao dao : subscriptionDaos) {
public BandwidthSubscription getBandwidthSubscription(long identifier) {
ArrayList<BandwidthSubscription> bandwidthSubscriptions = clone(this.bandwidthSubscriptions);
for (BandwidthSubscription dao : bandwidthSubscriptions) {
if (dao.getIdentifier() == identifier) {
return dao;
}
@ -236,13 +236,13 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public SubscriptionDao getSubscriptionDao(String registryId,
public BandwidthSubscription getBandwidthSubscription(String registryId,
Calendar baseReferenceTime) {
List<SubscriptionDao> daos = getSubscriptionDaoByRegistryId(registryId);
for (SubscriptionDao dao : daos) {
if (dao.getBaseReferenceTime().getTimeInMillis() == baseReferenceTime
List<BandwidthSubscription> bandwidthSubscriptions = getBandwidthSubscriptionByRegistryId(registryId);
for (BandwidthSubscription bandwidthSubscription : bandwidthSubscriptions) {
if (bandwidthSubscription.getBaseReferenceTime().getTimeInMillis() == baseReferenceTime
.getTimeInMillis()) {
return dao;
return bandwidthSubscription;
}
}
return null;
@ -252,20 +252,20 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public List<SubscriptionDao> getSubscriptionDao(Subscription subscription) {
return getSubscriptionDaoByRegistryId(subscription.getId());
public List<BandwidthSubscription> getBandwidthSubscription(Subscription subscription) {
return getBandwidthSubscriptionByRegistryId(subscription.getId());
}
/**
* {@inheritDoc}
*/
@Override
public List<SubscriptionDao> getSubscriptionDaoByRegistryId(
public List<BandwidthSubscription> getBandwidthSubscriptionByRegistryId(
String registryId) {
final ArrayList<SubscriptionDao> results = clone(subscriptionDaos);
for (Iterator<SubscriptionDao> iter = results
final ArrayList<BandwidthSubscription> results = clone(bandwidthSubscriptions);
for (Iterator<BandwidthSubscription> iter = results
.iterator(); iter.hasNext();) {
final SubscriptionDao current = iter.next();
final BandwidthSubscription current = iter.next();
if (registryId.equals(current.getRegistryId())) {
continue;
}
@ -298,15 +298,15 @@ class InMemoryBandwidthDao implements IBandwidthDao {
String provider, String dataSetName, Calendar baseReferenceTime) {
List<SubscriptionRetrieval> results = new ArrayList<SubscriptionRetrieval>(
getSubscriptionRetrievals(provider, dataSetName));
List<SubscriptionDao> subscriptionsMatching = getSubscriptions(
List<BandwidthSubscription> subscriptionsMatching = getBandwidthSubscriptions(
provider,
dataSetName, baseReferenceTime);
OUTER: for (Iterator<SubscriptionRetrieval> iter = results.iterator(); iter
.hasNext();) {
SubscriptionRetrieval current = iter.next();
for (SubscriptionDao subscription : subscriptionsMatching) {
if (current.getSubscriptionDao().getId() == subscription
for (BandwidthSubscription subscription : subscriptionsMatching) {
if (current.getBandwidthSubscription().getId() == subscription
.getIdentifier()) {
continue OUTER;
}
@ -359,21 +359,21 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public List<SubscriptionDao> getSubscriptions() {
return clone(subscriptionDaos);
public List<BandwidthSubscription> getBandwidthSubscriptions() {
return clone(bandwidthSubscriptions);
}
/**
* {@inheritDoc}
*/
@Override
public List<SubscriptionDao> getSubscriptions(String provider,
public List<BandwidthSubscription> getBandwidthSubscriptions(String provider,
String dataSetName, Calendar baseReferenceTime) {
List<SubscriptionDao> subscriptionDaos = getSubscriptions();
List<BandwidthSubscription> bandwidthSubscriptions = getBandwidthSubscriptions();
for (Iterator<SubscriptionDao> iter = subscriptionDaos.iterator(); iter
for (Iterator<BandwidthSubscription> iter = bandwidthSubscriptions.iterator(); iter
.hasNext();) {
SubscriptionDao current = iter.next();
BandwidthSubscription current = iter.next();
if (provider.equals(current.getProvider())
&& dataSetName.equals(current.getDataSetName())
&& baseReferenceTime.getTimeInMillis() == current
@ -383,36 +383,36 @@ class InMemoryBandwidthDao implements IBandwidthDao {
iter.remove();
}
return subscriptionDaos;
return bandwidthSubscriptions;
}
/**
* {@inheritDoc}
*/
@Override
public DataSetMetaDataDao newDataSetMetaDataDao(
public BandwidthDataSetUpdate newBandwidthDataSetUpdate(
DataSetMetaData dataSetMetaData) {
DataSetMetaDataDao dao = BandwidthUtil
BandwidthDataSetUpdate entity = BandwidthUtil
.newDataSetMetaDataDao(dataSetMetaData);
dao.setIdentifier(getNextId());
entity.setIdentifier(getNextId());
dataSetMetaDataDaos.add(dao);
bandwidthDataSetUpdates.add(entity);
return dao;
return entity;
}
/**
* {@inheritDoc}
*/
@Override
public SubscriptionDao newSubscriptionDao(Subscription subscription,
public BandwidthSubscription newBandwidthSubscription(Subscription subscription,
Calendar baseReferenceTime) throws SerializationException {
SubscriptionDao dao = BandwidthUtil.getSubscriptionDaoForSubscription(
BandwidthSubscription entity = BandwidthUtil.getSubscriptionDaoForSubscription(
subscription, baseReferenceTime);
update(dao);
update(entity);
return dao;
return entity;
}
/**
@ -429,7 +429,7 @@ class InMemoryBandwidthDao implements IBandwidthDao {
.hasNext();) {
BandwidthAllocation current = iter.next();
if (current instanceof SubscriptionRetrieval) {
if (((SubscriptionRetrieval) current).getSubscriptionDao()
if (((SubscriptionRetrieval) current).getBandwidthSubscription()
.getId() == subscriptionId) {
results.add((SubscriptionRetrieval) current);
}
@ -444,7 +444,7 @@ class InMemoryBandwidthDao implements IBandwidthDao {
*/
@Override
public List<SubscriptionRetrieval> querySubscriptionRetrievals(
SubscriptionDao dao) {
BandwidthSubscription dao) {
return querySubscriptionRetrievals(dao.getId());
}
@ -452,8 +452,8 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public void remove(SubscriptionDao subscriptionDao) {
removeFromCollection(subscriptionDaos, subscriptionDao);
public void remove(BandwidthSubscription subscriptionDao) {
removeFromCollection(bandwidthSubscriptions, subscriptionDao);
}
/**
@ -468,8 +468,8 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public void store(SubscriptionDao subscriptionDao) {
replaceOldOrAddToCollection(subscriptionDaos, subscriptionDao);
public void store(BandwidthSubscription subscriptionDao) {
replaceOldOrAddToCollection(bandwidthSubscriptions, subscriptionDao);
}
/**
@ -501,8 +501,8 @@ class InMemoryBandwidthDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public void update(SubscriptionDao dao) {
replaceOldOrAddToCollection(subscriptionDaos, dao);
public void update(BandwidthSubscription dao) {
replaceOldOrAddToCollection(bandwidthSubscriptions, dao);
}
/**

View file

@ -49,7 +49,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
@DiscriminatorColumn(name = "dtype", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("BandwidthAllocation")
@DynamicSerialize
@SequenceGenerator(name = "BANDWIDTH_SEQ", sequenceName = "bandwidth_seq", allocationSize = 1)
@SequenceGenerator(name = "BANDWIDTH_SEQ", sequenceName = "bandwidth_seq", allocationSize = 1, initialValue = 1)
public class BandwidthAllocation implements IPersistableDataObject<Long>,
ISerializableObject, Serializable {

View file

@ -42,7 +42,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
@Table(name = "bandwidth_datasetupdate")
@SequenceGenerator(name = "BANDWIDTH_SEQ", sequenceName = "bandwidth_datasetupdate_seq", allocationSize = 1)
@DynamicSerialize
public class DataSetMetaDataDao implements IPersistableDataObject<Long>,
public class BandwidthDataSetUpdate implements IPersistableDataObject<Long>,
Serializable, ISerializableObject {
private static final long serialVersionUID = 20120723L;

View file

@ -48,12 +48,12 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
@Entity
@Table(name = "bandwidth_subscription")
@DynamicSerialize
@SequenceGenerator(name = "BANDWIDTH_SEQ", sequenceName = "bandwidth_seq", allocationSize = 1)
public class SubscriptionDao extends PersistableDataObject<Long> implements
@SequenceGenerator(name = "BANDWIDTH_SEQ", sequenceName = "bandwidth_seq", allocationSize = 1, initialValue = 1)
public class BandwidthSubscription extends PersistableDataObject<Long> implements
Serializable, ISerializableObject {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(SubscriptionDao.class);
.getHandler(BandwidthSubscription.class);
private static final long serialVersionUID = 20120723L;
@ -150,7 +150,7 @@ public class SubscriptionDao extends PersistableDataObject<Long> implements
}
}
public SubscriptionDao() {
public BandwidthSubscription() {
// Bean constructor
}

View file

@ -82,7 +82,7 @@ public interface IBandwidthDao {
* @return A List of DataSetMetaDataDaos that have the specified
* providerName and dataSetName.
*/
List<DataSetMetaDataDao> getDataSetMetaDataDao(String providerName,
List<BandwidthDataSetUpdate> getBandwidthDataSetUpdate(String providerName,
String dataSetName);
/**
@ -99,7 +99,7 @@ public interface IBandwidthDao {
* @return A List of DataSetMetaDataDaos that have the specified
* providerName, dataSetName and baseReferenceTime.
*/
List<DataSetMetaDataDao> getDataSetMetaDataDao(String providerName,
List<BandwidthDataSetUpdate> getBandwidthDataSetUpdate(String providerName,
String dataSetName, Calendar baseReferenceTime);
/**
@ -112,53 +112,54 @@ public interface IBandwidthDao {
List<BandwidthAllocation> getDeferred(Network network, Calendar endTime);
/**
* Get a SubscriptionDao.
* Get a BandwidthSubscription.
*
* @param identifier
* Retrieve the SubscriptionDao with the specified identifier.
* Retrieve the BandwidthSubscription with the specified identifier.
*
* @return The SubscriptionDao that has the specified identifier or null if
* no such SubscriptionDao exists.
* @return The BandwidthSubscription that has the specified identifier or null if
* no such BandwidthSubscription exists.
*/
SubscriptionDao getSubscriptionDao(long identifier);
BandwidthSubscription getBandwidthSubscription(long identifier);
/**
* Get a SubscriptionDao.
* Get a BandwidthSubscription.
*
* @param registryId
* Retrieve the SubscriptionDao with the specified registryId.
* Retrieve the BandwidthSubscription with the specified registryId.
* @param baseReferenceTime
* Retrieve the SubscriptionDao with the specified
* Retrieve the BandwidthSubscription with the specified
* baseReferenceTime.
*
* @return The SubscriptionDao that has the specified identifier and
* baseReferenceTime or null if no such SubscriptionDao exists.
* @return The BandwidthSubscription that has the specified identifier and
* baseReferenceTime or null if no such BandwidthSubscription exists.
*/
SubscriptionDao getSubscriptionDao(String registryId,
BandwidthSubscription getBandwidthSubscription(String registryId,
Calendar baseReferenceTime);
/**
* Get SubscriptionDaos.
* Get BandwidthSubscriptions.
*
* @param subscription
* Retrieve SubscriptionDaos that match the specified
* Retrieve BandwidthSubscriptions that match the specified
* subscription's owner, provider, name and dataSetName.
*
* @return A List of SubscriptionDaos that have the same owner, provider,
* name and dataSetName and the specified subscription.
* @return A List of BandwidthSubscriptions that have the same owner,
* provider, name and dataSetName and the specified subscription.
*/
List<SubscriptionDao> getSubscriptionDao(Subscription subscription);
List<BandwidthSubscription> getBandwidthSubscription(Subscription subscription);
/**
* Get a SubscriptionDaos.
* Get a BandwidthSubscriptions.
*
* @param registryId
* Retrieve the SubscriptionDaos with the specified registryId.
* Retrieve the BandwidthSubscriptions with the specified
* registryId.
*
* @return A List of SubscriptionDaos that has the specified registryId or
* null if no such SubscriptionDao exists.
* @return A List of BandwidthSubscriptions that has the specified
* registryId or null if no such BandwidthSubscription exists.
*/
List<SubscriptionDao> getSubscriptionDaoByRegistryId(String registryId);
List<BandwidthSubscription> getBandwidthSubscriptionByRegistryId(String registryId);
/**
* Retrieve a SubscriptionRetrieval Object from the database given an
@ -211,12 +212,12 @@ public interface IBandwidthDao {
String dataSetName);
/**
* Return all the SubscriptionDao Objects in the database in ascending order
* based on the SubscriptionDao's baseReferenceTime attribute.
* Return all the BandwidthSubscription Objects in the database in ascending order
* based on the BandwidthSubscription's baseReferenceTime attribute.
*
* @return A List of SubscriptionDao Objects.
* @return A List of BandwidthSubscription Objects.
*/
List<SubscriptionDao> getSubscriptions();
List<BandwidthSubscription> getBandwidthSubscriptions();
/**
* Get all the subscription retrievals for the specified dataset and base
@ -234,36 +235,36 @@ public interface IBandwidthDao {
* @return All the SubscriptionRetrievals that are scheduled for the
* specified time.
*/
List<SubscriptionDao> getSubscriptions(String provider, String dataSetName,
List<BandwidthSubscription> getBandwidthSubscriptions(String provider, String dataSetName,
Calendar baseReferenceTime);
/**
* Create a new DataSetMetaDataDao Object based on the dataSetMetaData
* Create a new BandwidthDataSetUpdate Object based on the dataSetMetaData
* Object provided.
*
* @param dataSetMetaData
* The DataSetMetaData Object to create the DataSetMetaDataDao
* The DataSetMetaData Object to create the BandwidthDataSetUpdate
* Object from.
*
* @return A newly created and persisted DataSetMetaDataDao Object.
* @return A newly created and persisted BandwidthDataSetUpdate Object.
*/
DataSetMetaDataDao newDataSetMetaDataDao(DataSetMetaData dataSetMetaData);
BandwidthDataSetUpdate newBandwidthDataSetUpdate(DataSetMetaData dataSetMetaData);
/**
* Create a new SubscriptionDao Object based on the Subscription and
* Create a new BandwidthSubscription Object based on the Subscription and
* Calendar Objects provided.
*
* @param Subscription
* The Subscription Object to create the SubscriptionDao Object
* The Subscription Object to create the BandwidthSubscription Object
* from.
*
* @param baseReferenceTime
* The base reference time to set on the newly created
* SubscriptionDao Object.
* BandwidthSubscription Object.
*
* @return A newly created and persisted SubscriptionDao Object.
* @return A newly created and persisted BandwidthSubscription Object.
*/
SubscriptionDao newSubscriptionDao(Subscription subscription,
BandwidthSubscription newBandwidthSubscription(Subscription subscription,
Calendar baseReferenceTime) throws SerializationException;
/**
@ -280,22 +281,22 @@ public interface IBandwidthDao {
/**
* Get {@link SubscriptionRetrieval}s for the specific
* {@link SubscriptionDao}.
* {@link BandwidthSubscription}.
*
* @param subscriptionDao
* the dao
* @return the retrievals
*/
List<SubscriptionRetrieval> querySubscriptionRetrievals(
SubscriptionDao subscriptionDao);
BandwidthSubscription subscriptionDao);
/**
* Remove a SubscriptionDao from the database.
* Remove a BandwidthSubscription from the database.
*
* @param subscriptionDao
* The subscriptionDao to remove.
*/
void remove(SubscriptionDao subscriptionDao);
void remove(BandwidthSubscription subscriptionDao);
/**
* Persist a BandwidthAllocation to the database.
@ -314,12 +315,12 @@ public interface IBandwidthDao {
void store(List<SubscriptionRetrieval> retrievals);
/**
* Persist a {@link SubscriptionDao} to the database.
* Persist a {@link BandwidthSubscription} to the database.
*
* @param subscriptionDao
* The {@link SubscriptionDao} to store.
* The {@link BandwidthSubscription} to store.
*/
void store(SubscriptionDao subscriptionDao);
void store(BandwidthSubscription subscriptionDao);
/**
* Update a BandwidthAllocation in the database.
@ -330,12 +331,12 @@ public interface IBandwidthDao {
void update(BandwidthAllocation allocation);
/**
* Update a SubscriptionDao in the database.
* Update a BandwidthSubscription in the database.
*
* @param dao
* The SubscriptionDao to store.
* The BandwidthSubscription to store.
*/
void update(SubscriptionDao dao);
void update(BandwidthSubscription dao);
/**
* Update a SubscriptionRetrieval in the database.

View file

@ -30,7 +30,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Oct 02, 2012 726 jspinks Initial creation
* Oct 16, 2012 0726 djohnson Added explicit length to subSubscription,
* made it nullable for single table strategy.
* Nov 09, 2012 1286 djohnson Add reference back to owning SubscriptionDao.
* Nov 09, 2012 1286 djohnson Add reference back to owning BandwidthSubscription.
*
* </pre>
*
@ -56,13 +56,13 @@ public class SubscriptionRetrieval extends BandwidthAllocation {
private byte[] subSubscription;
/**
* A link to the owning SubscriptionDao entity.
* A link to the owning BandwidthSubscription entity.
*/
@DynamicSerializeElement
@ManyToOne(fetch = FetchType.EAGER, optional = true)
// Must be nullable because we use a single table strategy
@IndexColumn(name = "subscriptionid_fk", nullable = true)
private SubscriptionDao subscriptionDao;
private BandwidthSubscription bandwidthSubscription;
@Column
@DynamicSerializeElement
@ -118,18 +118,19 @@ public class SubscriptionRetrieval extends BandwidthAllocation {
}
/**
* @return the subscriptionDao
* @return the bandwidthSubscription
*/
public SubscriptionDao getSubscriptionDao() {
return subscriptionDao;
public BandwidthSubscription getBandwidthSubscription() {
return bandwidthSubscription;
}
/**
* @param subscriptionDao
* the subscriptionDao to set
* @param bandwidthSubscription
* the bandwidthSubscription to set
*/
public void setSubscriptionDao(SubscriptionDao subscriptionDao) {
this.subscriptionDao = subscriptionDao;
public void setBandwidthSubscription(
BandwidthSubscription bandwidthSubscription) {
this.bandwidthSubscription = bandwidthSubscription;
}
/**

View file

@ -0,0 +1,50 @@
/**
* 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 com.raytheon.uf.edex.database.dao.SessionManagedDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
/**
* {@link SessionManagedDao} for {@link BandwidthAllocation}s.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 07, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class BandwidthAllocationDao extends SessionManagedDao {
/**
* Constructor.
*/
public BandwidthAllocationDao() {
super();
}
}

View file

@ -0,0 +1,49 @@
/**
* 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 com.raytheon.uf.edex.database.dao.SessionManagedDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
/**
* Data access object for {@link BandwidthSubscription} instances.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 07, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class BandwidthSubscriptionDao extends SessionManagedDao {
/**
* Constructor.
*/
public BandwidthSubscriptionDao() {
super();
}
}

View file

@ -24,25 +24,21 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.Dialect;
import org.hibernate.impl.SessionFactoryImpl;
import org.hibernate.jdbc.Work;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.util.session.SessionContext;
import com.raytheon.uf.common.util.session.SessionManager;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.dao.SessionManagedDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
@ -57,77 +53,35 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 23, 2012 1286 djohnson Extracted from BandwidthContextFactory.
* Feb 07, 2013 1543 djohnson Moved session management context to CoreDao.
* Feb 11, 2013 1543 djohnson Use Spring transactions.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
/**
*
* Implementation of {@link SessionContext} which controls the Hibernate
* session and transaction. The {@link SessionManager} controls the
* lifecycle of the context, and you can read the documentation located in
* the {@link SessionManager} class for more details on its use.
*/
public static class BandwidthSessionContext implements SessionContext {
private Session session;
@Transactional
@Repository
// TODO: Split service functionality from DAO functionality
public class HibernateBandwidthDao extends SessionManagedDao implements
IBandwidthDao {
private Transaction tx;
private BandwidthAllocationDao bandwidthAllocationDao;
/**
* {@inheritDoc}
*/
@Override
public void open() {
session = instance.getSessionFactory().openSession();
tx = session.beginTransaction();
}
/**
* {@inheritDoc}
*/
@Override
public void close() {
if (tx != null && !tx.wasCommitted()) {
tx.rollback();
}
if (session != null) {
session.close();
}
}
private void commit() {
tx.commit();
}
private Query getQuery(final String queryString) {
return session.createQuery(queryString).setCacheable(true);
}
/**
* Do some database work.
*
* @param work
* the work instance
*/
private void doWork(Work work) {
session.doWork(work);
}
}
private BandwidthSubscriptionDao bandwidthSubscriptionDao;
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_NETWORK = "from BandwidthAllocation res where res.network = :network";
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_STATE = "from BandwidthAllocation res where res.status = :state";
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_SUBSCRIPTION_ID = "from BandwidthAllocation res where res.subscriptionDao.id = :subscriptionId";
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_SUBSCRIPTION_ID = "from BandwidthAllocation res where res.bandwidthSubscription.id = :subscriptionId";
private static final String GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET = "from DataSetMetaDataDao d where "
private static final String GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET = "from BandwidthDataSetUpdate d where "
+ "d.providerName = :providerName and "
+ "d.dataSetName = :dataSetName order by dataSetBaseTime desc";
private static final String GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = "from DataSetMetaDataDao d where "
private static final String GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = "from BandwidthDataSetUpdate d where "
+ "d.providerName = :providerName and "
+ "d.dataSetName = :dataSetName and "
+ "d.dataSetBaseTime = :dataSetBaseTime "
@ -138,23 +92,21 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
+ "alloc.network = :network and "
+ "alloc.endTime <= :endTime";
private static final String GET_SUBSCRIPTIONDAO = "from SubscriptionDao sub order by sub.baseReferenceTime asc";
private static final String GET_SUBSCRIPTIONDAO = "from BandwidthSubscription sub order by sub.baseReferenceTime asc";
private static final String GET_SUBSCRIPTIONDAO_BY_IDENTIFIER = "from SubscriptionDao sub where sub.id = :identifier";
private static final String GET_SUBSCRIPTIONDAO_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = "from SubscriptionDao sub where "
private static final String GET_SUBSCRIPTIONDAO_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = "from BandwidthSubscription sub where "
+ " sub.provider = :provider and "
+ " sub.dataSetName = :dataSetName and "
+ " sub.baseReferenceTime = :baseReferenceTime";
private static final String GET_SUBSCRIPTIONDAO_BY_REGISTRY_ID_AND_BASEREFERENCETIME = "from SubscriptionDao sub where "
private static final String GET_SUBSCRIPTIONDAO_BY_REGISTRY_ID_AND_BASEREFERENCETIME = "from BandwidthSubscription sub where "
+ "sub.registryId = :registryId and "
+ "sub.baseReferenceTime = :baseReferenceTime";
private static final String GET_SUBSCRIPTIONDAO_BY_REGISTRYID = "from SubscriptionDao sub where "
private static final String GET_SUBSCRIPTIONDAO_BY_REGISTRYID = "from BandwidthSubscription sub where "
+ "sub.registryId = :registryId";
private static final String GET_SUBSCRIPTIONDAO_BY_SUBSCRIPTION = "from SubscriptionDao sub where "
private static final String GET_SUBSCRIPTIONDAO_BY_SUBSCRIPTION = "from BandwidthSubscription sub where "
+ "sub.owner = :owner and "
+ "sub.provider = :provider and "
+ "sub.name = :name and " + "sub.dataSetName = :dataSetName";
@ -163,8 +115,8 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
+ "sr.id = :identifier";
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_BASE = "from SubscriptionRetrieval sr where "
+ " sr.subscriptionDao.id in ("
+ " select sub.id from SubscriptionDao sub where "
+ " sr.bandwidthSubscription.id in ("
+ " select sub.id from BandwidthSubscription sub where "
+ " sub.provider = :provider and "
+ " sub.dataSetName = :dataSetName";
@ -175,9 +127,9 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
+ " and sub.baseReferenceTime = :baseReferenceTime)";
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_SUBSCRIPTIONID = "from SubscriptionRetrieval sr where "
+ "sr.subscriptionDao.id = :subscriptionId";
+ "sr.bandwidthSubscription.id = :subscriptionId";
private static final HibernateBandwidthDao instance = new HibernateBandwidthDao();
private static HibernateBandwidthDao instance;
/**
* @return the instance
@ -186,8 +138,12 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
return instance;
}
private HibernateBandwidthDao() {
super(DaoConfig.forClass(HibernateBandwidthDao.class));
/**
* Constructor.
*/
public HibernateBandwidthDao() {
// TODO: Don't use a static instance
HibernateBandwidthDao.instance = this;
}
/**
@ -225,8 +181,8 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public List<DataSetMetaDataDao> getDataSetMetaDataDao(String providerName,
String dataSetName) {
public List<BandwidthDataSetUpdate> getBandwidthDataSetUpdate(
String providerName, String dataSetName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("providerName", providerName);
params.put("dataSetName", dataSetName);
@ -237,8 +193,8 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public List<DataSetMetaDataDao> getDataSetMetaDataDao(String providerName,
String dataSetName, Calendar baseReferenceTime) {
public List<BandwidthDataSetUpdate> getBandwidthDataSetUpdate(
String providerName, String dataSetName, Calendar baseReferenceTime) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("providerName", providerName);
params.put("dataSetName", dataSetName);
@ -268,24 +224,23 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* @return The Dialect.
*/
public Dialect getDialect() {
return ((SessionFactoryImpl) getSessionFactory()).getDialect();
return ((SessionFactoryImpl) template.getSessionFactory()).getDialect();
}
/**
* {@inheritDoc}
*/
@Override
public SubscriptionDao getSubscriptionDao(long identifier) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("identifier", identifier);
return uniqueResult(GET_SUBSCRIPTIONDAO_BY_IDENTIFIER, params);
public BandwidthSubscription getBandwidthSubscription(long identifier) {
return BandwidthSubscription.class.cast(template.get(
BandwidthSubscription.class, Long.valueOf(identifier)));
}
/**
* {@inheritDoc}
*/
@Override
public SubscriptionDao getSubscriptionDao(String registryId,
public BandwidthSubscription getBandwidthSubscription(String registryId,
Calendar baseReferenceTime) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("registryId", registryId);
@ -299,7 +254,8 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public List<SubscriptionDao> getSubscriptionDao(Subscription subscription) {
public List<BandwidthSubscription> getBandwidthSubscription(
Subscription subscription) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("owner", subscription.getOwner());
@ -313,7 +269,7 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public List<SubscriptionDao> getSubscriptionDaoByRegistryId(
public List<BandwidthSubscription> getBandwidthSubscriptionByRegistryId(
String registryId) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("registryId", registryId);
@ -361,18 +317,18 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public List<SubscriptionDao> getSubscriptions() {
Map<String, Object> params = new HashMap<String, Object>();
return query(GET_SUBSCRIPTIONDAO, params);
public List<BandwidthSubscription> getBandwidthSubscriptions() {
return template.find(GET_SUBSCRIPTIONDAO);
}
/**
* {@inheritDoc}
*/
@Override
public List<SubscriptionDao> getSubscriptions(String provider,
String dataSetName, Calendar baseReferenceTime) {
public List<BandwidthSubscription> getBandwidthSubscriptions(
String provider, String dataSetName, Calendar baseReferenceTime) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("provider", provider);
params.put("dataSetName", dataSetName);
@ -386,13 +342,13 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public DataSetMetaDataDao newDataSetMetaDataDao(
public BandwidthDataSetUpdate newBandwidthDataSetUpdate(
DataSetMetaData dataSetMetaData) {
DataSetMetaDataDao dao = BandwidthUtil
BandwidthDataSetUpdate dao = BandwidthUtil
.newDataSetMetaDataDao(dataSetMetaData);
persist(dao);
create(dao);
return dao;
}
@ -401,10 +357,12 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public SubscriptionDao newSubscriptionDao(Subscription subscription,
Calendar baseReferenceTime) throws SerializationException {
SubscriptionDao dao = BandwidthUtil.getSubscriptionDaoForSubscription(
subscription, baseReferenceTime);
public BandwidthSubscription newBandwidthSubscription(
Subscription subscription, Calendar baseReferenceTime)
throws SerializationException {
BandwidthSubscription dao = BandwidthUtil
.getSubscriptionDaoForSubscription(subscription,
baseReferenceTime);
store(dao);
return dao;
@ -426,7 +384,7 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
*/
@Override
public List<SubscriptionRetrieval> querySubscriptionRetrievals(
SubscriptionDao subscriptionDao) {
BandwidthSubscription subscriptionDao) {
return querySubscriptionRetrievals(subscriptionDao.getId());
}
@ -434,11 +392,11 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public void remove(SubscriptionDao subscriptionDao) {
public void remove(BandwidthSubscription subscriptionDao) {
List<BandwidthAllocation> bandwidthReservations = getBandwidthAllocations(subscriptionDao
.getIdentifier());
deleteAll(bandwidthReservations);
delete(subscriptionDao);
bandwidthAllocationDao.deleteAll(bandwidthReservations);
bandwidthSubscriptionDao.delete(subscriptionDao);
}
/**
@ -446,7 +404,7 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
*/
@Override
public void store(BandwidthAllocation bandwidthAllocation) {
persist(bandwidthAllocation);
update(bandwidthAllocation);
}
/**
@ -454,9 +412,8 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
*/
@Override
public void store(List<SubscriptionRetrieval> retrievals) {
for (SubscriptionRetrieval retrieval : retrievals) {
persist(retrieval);
store(retrieval);
}
}
@ -464,8 +421,9 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* {@inheritDoc}
*/
@Override
public void store(SubscriptionDao subscriptionDao) {
persist(subscriptionDao);
@Transactional
public void store(BandwidthSubscription subscriptionDao) {
template.save(subscriptionDao);
}
/**
@ -473,15 +431,15 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
*/
@Override
public void update(BandwidthAllocation allocation) {
persist(allocation);
createOrUpdate(allocation);
}
/**
* {@inheritDoc}
*/
@Override
public void update(SubscriptionDao dao) {
persist(dao);
public void update(BandwidthSubscription dao) {
template.update(dao);
}
/**
@ -489,69 +447,7 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
*/
@Override
public void update(SubscriptionRetrieval subscriptionRetrieval) {
persist(subscriptionRetrieval);
}
/**
* Internal convenience method for querying.
*
* @param <T>
* @param queryString
* @param params
* @return
*/
@SuppressWarnings("unchecked")
private <T extends Object> List<T> query(String queryString,
Map<String, Object> params) {
List<T> results = null;
BandwidthSessionContext ctx = SessionManager
.openSession(BandwidthSessionContext.class);
try {
Query query = ctx.getQuery(queryString);
if (params != null) {
for (String name : params.keySet()) {
Object val = params.get(name);
query.setParameter(name, val);
}
}
results = query.list();
ctx.commit();
} finally {
SessionManager.closeSession(BandwidthSessionContext.class);
}
return results;
}
/**
* Internal convenience method for returning a single result.
*
* @param <T>
* @param queryString
* @param params
* @return
*/
@SuppressWarnings("unchecked")
private <T extends Object> T uniqueResult(String queryString,
Map<String, Object> params) {
T results = null;
BandwidthSessionContext ctx = SessionManager
.openSession(BandwidthSessionContext.class);
try {
Query query = ctx.getQuery(queryString);
if (params != null) {
for (String name : params.keySet()) {
Object val = params.get(name);
query.setParameter(name, val);
}
}
results = (T) query.uniqueResult();
ctx.commit();
} finally {
SessionManager.closeSession(BandwidthSessionContext.class);
}
return results;
createOrUpdate(subscriptionRetrieval);
}
/**
@ -561,13 +457,38 @@ public class HibernateBandwidthDao extends CoreDao implements IBandwidthDao {
* The unit of work to do.
*/
public void doWork(Work work) {
BandwidthSessionContext ctx = SessionManager
.openSession(BandwidthSessionContext.class);
try {
ctx.doWork(work);
ctx.commit();
} finally {
SessionManager.closeSession(BandwidthSessionContext.class);
}
template.getSessionFactory().getCurrentSession().doWork(work);
}
/**
* @return the bandwidthAllocationDao
*/
public BandwidthAllocationDao getBandwidthAllocationDao() {
return bandwidthAllocationDao;
}
/**
* @param bandwidthAllocationDao
* the bandwidthAllocationDao to set
*/
public void setBandwidthAllocationDao(
BandwidthAllocationDao bandwidthAllocationDao) {
this.bandwidthAllocationDao = bandwidthAllocationDao;
}
/**
* @return the subscriptionDaoDao
*/
public BandwidthSubscriptionDao getBandwidthSubscriptionDao() {
return bandwidthSubscriptionDao;
}
/**
* @param subscriptionDaoDao
* the subscriptionDaoDao to set
*/
public void setBandwidthSubscriptionDao(
BandwidthSubscriptionDao bandwidthSubscriptionDao) {
this.bandwidthSubscriptionDao = bandwidthSubscriptionDao;
}
}

View file

@ -103,8 +103,8 @@ public class HibernateBandwidthDbInit implements IBandwidthDbInit {
// TODO: add package scanning or some other more elegant solution, but
// for now
// just to it ugly.
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation.class);

View file

@ -31,10 +31,10 @@ 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 DataSetMetaDataDao) on each
// 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.SubscriptionDao.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval.class);
aConfig.addAnnotatedClass(com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation.class);

View file

@ -2,13 +2,13 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.interfaces;
import java.util.List;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
/**
*
* Interface for Subscription aggregation and RetrievalRequest generation. Each
* implementation of this interface will examine the List of SubscriptionDao
* implementation of this interface will examine the List of BandwidthSubscription
* Objects provided and evaluate how to combine and/or subset those
* Subscriptions into SubscriptionRetrieval Objects.
*
@ -30,15 +30,15 @@ public interface ISubscriptionAggregator {
/**
* Generate a List of SubscriptionRetrieval Object for the provided
* SubscriptionDao Objects.
* BandwidthSubscription Objects.
*
* @param subscriptions
* A List of SubscriptionDao Objects to examine for retrieval.
* A List of BandwidthSubscription Objects to examine for retrieval.
*
* @return The SubscriptionRetrieval Objects used to fulfill the
* SubscriptionDao Objects provided.
* BandwidthSubscription Objects provided.
*/
List<SubscriptionRetrieval> aggregate(List<SubscriptionDao> subscriptions);
List<SubscriptionRetrieval> aggregate(List<BandwidthSubscription> subscriptions);
/**
* This method is called once all the SubscriptionRetrievals for a
@ -54,6 +54,6 @@ public interface ISubscriptionAggregator {
* @return A List of completed subscriptions, ready for notification to the
* user.
*/
List<SubscriptionDao> completeRetrieval(
List<BandwidthSubscription> completeRetrieval(
List<SubscriptionRetrieval> retrievals);
}

View file

@ -37,45 +37,39 @@ import com.raytheon.uf.edex.core.EDEXUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 11, 2012 1286 djohnson Initial creation
* Feb 06, 2013 1543 djohnson Changes to correspond with EventBus changes.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
class BandwidthAsyncEventBusFactory implements BandwidthEventBusFactory {
public class BandwidthAsyncEventBusFactory implements BandwidthEventBusFactory {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(BandwidthAsyncEventBusFactory.class);
/**
* On-demand, thread-safe initialization that delays the bandwidth bus
* creation until required.
*/
private static final class BandwidthAsyncEventBusConfigHolder {
private static final AsyncEventBus dataSetBus;
private final AsyncEventBus dataSetBus;
private static final AsyncEventBus subscriptionBus;
private final AsyncEventBus subscriptionBus;
private static final AsyncEventBus retrievalBus;
private final AsyncEventBus retrievalBus;
static {
BandwidthEventBusConfig config = (BandwidthEventBusConfig) EDEXUtil
.getESBComponent("BandwidthEventBusConfig");
// If no bean was defined, use the defaults defined in the
// class.
if (config == null) {
statusHandler
.info("No BandwidthEventBusConfig defined. Using defaults.");
config = new BandwidthEventBusConfig();
}
dataSetBus = new AsyncEventBus(Executors.newFixedThreadPool(config
.getDataSetMetaDataPoolSize()));
subscriptionBus = new AsyncEventBus(
Executors.newFixedThreadPool(config
.getSubscriptionPoolSize()));
retrievalBus = new AsyncEventBus(
Executors.newFixedThreadPool(config.getRetrievalPoolSize()));
public BandwidthAsyncEventBusFactory() {
BandwidthEventBusConfig config = (BandwidthEventBusConfig) EDEXUtil
.getESBComponent("BandwidthEventBusConfig");
// If no bean was defined, use the defaults defined in the
// class.
if (config == null) {
statusHandler
.info("No BandwidthEventBusConfig defined. Using defaults.");
config = new BandwidthEventBusConfig();
}
dataSetBus = new AsyncEventBus(Executors.newFixedThreadPool(config
.getDataSetMetaDataPoolSize()));
subscriptionBus = new AsyncEventBus(Executors.newFixedThreadPool(config
.getSubscriptionPoolSize()));
retrievalBus = new AsyncEventBus(Executors.newFixedThreadPool(config
.getRetrievalPoolSize()));
}
/**
@ -83,7 +77,7 @@ class BandwidthAsyncEventBusFactory implements BandwidthEventBusFactory {
*/
@Override
public EventBus getDataSetBus() {
return BandwidthAsyncEventBusConfigHolder.dataSetBus;
return dataSetBus;
}
/**
@ -91,7 +85,7 @@ class BandwidthAsyncEventBusFactory implements BandwidthEventBusFactory {
*/
@Override
public EventBus getSubscriptionBus() {
return BandwidthAsyncEventBusConfigHolder.subscriptionBus;
return subscriptionBus;
}
/**
@ -99,7 +93,7 @@ class BandwidthAsyncEventBusFactory implements BandwidthEventBusFactory {
*/
@Override
public EventBus getRetrievalBus() {
return BandwidthAsyncEventBusConfigHolder.retrievalBus;
return retrievalBus;
}
}

View file

@ -1,6 +1,7 @@
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
import com.google.common.annotations.VisibleForTesting;
import java.util.ServiceLoader;
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
@ -18,40 +19,39 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.SubscriptionRetriev
* Oct 02, 2012 726 jspinks Initial creation
* Oct 10, 2012 0726 djohnson Make buses final.
* Dec 11, 2012 1286 djohnson Create a factory to hold Google event buses.
* Feb 07, 2013 1543 djohnson Changed to behave similarly to EventBus.
*
* </pre>
*
* @version 1.0
*/
public class BandwidthEventBus {
@VisibleForTesting
static BandwidthEventBusFactory eventBusFactory = new BandwidthAsyncEventBusFactory();
/**
* Holder class which allows safe, concurrent, and on-demand creation of the
* EventBus. It also enforces the singleton contract.
*/
private static class EventBusHolder {
private static final com.google.common.eventbus.EventBus dataSetBus = eventBusFactory
.getDataSetBus();
private static final com.google.common.eventbus.EventBus subscriptionBus = eventBusFactory
.getSubscriptionBus();
private static final com.google.common.eventbus.EventBus retrievalBus = eventBusFactory
.getRetrievalBus();
private static final BandwidthEventBusFactory eventBusFactory;
static {
eventBusFactory = ServiceLoader
.<BandwidthEventBusFactory> load(BandwidthEventBusFactory.class)
.iterator().next();
}
private static final com.google.common.eventbus.EventBus dataSetBus = eventBusFactory
.getDataSetBus();
private static final com.google.common.eventbus.EventBus subscriptionBus = eventBusFactory
.getSubscriptionBus();
private static final com.google.common.eventbus.EventBus retrievalBus = eventBusFactory
.getRetrievalBus();
/**
* Registers an object with the event bus.
*
* @param subscriber
*/
public static void register(Object subscriber) {
EventBusHolder.retrievalBus.register(subscriber);
EventBusHolder.subscriptionBus.register(subscriber);
EventBusHolder.dataSetBus.register(subscriber);
BandwidthEventBus.retrievalBus.register(subscriber);
BandwidthEventBus.subscriptionBus.register(subscriber);
BandwidthEventBus.dataSetBus.register(subscriber);
}
/**
@ -60,9 +60,9 @@ public class BandwidthEventBus {
* @param subscriber
*/
public static void unregister(Object subscriber) {
EventBusHolder.retrievalBus.unregister(subscriber);
EventBusHolder.subscriptionBus.unregister(subscriber);
EventBusHolder.dataSetBus.unregister(subscriber);
BandwidthEventBus.retrievalBus.unregister(subscriber);
BandwidthEventBus.subscriptionBus.unregister(subscriber);
BandwidthEventBus.dataSetBus.unregister(subscriber);
}
/**
@ -72,15 +72,15 @@ public class BandwidthEventBus {
*/
public static void publish(Object object) {
if (object instanceof SubscriptionRetrieval) {
EventBusHolder.retrievalBus.post(object);
BandwidthEventBus.retrievalBus.post(object);
} else if (object instanceof SubscriptionRetrievalFulfilled) {
EventBusHolder.subscriptionBus.post(object);
BandwidthEventBus.subscriptionBus.post(object);
} else if (object instanceof DataSetMetaData) {
EventBusHolder.dataSetBus.post(object);
BandwidthEventBus.dataSetBus.post(object);
} else if (object instanceof Subscription) {
EventBusHolder.subscriptionBus.post(object);
BandwidthEventBus.subscriptionBus.post(object);
} else if (object instanceof RemoveRegistryEvent) {
EventBusHolder.subscriptionBus.post(object);
BandwidthEventBus.subscriptionBus.post(object);
} else {
throw new IllegalArgumentException("Object type ["
+ object.getClass().getName()

View file

@ -9,7 +9,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.ISubscriptionAggregator;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
@ -50,7 +50,7 @@ public class SimpleSubscriptionAggregator implements ISubscriptionAggregator {
@Override
public List<SubscriptionRetrieval> aggregate(
List<SubscriptionDao> subscriptions) {
List<BandwidthSubscription> subscriptions) {
List<SubscriptionRetrieval> subscriptionRetrievals = new ArrayList<SubscriptionRetrieval>();
@ -58,7 +58,7 @@ public class SimpleSubscriptionAggregator implements ISubscriptionAggregator {
// necessary retrievals without regards to 'sharing' retrievals across
// subscriptions.
for (SubscriptionDao subDao : subscriptions) {
for (BandwidthSubscription subDao : subscriptions) {
List<SubscriptionRetrieval> t = bandwidthDao
.querySubscriptionRetrievals(subDao.getIdentifier());
@ -70,7 +70,7 @@ public class SimpleSubscriptionAggregator implements ISubscriptionAggregator {
try {
SubscriptionRetrieval subscriptionRetrieval = new SubscriptionRetrieval();
// Link this SubscriptionRetrieval with the subscription.
subscriptionRetrieval.setSubscriptionDao(subDao);
subscriptionRetrieval.setBandwidthSubscription(subDao);
subscriptionRetrieval.setNetwork(subDao.getRoute());
subscriptionRetrieval
.setAgentType(SubscriptionRetrievalAgent.SUBSCRIPTION_AGENT);
@ -103,7 +103,7 @@ public class SimpleSubscriptionAggregator implements ISubscriptionAggregator {
statusHandler
.debug("Created ["
+ subscriptionRetrievals.size()
+ "] SubscriptionRetrieval Objects for SubscriptionDao ["
+ "] SubscriptionRetrieval Objects for BandwidthSubscription ["
+ subDao.getIdentifier() + "]");
}
}
@ -112,20 +112,20 @@ public class SimpleSubscriptionAggregator implements ISubscriptionAggregator {
}
@Override
public List<SubscriptionDao> completeRetrieval(
public List<BandwidthSubscription> completeRetrieval(
List<SubscriptionRetrieval> retrievals) {
List<SubscriptionDao> daos = new ArrayList<SubscriptionDao>();
List<BandwidthSubscription> daos = new ArrayList<BandwidthSubscription>();
// We know that only one SubscriptionRetrieval was created for each
// Subscription so there will not be any duplication of subscription
// ids.
for (SubscriptionRetrieval retrieval : retrievals) {
daos.add(bandwidthDao.getSubscriptionDao(retrieval
.getSubscriptionDao().getId()));
daos.add(bandwidthDao.getBandwidthSubscription(retrieval
.getBandwidthSubscription().getId()));
}
StringBuilder sb = new StringBuilder();
for (SubscriptionDao dao : daos) {
for (BandwidthSubscription dao : daos) {
sb.append("Fulfilled subscription [").append(dao.getIdentifier());
sb.append("][").append(dao.getRegistryId()).append("]\n");
}

View file

@ -71,7 +71,7 @@ public class RetrievalAgentManager {
this.agents = agents;
// set all Running state retrievals to pending
RetrievalDao dao = new RetrievalDao();
RetrievalDao dao = RetrievalDao.getInstance();
dao.resetRunningRetrievalsToPending();
}

View file

@ -150,7 +150,7 @@ public class RetrievalManager {
// fulfilled.
List<SubscriptionRetrieval> subscriptionRetrievals = bandwidthDao
.querySubscriptionRetrievals(subscriptionRetrieval
.getSubscriptionDao().getId());
.getBandwidthSubscription().getId());
boolean completed = true;
// If there is more than one check them all..

View file

@ -152,7 +152,7 @@ public class SubscriptionRetrievalAgent extends
private boolean generateRetrieval(SubscriptionBundle bundle,
Long subRetrievalKey) {
RetrievalDao dao = new RetrievalDao();
RetrievalDao dao = RetrievalDao.getInstance();
// process the bundle into a retrieval
RetrievalGenerator rg = ServiceTypeFactory.retrieveServiceFactory(
bundle.getProvider()).getRetrievalGenerator();

View file

@ -6,7 +6,7 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.util;
import java.util.List;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
/**
@ -60,14 +60,14 @@ public class AveragingAvailablityCalculator implements
public int getDataSetAvailablityDelay(Subscription subscription) {
// Use a default of 60 minutes..
int delay = DATASET_AVAILABLE_DEFAULT;
List<DataSetMetaDataDao> recs = bandwidthDao
.getDataSetMetaDataDao(subscription.getProvider(),
List<BandwidthDataSetUpdate> recs = bandwidthDao
.getBandwidthDataSetUpdate(subscription.getProvider(),
subscription.getDataSetName());
long totalLatency = 0;
int recordcount = 0;
// Average out a maximum of twenty records
for (DataSetMetaDataDao rec : recs) {
for (BandwidthDataSetUpdate rec : recs) {
long diff = (rec.getUpdateTime().getTimeInMillis() - rec
.getDataSetBaseTime().getTimeInMillis()) / 60000;
// Make sure some funky dates don't mess with the average..

View file

@ -36,9 +36,9 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
@ -242,7 +242,7 @@ public class BandwidthDaoUtil {
return subscriptionTimes;
}
public void remove(SubscriptionDao dao) {
public void remove(BandwidthSubscription dao) {
List<BandwidthAllocation> reservations = bandwidthDao
.getBandwidthAllocations(dao.getIdentifier());
@ -291,17 +291,17 @@ public class BandwidthDaoUtil {
AdhocSubscription adhoc, boolean mostRecent) {
AdhocSubscription retVal = null;
List<DataSetMetaDataDao> dataSetMetaDataUpdates = bandwidthDao
.getDataSetMetaDataDao(adhoc.getProvider(),
List<BandwidthDataSetUpdate> dataSetMetaDataUpdates = bandwidthDao
.getBandwidthDataSetUpdate(adhoc.getProvider(),
adhoc.getDataSetName());
if (!dataSetMetaDataUpdates.isEmpty()) {
// getDataSetMetaData returns the dataset meta-data in descending
// order of time, so walk the iterator finding the first subscribed
// to cycle
try {
DataSetMetaDataDao daoToUse = null;
BandwidthDataSetUpdate daoToUse = null;
Time adhocTime = adhoc.getTime();
for (DataSetMetaDataDao current : dataSetMetaDataUpdates) {
for (BandwidthDataSetUpdate current : dataSetMetaDataUpdates) {
if (mostRecent
|| adhocTime.getCycleTimes().contains(
current.getDataSetBaseTime().get(

View file

@ -9,8 +9,8 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
/**
* Bandwidth Manager utility methods.
@ -179,21 +179,21 @@ public class BandwidthUtil {
}
/**
* Create a new {@link SubscriptionDao} Object based on the
* Create a new {@link BandwidthSubscription} Object based on the
* {@link Subscription} and {@link Calendar} Objects provided.
*
* @param subscription
* the subscription
* @param baseReferenceTime
* the base reference time
* @return the {@link SubscriptionDao}
* @return the {@link BandwidthSubscription}
* @throws SerializationException
* on error serializing the subscription
*/
public static SubscriptionDao getSubscriptionDaoForSubscription(
public static BandwidthSubscription getSubscriptionDaoForSubscription(
Subscription subscription, Calendar baseReferenceTime)
throws SerializationException {
SubscriptionDao dao = new SubscriptionDao();
BandwidthSubscription dao = new BandwidthSubscription();
dao.setDataSetName(subscription.getDataSetName());
dao.setProvider(subscription.getProvider());
@ -213,16 +213,16 @@ public class BandwidthUtil {
}
/**
* Create a new {@link DataSetMetaDataDao} Object based on the
* Create a new {@link BandwidthDataSetUpdate} Object based on the
* {@link DataSetMetaData} Object provided.
*
* @param dataSetMetaData
* the metadata
* @return the dao
*/
public static DataSetMetaDataDao newDataSetMetaDataDao(
public static BandwidthDataSetUpdate newDataSetMetaDataDao(
DataSetMetaData dataSetMetaData) {
DataSetMetaDataDao dao = new DataSetMetaDataDao();
BandwidthDataSetUpdate dao = new BandwidthDataSetUpdate();
// Set the fields we need to have..
dao.setDataSetName(dataSetMetaData.getDataSetName());
dao.setProviderName(dataSetMetaData.getProviderName());

View file

@ -20,4 +20,5 @@ Require-Bundle: com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0",
com.raytheon.uf.common.registry.event;bundle-version="1.0.0",
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.service;bundle-version="1.0.0"
com.raytheon.uf.common.datadelivery.service;bundle-version="1.0.0",
com.raytheon.uf.common.util;bundle-version="1.12.1174"

View file

@ -13,6 +13,10 @@
<constructor-arg ref="ddRetrievalDatabaseProperties"/>
</bean>
<bean id="retrievalDao" class="com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="subNotifyTask" class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.SubscriptionNotifyTask" />
<!-- A RetrievalTask takes three constructor arguments:

View file

@ -65,7 +65,7 @@ public class RetrievalGenerationHandler implements IGenerateRetrieval {
public List<String> generateRetrieval(List<SubscriptionBundle> bundles) {
if (bundles != null) {
RetrievalDao dao = new RetrievalDao();
RetrievalDao dao = RetrievalDao.getInstance();
ArrayList<String> names = new ArrayList<String>(bundles.size());
for (SubscriptionBundle bundle : bundles) {

View file

@ -10,15 +10,15 @@ import org.hibernate.HibernateException;
import org.hibernate.LockOptions;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.dao.SessionManagedDao;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
/**
@ -32,18 +32,35 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 30, 2013 1543 djohnson Add SW history.
* Feb 07, 2013 1543 djohnson Use session management code.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class RetrievalDao extends CoreDao {
private static final transient IUFStatusHandler statusHandler = UFStatus
@Repository
@Transactional
// TODO: Split service functionality from DAO functionality
public class RetrievalDao extends SessionManagedDao {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(RetrievalDao.class);
private static RetrievalDao instance;
/**
* @return the instance
*/
public static RetrievalDao getInstance() {
return instance;
}
/**
* Constructor.
*/
public RetrievalDao() {
super(DaoConfig.forClass(RetrievalRequestRecord.class));
// TODO: Don't use a static instance
RetrievalDao.instance = this;
}
/**
@ -58,12 +75,10 @@ public class RetrievalDao extends CoreDao {
public RetrievalRequestRecord activateNextRetrievalRequest(Network network)
throws DataAccessLayerException {
Session sess = null;
Transaction tx = null;
RetrievalRequestRecord rval = null;
try {
sess = getHibernateTemplate().getSessionFactory().openSession();
tx = sess.beginTransaction();
sess = template.getSessionFactory().getCurrentSession();
final String minPriHql = "select min(rec.priority) from RetrievalRequestRecord rec "
+ "where rec.state = :statePending and rec.network = :network";
@ -147,25 +162,9 @@ public class RetrievalDao extends CoreDao {
rval.setState(State.RUNNING);
sess.update(rval);
}
tx.commit();
} catch (Exception e) {
throw new DataAccessLayerException(
"Failed looking up next retrieval", e);
} finally {
if (tx != null && !tx.wasCommitted()) {
try {
tx.rollback();
} catch (Exception e) {
// ignore
}
}
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
// ignore
}
}
}
return rval;
@ -173,35 +172,13 @@ public class RetrievalDao extends CoreDao {
public void completeRetrievalRequest(RetrievalRequestRecord rec)
throws DataAccessLayerException {
Session sess = null;
Transaction tx = null;
try {
sess = getHibernateTemplate().getSessionFactory().openSession();
tx = sess.beginTransaction();
sess.update(rec);
tx.commit();
update(rec);
} catch (HibernateException e) {
throw new DataAccessLayerException(
"Failed to update the database while changing the status on ["
+ rec.getId() + "]" + " to [" + rec.getState()
+ "]", e);
} finally {
if (tx != null && !tx.wasCommitted()) {
try {
tx.rollback();
} catch (Exception e) {
// ignore
}
}
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
// ignore
}
}
}
}
@ -211,38 +188,20 @@ public class RetrievalDao extends CoreDao {
* @return
*/
public boolean resetRunningRetrievalsToPending() {
Session sess = null;
Transaction tx = null;
boolean rval = true;
boolean rval = false;
try {
sess = getHibernateTemplate().getSessionFactory().openSession();
tx = sess.beginTransaction();
String hql = "update RetrievalRequestRecord rec set rec.state = :pendState where rec.state = :runState";
Query query = sess.createQuery(hql);
Query query = template.getSessionFactory().getCurrentSession()
.createQuery(hql);
query.setParameter("pendState", State.PENDING);
query.setParameter("runState", State.RUNNING);
query.executeUpdate();
tx.commit();
rval = true;
} catch (Exception e) {
rval = false;
statusHandler.error(
"Unable to reset old RUNNING retrievals to PENDING", e);
} finally {
if (tx != null && !tx.wasCommitted()) {
try {
tx.rollback();
} catch (Exception e) {
// ignore
}
}
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
// ignore
}
}
}
return rval;
@ -257,16 +216,13 @@ public class RetrievalDao extends CoreDao {
*/
public Map<State, Integer> getSubscriptionStateCounts(String subName)
throws DataAccessLayerException {
Session sess = null;
Transaction tx = null;
Map<State, Integer> rval = new HashMap<State, Integer>(8);
try {
sess = getHibernateTemplate().getSessionFactory().openSession();
tx = sess.beginTransaction();
String hql = "select rec.state, count(rec.id.subscriptionName) from RetrievalRequestRecord rec "
+ "where rec.id.subscriptionName = :subName group by rec.state";
Query query = sess.createQuery(hql);
Query query = template.getSessionFactory().getCurrentSession()
.createQuery(hql);
query.setString("subName", subName);
@SuppressWarnings("unchecked")
List<Object> result = query.list();
@ -284,26 +240,10 @@ public class RetrievalDao extends CoreDao {
}
}
}
tx.commit();
} catch (Exception e) {
throw new DataAccessLayerException(
"Failed check pending/running retrieval count for subscription ["
+ subName + "]", e);
} finally {
if (tx != null && !tx.wasCommitted()) {
try {
tx.rollback();
} catch (Exception e) {
// ignore
}
}
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
// ignore
}
}
}
return rval;
@ -312,75 +252,36 @@ public class RetrievalDao extends CoreDao {
@SuppressWarnings("unchecked")
public List<RetrievalRequestRecord> getFailedRequests(String subName)
throws DataAccessLayerException {
Session sess = null;
Transaction tx = null;
try {
sess = getHibernateTemplate().getSessionFactory().openSession();
tx = sess.beginTransaction();
Criteria query = sess.createCriteria(RetrievalRequestRecord.class);
Criteria query = template.getSessionFactory().getCurrentSession()
.createCriteria(RetrievalRequestRecord.class);
query.add(Restrictions.eq("state", State.FAILED));
query.add(Restrictions.eq("id.subscriptionName", subName));
List<RetrievalRequestRecord> rval = query.list();
tx.commit();
return rval;
} catch (Exception e) {
throw new DataAccessLayerException(
"Failed check pending/running retrieval count for subscription ["
+ subName + "]", e);
} finally {
if (tx != null && !tx.wasCommitted()) {
try {
tx.rollback();
} catch (Exception e) {
// ignore
}
}
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
// ignore
}
}
}
}
public boolean removeSubscription(String subName)
throws DataAccessLayerException {
Session sess = null;
Transaction tx = null;
boolean rval = false;
try {
sess = getHibernateTemplate().getSessionFactory().openSession();
tx = sess.beginTransaction();
String hql = "delete from RetrievalRequestRecord rec "
+ "where rec.id.subscriptionName = :subName";
Query query = sess.createQuery(hql);
Query query = template.getSessionFactory().getCurrentSession()
.createQuery(hql);
query.setString("subName", subName);
query.executeUpdate();
tx.commit();
rval = true;
} catch (Exception e) {
throw new DataAccessLayerException(
"Failed removing retrievals for subscription [" + subName
+ "]", e);
} finally {
if (tx != null && !tx.wasCommitted()) {
try {
tx.rollback();
} catch (Exception e) {
// ignore
}
}
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
// ignore
}
}
}
return rval;
}
@ -391,40 +292,19 @@ public class RetrievalDao extends CoreDao {
* @param subName
* @return
*/
// TODO: Change to use SessionManager code
@SuppressWarnings("unchecked")
public List<RetrievalRequestRecord> getRequests(String subName)
throws DataAccessLayerException {
Session sess = null;
Transaction tx = null;
try {
sess = getHibernateTemplate().getSessionFactory().openSession();
tx = sess.beginTransaction();
Criteria query = sess.createCriteria(RetrievalRequestRecord.class);
Criteria query = template.getSessionFactory().getCurrentSession()
.createCriteria(RetrievalRequestRecord.class);
query.add(Restrictions.eq("id.subscriptionName", subName));
List<RetrievalRequestRecord> rval = query.list();
tx.commit();
return rval;
} catch (Exception e) {
throw new DataAccessLayerException(
"Failed to return retrieval records for subscription ["
+ subName + "]", e);
} finally {
if (tx != null && !tx.wasCommitted()) {
try {
tx.rollback();
} catch (Exception e) {
// ignore
}
}
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
// ignore
}
}
}
}
@ -443,4 +323,5 @@ public class RetrievalDao extends CoreDao {
private void setQueryNetwork(Query query, Network network) {
query.setParameter("network", network);
}
}

View file

@ -24,6 +24,9 @@ import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
@ -38,6 +41,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 09, 2012 rjpeter Initial creation
* Feb 11, 2013 1543 djohnson Override equals/hashCode to remove Hibernate warning.
*
* </pre>
*
@ -46,7 +50,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
*/
@Embeddable
@DynamicSerialize
public class RetrievalRequestRecordPK implements IPersistableDataObject,
public class RetrievalRequestRecordPK implements
IPersistableDataObject<RetrievalRequestRecordPK>,
Serializable, ISerializableObject {
private static final long serialVersionUID = 1L;
@ -86,7 +91,7 @@ public class RetrievalRequestRecordPK implements IPersistableDataObject,
}
@Override
public Object getIdentifier() {
public RetrievalRequestRecordPK getIdentifier() {
return this;
}
@ -94,4 +99,26 @@ public class RetrievalRequestRecordPK implements IPersistableDataObject,
public String toString() {
return subscriptionName + "/" + index;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof RetrievalRequestRecordPK) {
RetrievalRequestRecordPK other = (RetrievalRequestRecordPK) obj;
EqualsBuilder builder = new EqualsBuilder();
builder.append(this.getIndex(), other.getIndex());
builder.append(this.getSubscriptionName(),
other.getSubscriptionName());
return builder.isEquals();
}
return super.equals(obj);
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
builder.append(this.getIndex());
builder.append(this.getSubscriptionName());
return builder.toHashCode();
}
}

View file

@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
@ -53,6 +54,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 01, 2013 1543 djohnson Initial creation
* Feb 07, 2013 1543 djohnson Expose process() for testing.
*
* </pre>
*
@ -83,7 +85,7 @@ public class PerformRetrievalPluginDataObjectsFinder implements
@Override
public RetrievalPluginDataObjects findRetrievalPluginDataObjects()
throws Exception {
RetrievalDao dao = new RetrievalDao();
RetrievalDao dao = RetrievalDao.getInstance();
RetrievalPluginDataObjects retVal = null;
ITimer timer = TimeUtil.getTimer();
@ -129,7 +131,8 @@ public class PerformRetrievalPluginDataObjectsFinder implements
/**
* The actual work gets done here.
*/
private RetrievalPluginDataObjects process(
@VisibleForTesting
RetrievalPluginDataObjects process(
RetrievalRequestRecord requestRecord) {
requestRecord.setState(State.FAILED);
List<RetrievalAttributePluginDataObjects> retrievalAttributePluginDataObjects = new ArrayList<RetrievalAttributePluginDataObjects>();
@ -150,7 +153,7 @@ public class PerformRetrievalPluginDataObjectsFinder implements
// Perform the actual retrievals and transforms to plugin data
// objects
final List<RetrievalAttribute> attributes = retrieval
.getAttribute();
.getAttributes();
for (RetrievalAttribute attXML : attributes) {
IRetrievalRequestBuilder request = pra

View file

@ -66,7 +66,8 @@ public class RetrievalHandler {
public RetrievalHandler(ScheduledExecutorService executorService,
List<RetrievalTask> retrievalTasks,
SubscriptionNotifyTask subNotifyTask) {
this(executorService, new RetrievalDao(), retrievalTasks, subNotifyTask);
this(executorService, RetrievalDao.getInstance(), retrievalTasks,
subNotifyTask);
}
@VisibleForTesting

View file

@ -65,7 +65,7 @@ public class RetrievalResponseCompleter implements IRetrievalResponseCompleter {
// update database
try {
RetrievalDao dao = new RetrievalDao();
RetrievalDao dao = RetrievalDao.getInstance();
dao.completeRetrievalRequest(retrieval);
notifyTask.checkNotify(retrieval);
} catch (DataAccessLayerException e) {

View file

@ -242,7 +242,7 @@ public class SubscriptionNotifyTask implements Runnable {
SubscriptionDelay subToCheck = subscriptionQueue.poll();
while (subToCheck != null) {
if (dao == null) {
dao = new RetrievalDao();
dao = RetrievalDao.getInstance();
}
Map<RetrievalRequestRecord.State, Integer> stateCounts = dao
@ -290,7 +290,7 @@ public class SubscriptionNotifyTask implements Runnable {
Retrieval retrieval = failedRec
.getRetrievalObj();
for (RetrievalAttribute att : retrieval
.getAttribute()) {
.getAttributes()) {
sb.append(att.getParameter().getName()
+ ", ");
}

View file

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.edex.util.Util;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.registry.Parameter;
@ -43,6 +44,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.util.ResponseProcessingUtilit
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 19, 2012 bsteffen Initial javadoc
* Feb 07, 2013 1543 djohnson Allow package-level overriding of methods for mocking in tests.
*
* </pre>
*
@ -129,11 +131,13 @@ public class GridMetadataAdapter extends AbstractMetadataAdapter {
* @param coverage
* @return
*/
private GridCoverage getCoverageFromCache(GridCoverage coverage) {
@VisibleForTesting
GridCoverage getCoverageFromCache(GridCoverage coverage) {
return ResponseProcessingUtilities.getCoverageFromCache(coverage);
}
private Level[] getLevels(RetrievalAttribute attXML) {
@VisibleForTesting
Level[] getLevels(RetrievalAttribute attXML) {
ArrayList<Level> levels = ResponseProcessingUtilities
.getOpenDAPGridLevels(attXML.getParameter().getLevels());
return levels.toArray(new Level[levels.size()]);

View file

@ -98,7 +98,7 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
OpenDAPTranslator translator;
try {
translator = new OpenDAPTranslator(response.getAttribute());
translator = getOpenDapTranslator(response.getAttribute());
} catch (InstantiationException e) {
throw new TranslationException(
"Unable to instantiate a required class!", e);
@ -122,4 +122,13 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
return map;
}
/**
* @param attribute
* @return
*/
OpenDAPTranslator getOpenDapTranslator(RetrievalAttribute attribute)
throws InstantiationException {
return new OpenDAPTranslator(attribute);
}
}

View file

@ -38,13 +38,14 @@ import com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 24, 2012 955 djohnson Initial creation
* Feb 07, 2013 1543 djohnson Allow sub-classes.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public final class OpenDapServiceFactory implements ServiceFactory {
public class OpenDapServiceFactory implements ServiceFactory {
private static final OpenDAPMetaDataParser PARSER = new OpenDAPMetaDataParser();

View file

@ -25,9 +25,11 @@ import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.DataTime;
@ -50,6 +52,7 @@ import dods.dap.PrimitiveVector;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 18, 2011 dhladky Initial creation
* Feb 07, 2013 1543 djohnson Allow package-level construction with explicit PDO class name.
*
* </pre>
*
@ -67,6 +70,11 @@ public class OpenDAPTranslator extends RetrievalTranslator {
super(attXML);
}
OpenDAPTranslator(RetrievalAttribute attXML, String className)
throws InstantiationException {
super(attXML, className);
}
public PluginDataObject[] asPluginDataObjects(DataDDS dds) {
PluginDataObject[] pdos = null;
@ -168,7 +176,8 @@ public class OpenDAPTranslator extends RetrievalTranslator {
for (int j = 0; j < numLevels; j++) {
PluginDataObject record = getPdo(bin);
record.setDataTime(dataTime);
record.constructDataURI();
constructDataUri(record);
int end = start + gridSize;
@ -191,9 +200,20 @@ public class OpenDAPTranslator extends RetrievalTranslator {
return records;
}
/**
* @param record
* @throws PluginException
*/
@VisibleForTesting
void constructDataUri(PluginDataObject record)
throws PluginException {
record.constructDataURI();
}
/**
* get # of subset times
*/
@Override
protected int getSubsetNumTimes() {
return ResponseProcessingUtilities.getOpenDAPGridNumTimes(attXML
@ -203,6 +223,7 @@ public class OpenDAPTranslator extends RetrievalTranslator {
/**
* get subset levels
*/
@Override
protected int getSubsetNumLevels() {
return ResponseProcessingUtilities.getOpenDAPGridNumLevels(attXML
@ -212,6 +233,7 @@ public class OpenDAPTranslator extends RetrievalTranslator {
/**
* get list of data times from subset
*/
@Override
protected ArrayList<DataTime> getTimes() {
return ResponseProcessingUtilities.getOpenDAPGridDataTimes(attXML

View file

@ -38,6 +38,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.metadata.adapters.AbstractMet
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 18, 2011 191 dhladky Initial creation
* Feb 07, 2013 1543 djohnson Allow overriding of methods for mocking in tests.
*
* </pre>
*
@ -51,7 +52,7 @@ public abstract class RetrievalTranslator implements IRetrievalTranslator {
protected RetrievalAttribute attXML;
private AbstractMetadataAdapter metadataAdapter;
protected AbstractMetadataAdapter metadataAdapter;
/**
* Used by all translators
@ -66,14 +67,30 @@ public abstract class RetrievalTranslator implements IRetrievalTranslator {
PluginFactory factory = PluginFactory.getInstance();
String clazz = factory.getPluginRecordClassName(getAttribute()
.getPlugin());
setPdoClass(clazz);
metadataAdapter = AbstractMetadataAdapter.getMetadataAdapter(
getPdoClass(), attXML);
configureFromPdoClassName(clazz);
} catch (Exception e) {
throw new InstantiationException(e.toString());
}
}
RetrievalTranslator(RetrievalAttribute attXML, String className)
throws InstantiationException {
this.attXML = attXML;
try {
configureFromPdoClassName(className);
} catch (Exception e) {
throw new InstantiationException(e.toString());
}
}
protected void configureFromPdoClassName(String className)
throws InstantiationException, ClassNotFoundException {
setPdoClass(className);
metadataAdapter = AbstractMetadataAdapter.getMetadataAdapter(
getPdoClass(), attXML);
}
@Override
public void setAttribute(RetrievalAttribute attXML) {
this.attXML = attXML;

View file

@ -1,6 +1,7 @@
package com.raytheon.uf.edex.registry.ebxml.services.util;
import com.raytheon.uf.common.event.Event;
import com.raytheon.uf.common.util.session.SessionContextFactory;
import com.raytheon.uf.common.util.session.SessionManager;
/**
@ -15,6 +16,7 @@ import com.raytheon.uf.common.util.session.SessionManager;
* ------------ ---------- ----------- --------------------------
* Mar 29, 2012 jspinks Initial creation
* Sep 27, 2012 1187 djohnson Split implementation between {@link SessionManager} and {@link RegistrySessionContext}.
* Feb 07, 2013 1543 djohnson Use SessionContextFactory instead of context class directly.
*
* </pre>
*
@ -23,11 +25,33 @@ import com.raytheon.uf.common.util.session.SessionManager;
*/
public class RegistrySessionManager {
/**
* {@link SessionContextFactory} for {@link RegistrySessionContext}
* instances.
*/
private static final SessionContextFactory<RegistrySessionContext> REGISTRY_SESSION_CONTEXT_FACTORY = new SessionContextFactory<RegistrySessionContext>() {
/**
* {@inheritDoc}
*/
@Override
public RegistrySessionContext getSessionContext() {
return new RegistrySessionContext();
}
/**
* {@inheritDoc}
*/
@Override
public Class<RegistrySessionContext> getSessionContextClass() {
return RegistrySessionContext.class;
}
};
/**
* Opens a Hibernate transaction and binds it to a thread
*/
public static void openSession() {
SessionManager.openSession(RegistrySessionContext.class);
SessionManager.openSession(REGISTRY_SESSION_CONTEXT_FACTORY);
}
/**
@ -36,7 +60,7 @@ public class RegistrySessionManager {
* processing.
*/
public static void closeSession() {
SessionManager.closeSession(RegistrySessionContext.class);
SessionManager.closeSession(REGISTRY_SESSION_CONTEXT_FACTORY);
}
/**
@ -51,10 +75,9 @@ public class RegistrySessionManager {
* @throws IllegalStateException
* If an attempt is made to add an event to an inactive Session.
*/
public static void postEvent(Event event)
throws IllegalStateException {
public static void postEvent(Event event) throws IllegalStateException {
RegistrySessionContext ctx = SessionManager
.getSessionContext(RegistrySessionContext.class);
.getSessionContext(REGISTRY_SESSION_CONTEXT_FACTORY);
ctx.postEvent(event);
}
}

View file

@ -75,5 +75,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.plugin.level"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.level"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.grid"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.log"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -34,13 +34,12 @@ import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionFixture;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.serialization.SerializationUtilTest;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.time.util.TimeUtilTest;
import com.raytheon.uf.common.util.PropertiesUtil;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthEventBusTest;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
@ -57,6 +56,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Oct 22, 2012 1286 djohnson Initial creation
* 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.
*
* </pre>
*
@ -102,9 +102,7 @@ public abstract class AbstractBandwidthManagerIntTest {
.getResourceAsStream("/com.raytheon.uf.edex.datadelivery.bandwidth.properties"));
System.getProperties().putAll(properties);
SerializationUtilTest.initSerializationUtil();
TimeUtilTest.freezeTime(TimeUtil.MILLIS_PER_DAY * 2);
BandwidthEventBusTest.initSynchronous();
}
@AfterClass
@ -118,7 +116,7 @@ public abstract class AbstractBandwidthManagerIntTest {
DatabaseUtil.start();
context = new ClassPathXmlApplicationContext(
IntegrationTestBandwidthManager.INTEGRATION_TEST_SPRING_FILES,
BandwidthManagerIntTest.class);
BandwidthManagerIntTest.class, EDEXUtil.getSpringContext());
bandwidthDao = (IBandwidthDao) context.getBean("bandwidthDao",
IBandwidthDao.class);
bandwidthManager = (BandwidthManager) context.getBean(

View file

@ -63,7 +63,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.time.util.TimeUtilTest;
import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthEventBus;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap;
@ -679,8 +679,8 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
bandwidthManager.schedule(subscription);
final List<SubscriptionDao> subscriptionDaos = bandwidthDao
.getSubscriptionDao(subscription);
final List<BandwidthSubscription> subscriptionDaos = bandwidthDao
.getBandwidthSubscription(subscription);
assertEquals("Incorrect number of subscription daos found.", 4,
subscriptionDaos.size());
@ -705,22 +705,22 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
Subscription subscription = createSubscriptionThatFillsUpABucket();
subscription.getTime().setCycleTimes(Arrays.asList(0, 12));
final Network network = subscription.getRoute();
final List<BandwidthAllocation> bandwidthAllocationsOrig = getRetrievalManagerAllocationsForNetwork(network);
assertEquals("Incorrect number of allocations found.", 0,
bandwidthAllocationsOrig.size());
bandwidthManager.schedule(subscription);
final Network network = subscription.getRoute();
final List<BandwidthAllocation> bandwidthAllocations = getRetrievalManagerAllocationsForNetwork(network);
assertEquals("Incorrect number of allocations found.", 4,
bandwidthAllocations.size());
System.out.println("allocs: " + bandwidthAllocations);
sendDeletedSubscriptionEvent(subscription);
final List<BandwidthAllocation> allocationsAfterDelete = getRetrievalManagerAllocationsForNetwork(network);
System.out.println("allocs: " + allocationsAfterDelete);
assertEquals(
"Expected all bandwidth allocations to have been deleted.", 0,
allocationsAfterDelete.size());
@ -776,8 +776,8 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
assertFalse("Shouldn't have been able to fully schedule.",
unableToSchedule.isEmpty());
final List<SubscriptionDao> subscriptionDaos = bandwidthDao
.getSubscriptionDao(subscription);
final List<BandwidthSubscription> subscriptionDaos = bandwidthDao
.getBandwidthSubscription(subscription);
assertEquals("Incorrect number of subscription daos found.", 0,
subscriptionDaos.size());
@ -812,7 +812,7 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
RemoveRegistryEvent event = new RemoveRegistryEvent(
subscription.getOwner(), subscription.getId());
event.setObjectType(DataDeliveryRegistryObjectTypes.SUBSCRIPTION);
BandwidthEventBus.publish(event);
bandwidthManager.subscriptionRemoved(event);
}
/**

View file

@ -79,7 +79,6 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
private static final int ONE_HUNDRED = 100;
private final BandwidthService service = new BandwidthService() {
@Override
protected Object sendRequest(IBandwidthRequest request)
@ -90,8 +89,8 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
.transformFromThrift(
Object.class,
SerializationUtil
.transformToThrift(BandwidthServiceIntTest.this.bandwidthManager
.handleRequest(request)));
.transformToThrift(BandwidthServiceIntTest.this.bandwidthManager
.handleRequest(request)));
}
};
@ -156,8 +155,8 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
public void testSaveBandwidthToServerUpdatesBandwidthMapFile() {
service.setBandwidthForNetworkInKilobytes(Network.OPSNET, ONE_HUNDRED);
File file = new IntegrationTestBandwidthContextFactory()
.getBandwidthMapConfigFile();
File file = IntegrationTestBandwidthContextFactory
.getIntegrationTestBandwidthMapConfigFile();
BandwidthMap map = BandwidthMap.load(file);
assertEquals(
"Expected the bandwidth to have been saved to the configuration file!",
@ -393,7 +392,7 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
service.schedule(subscription2);
BandwidthGraphData graphData = service.getBandwidthGraphData();
assertEquals("Incorrect number of subscriptions returned!", 2,
graphData.getNumberOfSubscriptions());
}
@ -451,7 +450,8 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
final TimeWindowData secondTimeWindow = subscriptionOneTimeWindows
.get(1);
final List<Long> firstWindowBinStartTimes = firstTimeWindow.getBinStartTimes();
final List<Long> firstWindowBinStartTimes = firstTimeWindow
.getBinStartTimes();
final List<Long> secondWindowBinStartTimes = secondTimeWindow
.getBinStartTimes();
@ -473,23 +473,22 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
assertEquals(
"Incorrect first bin start time in the first time window.",
expectedBinStartTime, firstWindowBinStartTimes
.get(0).longValue());
expectedBinStartTime, firstWindowBinStartTimes.get(0)
.longValue());
expectedBinStartTime += (TimeUtil.MILLIS_PER_MINUTE * 3);
assertEquals(
"Incorrect second bin start time in the first time window.",
expectedBinStartTime,
firstWindowBinStartTimes.get(1).longValue());
expectedBinStartTime, firstWindowBinStartTimes.get(1)
.longValue());
// Second retrieval window
expectedBinStartTime = iter.next().getStartTime().getTimeInMillis();
assertEquals(
"Incorrect first bin start time in the second time window.",
expectedBinStartTime,
secondWindowBinStartTimes
.get(0).longValue());
expectedBinStartTime, secondWindowBinStartTimes.get(0)
.longValue());
// The middle bucket was already reserved, so we went ahead six minutes
// and used that bucket
@ -497,8 +496,8 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
assertEquals(
"Incorrect second bin start time in the second time window.",
expectedBinStartTime,
secondWindowBinStartTimes.get(1).longValue());
expectedBinStartTime, secondWindowBinStartTimes.get(1)
.longValue());
}
@Test

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
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;
@ -45,6 +47,16 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
public class IntegrationTestBandwidthContextFactory extends
EdexBandwidthContextFactory {
/**
* Constructor, intentionally package-private.
*
* @param bandwidthDao
* the bandwidthDao
*/
IntegrationTestBandwidthContextFactory(IBandwidthDao bandwidthDao) {
super(bandwidthDao);
}
/**
* {@inheritDoc}
*/
@ -71,4 +83,14 @@ public class IntegrationTestBandwidthContextFactory extends
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)
.getBandwidthMapConfigFile();
}
}

View file

@ -0,0 +1 @@
com.raytheon.uf.common.serialization.TestJaxbableClassesLocator

View file

@ -0,0 +1 @@
com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthSyncEventBusFactory

View file

@ -5,18 +5,19 @@
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="bandwidthContextFactory"
class="com.raytheon.uf.edex.datadelivery.bandwidth.IntegrationTestBandwidthContextFactory" />
class="com.raytheon.uf.edex.datadelivery.bandwidth.IntegrationTestBandwidthContextFactory">
<constructor-arg ref="hibernateBandwidthDao" />
</bean>
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory">
<constructor-arg ref="bandwidthManager" />
</bean>
<bean id="registryManagerInstanceInitializer" class="java.lang.String">
<!-- required for depends-on -->
</bean>
<bean id="registerDataDeliveryHandlers" class="java.lang.String">
<!-- required for depends-on -->
</bean>

24
tests/resources/log4j.xml Normal file
View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n" />
</layout>
</appender>
<!-- Less verbose logging for COTS -->
<category name="org.springframework">
<priority value="WARN" />
</category>
<category name="org.hibernate">
<priority value="WARN" />
</category>
<root>
<priority value="INFO" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4j:configuration>

View file

@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver" />
@ -20,8 +23,8 @@
<list>
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation</value>
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval</value>
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao</value>
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao</value>
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate</value>
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription</value>
<value>com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord</value>
</list>
</property>
@ -29,9 +32,38 @@
<value>classpath:unit-test-hibernate.cfg.xml</value>
</property>
</bean>
<tx:annotation-driven transaction-manager="metadataTxManager" proxy-target-class="true" />
<bean id="metadataTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="bandwidthAllocationDao"
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthAllocationDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="bandwidthSubscriptionDao"
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthSubscriptionDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="hibernateBandwidthDao"
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
<property name="bandwidthAllocationDao" ref="bandwidthAllocationDao" />
<property name="bandwidthSubscriptionDao" ref="bandwidthSubscriptionDao" />
</bean>
<bean id="retrievalDao" class="com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao">
<property name="sessionFactory" ref="metadataSessionFactory" />
</bean>
<bean id="mockService" class="com.raytheon.uf.edex.database.dao.MockService">
<property name="sessionFactory" ref="metadataSessionFactory" />
<property name="bandwidthService" ref="hibernateBandwidthDao" />
</bean>
</beans>

View file

@ -5,6 +5,10 @@
<hibernate-configuration>
<session-factory>
<property name="connection.release_mode">
after_transaction
</property>
<property name="hibernate.id.new_generator_mappings">true</property>
<property name="hibernate.show_sql">false</property>
<property name="hibenate.format_sql">false</property>
<property name="hibernate.use_sql_comments">false</property>

View file

@ -29,7 +29,6 @@ import javax.xml.bind.JAXBException;
import org.junit.Test;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.serialization.SerializationUtilTest;
import com.raytheon.uf.common.time.util.ImmutableDate;
import com.raytheon.uf.common.util.TestUtil;
@ -45,6 +44,7 @@ import com.raytheon.uf.common.util.TestUtil;
* Jul 31, 2012 djohnson Initial creation
* Sep 07, 2012 1102 djohnson Add test for compareTo.
* Sep 19, 2012 726 jspinks Add test for Date serialization
* Feb 07, 2013 1543 djohnson Remove unnecessary test setup methods.
*
* </pre>
*
@ -83,8 +83,7 @@ public class DataSetMetaDataTest {
@Test
public void testDateSerialization() throws JAXBException {
SerializationUtilTest.initSerializationUtil();
OpenDapGriddedDataSetMetaData objectUnderTest =
OpenDapGriddedDataSetMetaDataFixture.INSTANCE.get();

View file

@ -32,7 +32,8 @@ import com.raytheon.uf.common.util.AbstractFixture;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 07, 2012 1104 djohnson Initial creation
* Dec 07, 2012 1104 djohnson Initial creation
* Feb 07, 2013 1543 djohnson Missing value must be a numeric value.
*
* </pre>
*
@ -63,7 +64,7 @@ public class ParameterFixture extends AbstractFixture<Parameter> {
obj.setLevels(LevelsFixture.INSTANCE.get(seedValue));
obj.setLevelType(Arrays.asList(DataLevelTypeFixture.INSTANCE
.get(seedValue)));
obj.setMissingValue("missingValue" + seedValue);
obj.setMissingValue("" + seedValue);
obj.setName("name" + seedValue);
return obj;

View file

@ -38,6 +38,7 @@ import com.raytheon.uf.common.util.AbstractFixture;
* ------------ ---------- ----------- --------------------------
* Sep 28, 2012 1187 djohnson Initial creation
* Oct 16, 2012 0726 djohnson Use {@link TimeUtil}.
* Feb 07, 2013 1543 djohnson Set request start/end dates.
*
* </pre>
*
@ -71,6 +72,8 @@ public class TimeFixture extends AbstractFixture<Time> {
time.setStartDate(new ImmutableDate(TimeUtil.currentTimeMillis()));
time.setEndDate(new ImmutableDate(TimeUtil.currentTimeMillis()
+ seedValue));
time.setRequestStartAsDate(time.getStartDate());
time.setRequestEndAsDate(time.getEndDate());
} catch (ParseException e) {
throw new RuntimeException(e);
}

View file

@ -55,6 +55,7 @@ import com.raytheon.uf.common.util.TestUtil;
* Sep 11, 2012 1102 djohnson Initial creation
* Sep 14, 2012 1169 djohnson Test dynamically serializing a throwable.
* Sep 28, 2012 1187 djohnson Test dynamically serializing with a field level adapter.
* Feb 07, 2013 1543 djohnson Moved JAXB_CLASSES into ServiceLoader implementation class.
*
* </pre>
*
@ -68,63 +69,8 @@ public class SerializationUtilTest {
private static String PROVIDER_XML;
/**
* An ever-growing list of JAXB-able classes. Basically this array should
* duplicate the contents of the ISerializableContext files at some point
* (as they are needed).
*/
private static final Class<?>[] JAXB_CLASSES = {
com.raytheon.uf.common.datadelivery.registry.AdhocSubscription.class,
com.raytheon.uf.common.datadelivery.registry.Connection.class,
com.raytheon.uf.common.datadelivery.registry.Coverage.class,
com.raytheon.uf.common.datadelivery.registry.DataLevelType.class,
com.raytheon.uf.common.datadelivery.registry.DataSet.class,
com.raytheon.uf.common.datadelivery.registry.DataSetMetaData.class,
com.raytheon.uf.common.datadelivery.registry.DataSetName.class,
com.raytheon.uf.common.datadelivery.registry.Ensemble.class,
com.raytheon.uf.common.datadelivery.registry.GriddedCoverage.class,
com.raytheon.uf.common.datadelivery.registry.GriddedDataSet.class,
com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData.class,
com.raytheon.uf.common.datadelivery.registry.GriddedProjection.class,
com.raytheon.uf.common.datadelivery.registry.GroupDefinition.class,
com.raytheon.uf.common.datadelivery.registry.Levels.class,
com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSet.class,
com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaData.class,
com.raytheon.uf.common.datadelivery.registry.Parameter.class,
com.raytheon.uf.common.datadelivery.registry.ParameterLevel.class,
com.raytheon.uf.common.datadelivery.registry.PendingSubscription.class,
com.raytheon.uf.common.datadelivery.registry.Projection.class,
com.raytheon.uf.common.datadelivery.registry.Provider.class,
com.raytheon.uf.common.datadelivery.registry.Subscription.class,
com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle.class,
com.raytheon.uf.common.datadelivery.registry.Time.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterLookup.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterConfig.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation.class,
com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.ServiceConfig.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.UnitLookup.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.LevelLookup.class };
/**
* Enables the use of {@link SerializationUtil} within tests.
*/
public static void initSerializationUtil() {
try {
SerializationUtil.jaxbManager = new JAXBManager(JAXB_CLASSES);
} catch (JAXBException e) {
throw new IllegalStateException(
"Unable to install the jaxbManager instance in SerializationUtil!");
}
}
@BeforeClass
public static void staticSetup() throws JAXBException {
SerializationUtilTest.initSerializationUtil();
PROVIDER = ProviderFixture.INSTANCE.get();
PROVIDER_XML = SerializationUtil.marshalToXml(PROVIDER);
}

View file

@ -0,0 +1,102 @@
/**
* 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.common.serialization;
import java.util.Arrays;
import java.util.List;
import org.junit.Ignore;
/**
* Implementation of {@link IJaxbableClassesLocator} that returns a static list
* of classes.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 06, 2013 1543 djohnson Moved out of SerializationUtilTest.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Ignore
public class TestJaxbableClassesLocator implements IJaxbableClassesLocator {
/**
* An ever-growing list of JAXB-able classes. Basically this array should
* duplicate the contents of the ISerializableContext files at some point
* (as they are needed).
*/
@SuppressWarnings("rawtypes")
private static final List JAXB_CLASSES;
static {
Class<?>[] array = new Class<?>[] {
com.raytheon.uf.common.datadelivery.registry.AdhocSubscription.class,
com.raytheon.uf.common.datadelivery.registry.Connection.class,
com.raytheon.uf.common.datadelivery.registry.Coverage.class,
com.raytheon.uf.common.datadelivery.registry.DataLevelType.class,
com.raytheon.uf.common.datadelivery.registry.DataSet.class,
com.raytheon.uf.common.datadelivery.registry.DataSetMetaData.class,
com.raytheon.uf.common.datadelivery.registry.DataSetName.class,
com.raytheon.uf.common.datadelivery.registry.Ensemble.class,
com.raytheon.uf.common.datadelivery.registry.GriddedCoverage.class,
com.raytheon.uf.common.datadelivery.registry.GriddedDataSet.class,
com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData.class,
com.raytheon.uf.common.datadelivery.registry.GriddedProjection.class,
com.raytheon.uf.common.datadelivery.registry.GroupDefinition.class,
com.raytheon.uf.common.datadelivery.registry.Levels.class,
com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSet.class,
com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaData.class,
com.raytheon.uf.common.datadelivery.registry.Parameter.class,
com.raytheon.uf.common.datadelivery.registry.ParameterLevel.class,
com.raytheon.uf.common.datadelivery.registry.PendingSubscription.class,
com.raytheon.uf.common.datadelivery.registry.Projection.class,
com.raytheon.uf.common.datadelivery.registry.Provider.class,
com.raytheon.uf.common.datadelivery.registry.Subscription.class,
com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle.class,
com.raytheon.uf.common.datadelivery.registry.Time.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterLookup.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterConfig.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval.class,
com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation.class,
com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.ServiceConfig.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.UnitLookup.class,
com.raytheon.uf.common.datadelivery.retrieval.xml.LevelLookup.class };
JAXB_CLASSES = Arrays.asList(array);
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public List<Class<ISerializableObject>> getJaxbables() {
return JAXB_CLASSES;
}
}

View file

@ -34,6 +34,7 @@ import org.junit.Test;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 27, 2012 1187 djohnson Initial creation
* Feb 07, 2013 1543 djohnson Accepts SessionContextFactory implementation now.
*
* </pre>
*
@ -43,29 +44,41 @@ import org.junit.Test;
public class SessionManagerTest {
private static final SessionContextFactory<StubSessionContext> CTX_FACTORY = new SessionContextFactory<StubSessionContext>() {
@Override
public Class<StubSessionContext> getSessionContextClass() {
return StubSessionContext.class;
}
@Override
public StubSessionContext getSessionContext() {
return new StubSessionContext();
}
};
@Test
public void testSessionIsOpenedOnFirstRequest() {
try {
SessionManager.openSession(StubSessionContext.class);
SessionManager.openSession(CTX_FACTORY);
StubSessionContext ctx = SessionManager
.getSessionContext(StubSessionContext.class);
.getSessionContext(CTX_FACTORY);
assertTrue(
"The context should have been opened on first open request!",
ctx.opened);
} finally {
SessionManager.closeSession(StubSessionContext.class);
SessionManager.closeSession(CTX_FACTORY);
}
}
@Test
public void testSessionIsClosedWhenRequesterCloses() {
SessionManager.openSession(StubSessionContext.class);
SessionManager.openSession(CTX_FACTORY);
StubSessionContext ctx = SessionManager
.getSessionContext(StubSessionContext.class);
StubSessionContext ctx = SessionManager.getSessionContext(CTX_FACTORY);
SessionManager.closeSession(StubSessionContext.class);
SessionManager.closeSession(CTX_FACTORY);
assertTrue("The context should have been closed when requested!",
ctx.closed);
@ -74,23 +87,22 @@ public class SessionManagerTest {
@Test
public void testSessionIsNotClosedUntilOriginalRequesterCloses() {
// Two opens requested (e.g. second would come from a called class)
SessionManager.openSession(StubSessionContext.class);
SessionManager.openSession(StubSessionContext.class);
SessionManager.openSession(CTX_FACTORY);
SessionManager.openSession(CTX_FACTORY);
StubSessionContext ctx = SessionManager
.getSessionContext(StubSessionContext.class);
StubSessionContext ctx = SessionManager.getSessionContext(CTX_FACTORY);
assertFalse(
"Session should not be closed before anyone called close!.",
ctx.closed);
// First close
SessionManager.closeSession(StubSessionContext.class);
SessionManager.closeSession(CTX_FACTORY);
assertFalse(
"Session should not be closed until everyone requesting open requested close!.",
ctx.closed);
// Second close
SessionManager.closeSession(StubSessionContext.class);
SessionManager.closeSession(CTX_FACTORY);
assertTrue(
"Session should be closed after everyone requesting open requested close!.",
ctx.closed);

View file

@ -45,7 +45,7 @@ import com.raytheon.uf.edex.core.EDEXUtil;
public final class DatabaseUtil {
private static IUFStatusHandler statusHandler = UFStatus
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(DatabaseUtil.class);
private static final String UNIT_TEST_DB_BEANS_XML = "/unit-test-db-beans.xml";
@ -66,14 +66,14 @@ public final class DatabaseUtil {
* and {@link #shutdown()} should be called in the @After section.
*/
public static void start() {
statusHandler.info("Starting the in-memory database.");
statusHandler.debug("Starting the in-memory database.");
originalApplicationContext = EDEXUtil.getSpringContext();
applicationContext = new ClassPathXmlApplicationContext(
UNIT_TEST_DB_BEANS_XML, DatabaseUtil.class);
new EDEXUtil().setApplicationContext(applicationContext);
statusHandler.info("Started.");
statusHandler.debug("Started.");
}
/**
@ -81,7 +81,7 @@ public final class DatabaseUtil {
* test.
*/
public static void shutdown() {
statusHandler.info("Stopping the in-memory database.");
statusHandler.debug("Stopping the in-memory database.");
if (applicationContext != null) {
applicationContext.close();
@ -90,6 +90,6 @@ public final class DatabaseUtil {
new EDEXUtil().setApplicationContext(originalApplicationContext);
originalApplicationContext = null;
statusHandler.info("Stopped.");
statusHandler.debug("Stopped.");
}
}

View file

@ -0,0 +1,99 @@
/**
* 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.database.dao;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao;
/**
* Mock service which uses another service.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 08, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Transactional
@Repository
public class MockService extends SessionManagedDao {
private HibernateBandwidthDao bandwidthService;
/**
* @param config
*/
public MockService() {
}
/**
* Stores a {@link BandwidthSubscription} then attempts an invalid transactable
* operation.
*
* @param subscription
* the subscription
*/
public void storeStuffThenThrowException(BandwidthSubscription subscription) {
SpringTransactionUtils
.transactionRequired("storeStuffThenThrowException");
storeStuff(subscription);
// This will throw the exception
bandwidthService.store((BandwidthAllocation) null);
}
/**
* Stores a {@link BandwidthSubscription}, not throwing an exception as long as
* the subscription object is valid.
*
* @param subscription
* the subscription
*/
public void storeStuffAndNotThrowException(BandwidthSubscription subscription) {
SpringTransactionUtils
.transactionRequired("storeStuffAndNotThrowException");
storeStuff(subscription);
}
private void storeStuff(BandwidthSubscription subscription) {
bandwidthService.store(subscription);
}
/**
* @param bandwidthService
* the bandwidthService to set
*/
public void setBandwidthService(HibernateBandwidthDao bandwidthService) {
this.bandwidthService = bandwidthService;
}
}

View file

@ -0,0 +1,103 @@
/**
* 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.database.dao;
import static org.hamcrest.Matchers.emptyCollectionOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDaoFixture;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrievalFixture;
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao;
/**
* Test {@link SessionManagedService}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 08, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class SessionManagedServiceTest {
private final BandwidthSubscription subscription = SubscriptionDaoFixture.INSTANCE
.get();
private final SubscriptionRetrieval subscriptionRetrieval = SubscriptionRetrievalFixture.INSTANCE
.get();
{
subscriptionRetrieval.setBandwidthSubscription(subscription);
}
private HibernateBandwidthDao bandwidthService;
private MockService service;
@Before
public void setUp() {
DatabaseUtil.start();
service = (MockService) EDEXUtil.getESBComponent("mockService");
bandwidthService = (HibernateBandwidthDao) EDEXUtil
.getESBComponent("hibernateBandwidthDao");
}
@After
public void tearDown() {
DatabaseUtil.shutdown();
}
@Test
public void exceptionThrownInDaoWillRollbackTransaction() {
try {
service.storeStuffThenThrowException(subscription);
} catch (RuntimeException e) {
// Expected
}
assertThat(bandwidthService.getBandwidthSubscriptions(),
is(emptyCollectionOf(BandwidthSubscription.class)));
}
@Test
public void noExceptionThrownInDaoWillCommitTransaction() {
service.storeStuffAndNotThrowException(subscription);
assertThat(bandwidthService.getBandwidthSubscriptions(),
is(not(emptyCollectionOf(BandwidthSubscription.class))));
}
}

View file

@ -0,0 +1,96 @@
package com.raytheon.uf.edex.database.dao;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
*
* Utility class for debugging Spring transactions.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 11, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public final class SpringTransactionUtils {
/**
* Set this property to "true" in your Run Configuration to enable Spring
* transaction debugging.
*/
public static final String SPRING_TRANSACTION_DEBUGGING_FLAG = "spring.transaction.debugging";
private static final boolean transactionDebugging = Boolean
.getBoolean(SPRING_TRANSACTION_DEBUGGING_FLAG);
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(SpringTransactionUtils.class);
/**
* Log the status of a Spring transaction.
*
* @param message
* the unique message identifying the location in code
*/
public static void showTransactionStatus(String message) {
if (!transactionDebugging) {
return;
}
statusHandler.info(((isTransactionActive()) ? "[+] " : "[-] ") + message);
}
/**
* Verify a Spring transaction is active.
*
* @param message
* the unique message identifying the location in code
* @throws IllegalStateException
* if a transaction is not active
*/
public static void transactionRequired(String message)
throws IllegalStateException {
if (!transactionDebugging) {
return;
}
showTransactionStatus(message);
if (!isTransactionActive()) {
throw new IllegalStateException(
"Transaction required but not active [" + message + "]");
}
}
/**
* Check whether a Spring transaction is active.
*
* @return true if a Spring transaction is active
*/
private static boolean isTransactionActive() {
try {
return TransactionSynchronizationManager
.isActualTransactionActive();
} catch (Throwable t) {
throw new IllegalStateException(
"Unable to determine transaction status", t);
}
}
/**
* Prevent construction.
*/
private SpringTransactionUtils() {
}
}

View file

@ -43,9 +43,9 @@ import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocationFixture;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.DataSetMetaDataDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrievalFixture;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
@ -91,7 +91,7 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get();
alloc1.setNetwork(Network.OPSNET);
dao.store(alloc1.getSubscriptionDao());
dao.store(alloc1.getBandwidthSubscription());
dao.store(alloc1);
assertEquals(1, dao.getBandwidthAllocations(Network.OPSNET).size());
@ -103,7 +103,7 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get();
alloc1.setNetwork(Network.SBN);
dao.store(alloc1.getSubscriptionDao());
dao.store(alloc1.getBandwidthSubscription());
dao.store(alloc1);
assertTrue(
@ -117,7 +117,7 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get();
alloc1.setNetwork(Network.OPSNET);
dao.store(alloc1.getSubscriptionDao());
dao.store(alloc1.getBandwidthSubscription());
dao.store(alloc1);
assertNotSame("Should have returned clones of the originals", alloc1,
@ -131,13 +131,13 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
SubscriptionRetrieval ret2 = SubscriptionRetrievalFixture.INSTANCE
.get(2);
dao.store(ret1.getSubscriptionDao());
dao.store(ret2.getSubscriptionDao());
dao.store(ret1.getBandwidthSubscription());
dao.store(ret2.getBandwidthSubscription());
dao.store(ret1);
dao.store(ret2);
List<BandwidthAllocation> results = dao.getBandwidthAllocations(ret2
.getSubscriptionDao().getId());
.getBandwidthSubscription().getId());
assertEquals("Should have only returned one object!", 1, results.size());
final BandwidthAllocation result = results.iterator().next();
assertNotSame(ret2, result);
@ -153,8 +153,8 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get(2);
ret2.setStatus(RetrievalStatus.PROCESSING);
dao.store(ret1.getSubscriptionDao());
dao.store(ret2.getSubscriptionDao());
dao.store(ret1.getBandwidthSubscription());
dao.store(ret2.getBandwidthSubscription());
dao.store(ret1);
dao.store(ret2);
@ -172,13 +172,13 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get(1);
OpenDapGriddedDataSetMetaData metaData2 = OpenDapGriddedDataSetMetaDataFixture.INSTANCE
.get(2);
DataSetMetaDataDao metaDataDao = dao.newDataSetMetaDataDao(metaData);
dao.newDataSetMetaDataDao(metaData2);
BandwidthDataSetUpdate metaDataDao = dao.newBandwidthDataSetUpdate(metaData);
dao.newBandwidthDataSetUpdate(metaData2);
final List<DataSetMetaDataDao> results = dao.getDataSetMetaDataDao(
final List<BandwidthDataSetUpdate> results = dao.getBandwidthDataSetUpdate(
metaData.getProviderName(), metaData.getDataSetName());
assertEquals(1, results.size());
final DataSetMetaDataDao result = results.iterator().next();
final BandwidthDataSetUpdate result = results.iterator().next();
assertEquals(metaData.getDataSetName(), result.getDataSetName());
assertNotSame(metaDataDao, result);
}
@ -191,17 +191,17 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get(1);
metaData2.setDate(new ImmutableDate(metaData.getDate().getTime()
+ TimeUtil.MILLIS_PER_YEAR));
DataSetMetaDataDao metaDataDao = dao.newDataSetMetaDataDao(metaData);
dao.newDataSetMetaDataDao(metaData2);
BandwidthDataSetUpdate metaDataDao = dao.newBandwidthDataSetUpdate(metaData);
dao.newBandwidthDataSetUpdate(metaData2);
final ImmutableDate date1 = metaData.getDate();
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
final List<DataSetMetaDataDao> results = dao.getDataSetMetaDataDao(
final List<BandwidthDataSetUpdate> results = dao.getBandwidthDataSetUpdate(
metaData.getProviderName(), metaData.getDataSetName(), cal);
assertEquals(1, results.size());
final DataSetMetaDataDao result = results.iterator().next();
final BandwidthDataSetUpdate result = results.iterator().next();
assertEquals(metaData.getDataSetName(), result.getDataSetName());
assertNotSame(metaDataDao, result);
}
@ -225,8 +225,8 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
alloc2.setStatus(RetrievalStatus.DEFERRED);
alloc2.setEndTime(after);
dao.store(alloc1.getSubscriptionDao());
dao.store(alloc2.getSubscriptionDao());
dao.store(alloc1.getBandwidthSubscription());
dao.store(alloc2.getBandwidthSubscription());
dao.store(alloc1);
dao.store(alloc2);
@ -255,8 +255,8 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
alloc2.setStatus(RetrievalStatus.FULFILLED);
alloc2.setEndTime(now);
dao.store(alloc1.getSubscriptionDao());
dao.store(alloc2.getSubscriptionDao());
dao.store(alloc1.getBandwidthSubscription());
dao.store(alloc2.getBandwidthSubscription());
dao.store(alloc1);
dao.store(alloc2);
@ -285,8 +285,8 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
alloc2.setStatus(RetrievalStatus.DEFERRED);
alloc2.setEndTime(now);
dao.store(alloc1.getSubscriptionDao());
dao.store(alloc2.getSubscriptionDao());
dao.store(alloc1.getBandwidthSubscription());
dao.store(alloc2.getBandwidthSubscription());
dao.store(alloc1);
dao.store(alloc2);
@ -304,15 +304,15 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
throws SerializationException {
final Calendar now = BandwidthUtil.now();
// Identical except for their identifier fields
SubscriptionDao entity1 = dao.newSubscriptionDao(
BandwidthSubscription entity1 = dao.newBandwidthSubscription(
SubscriptionFixture.INSTANCE.get(), now);
SubscriptionDao entity2 = dao.newSubscriptionDao(
BandwidthSubscription entity2 = dao.newBandwidthSubscription(
SubscriptionFixture.INSTANCE.get(), now);
assertFalse("The two objects should not have the same id!",
entity1.getId() == entity2.getId());
final SubscriptionDao result = dao.getSubscriptionDao(entity2.getId());
final BandwidthSubscription result = dao.getBandwidthSubscription(entity2.getId());
assertEquals("Should have returned the entity with the correct id!",
entity2.getId(), result.getId());
assertNotSame(entity2, result);
@ -323,14 +323,14 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
throws SerializationException {
final Calendar now = BandwidthUtil.now();
// Identical except for their base reference times and ids
dao.newSubscriptionDao(SubscriptionFixture.INSTANCE.get(), now);
dao.newBandwidthSubscription(SubscriptionFixture.INSTANCE.get(), now);
final Calendar later = BandwidthUtil.now();
later.add(Calendar.HOUR, 1);
SubscriptionDao entity2 = dao.newSubscriptionDao(
BandwidthSubscription entity2 = dao.newBandwidthSubscription(
SubscriptionFixture.INSTANCE.get(), later);
final SubscriptionDao result = dao.getSubscriptionDao(
final BandwidthSubscription result = dao.getBandwidthSubscription(
entity2.getRegistryId(), later);
assertEquals(
"Should have returned the entity with the correct registryId!",
@ -346,8 +346,8 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
SubscriptionRetrieval entity2 = SubscriptionRetrievalFixture.INSTANCE
.get(1);
dao.store(entity1.getSubscriptionDao());
dao.store(entity2.getSubscriptionDao());
dao.store(entity1.getBandwidthSubscription());
dao.store(entity2.getBandwidthSubscription());
dao.store(Arrays.asList(entity1, entity2));
final SubscriptionRetrieval result = dao
@ -369,9 +369,9 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
SubscriptionRetrieval entity3 = SubscriptionRetrievalFixture.INSTANCE
.get(2);
dao.store(entity1.getSubscriptionDao());
dao.store(entity2.getSubscriptionDao());
dao.store(entity3.getSubscriptionDao());
dao.store(entity1.getBandwidthSubscription());
dao.store(entity2.getBandwidthSubscription());
dao.store(entity3.getBandwidthSubscription());
dao.store(Arrays.asList(entity1, entity2, entity3));
final Subscription subscription = entity1.getSubscription();
@ -407,9 +407,9 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get(2);
// Still have to persist the actual subscription daos
final SubscriptionDao subDao1 = entity1.getSubscriptionDao();
final SubscriptionDao subDao2 = entity2.getSubscriptionDao();
final SubscriptionDao subDao3 = entity3.getSubscriptionDao();
final BandwidthSubscription subDao1 = entity1.getBandwidthSubscription();
final BandwidthSubscription subDao2 = entity2.getBandwidthSubscription();
final BandwidthSubscription subDao3 = entity3.getBandwidthSubscription();
// Give each a unique time
final Calendar one = BandwidthUtil.now();
@ -423,11 +423,11 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
// This persists the subscription dao objects and sets them on the
// retrievals
entity1.setSubscriptionDao(dao.newSubscriptionDao(
entity1.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao1.getSubscription(), subDao1.getBaseReferenceTime()));
entity2.setSubscriptionDao(dao.newSubscriptionDao(
entity2.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao2.getSubscription(), subDao2.getBaseReferenceTime()));
entity3.setSubscriptionDao(dao.newSubscriptionDao(
entity3.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao3.getSubscription(), subDao3.getBaseReferenceTime()));
dao.store(Arrays.asList(entity1, entity2, entity3));
@ -450,18 +450,18 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
subscription.getDataSetName(),
resultSubscription.getDataSetName());
TestUtil.assertCalEquals("Wrong base reference time found.", one,
result.getSubscriptionDao().getBaseReferenceTime());
result.getBandwidthSubscription().getBaseReferenceTime());
}
@Test
public void testGetSubscriptionsReturnsClones()
throws SerializationException {
SubscriptionDao entity = dao.newSubscriptionDao(
BandwidthSubscription entity = dao.newBandwidthSubscription(
SubscriptionFixture.INSTANCE.get(), BandwidthUtil.now());
List<SubscriptionDao> results = dao.getSubscriptions();
List<BandwidthSubscription> results = dao.getBandwidthSubscriptions();
assertEquals(1, results.size());
SubscriptionDao result = results.iterator().next();
BandwidthSubscription result = results.iterator().next();
assertNotSame(entity, result);
}
@ -475,17 +475,17 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
three.add(Calendar.HOUR, 1);
// Three entities all the same except for base reference time
dao.newSubscriptionDao(SubscriptionFixture.INSTANCE.get(), one);
dao.newSubscriptionDao(SubscriptionFixture.INSTANCE.get(), two);
SubscriptionDao entity3 = dao.newSubscriptionDao(
dao.newBandwidthSubscription(SubscriptionFixture.INSTANCE.get(), one);
dao.newBandwidthSubscription(SubscriptionFixture.INSTANCE.get(), two);
BandwidthSubscription entity3 = dao.newBandwidthSubscription(
SubscriptionFixture.INSTANCE.get(), three);
// One with same base reference time but different provider/dataset
dao.newSubscriptionDao(SubscriptionFixture.INSTANCE.get(2), three);
dao.newBandwidthSubscription(SubscriptionFixture.INSTANCE.get(2), three);
List<SubscriptionDao> results = dao.getSubscriptions(
List<BandwidthSubscription> results = dao.getBandwidthSubscriptions(
entity3.getProvider(), entity3.getDataSetName(), three);
assertEquals(1, results.size());
SubscriptionDao result = results.iterator().next();
BandwidthSubscription result = results.iterator().next();
assertEquals("Incorrect provider", entity3.getProvider(),
result.getProvider());
assertEquals("Incorrect provider", entity3.getDataSetName(),
@ -508,22 +508,22 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get(2);
// Still have to persist the actual subscription daos
final SubscriptionDao subDao1 = entity1.getSubscriptionDao();
final SubscriptionDao subDao2 = entity2.getSubscriptionDao();
final SubscriptionDao subDao3 = entity3.getSubscriptionDao();
final BandwidthSubscription subDao1 = entity1.getBandwidthSubscription();
final BandwidthSubscription subDao2 = entity2.getBandwidthSubscription();
final BandwidthSubscription subDao3 = entity3.getBandwidthSubscription();
// This persists the subscription dao objects and sets them on the
// retrievals
entity1.setSubscriptionDao(dao.newSubscriptionDao(
entity1.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao1.getSubscription(), subDao1.getBaseReferenceTime()));
entity2.setSubscriptionDao(dao.newSubscriptionDao(
entity2.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao2.getSubscription(), subDao2.getBaseReferenceTime()));
entity3.setSubscriptionDao(dao.newSubscriptionDao(
entity3.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao3.getSubscription(), subDao3.getBaseReferenceTime()));
dao.store(Arrays.asList(entity1, entity2, entity3));
final List<SubscriptionRetrieval> results = dao
.querySubscriptionRetrievals(entity2.getSubscriptionDao()
.querySubscriptionRetrievals(entity2.getBandwidthSubscription()
.getId());
assertEquals(
"Should have returned one entity for the subscriptionDao id!",
@ -547,22 +547,22 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get(2);
// Still have to persist the actual subscription daos
final SubscriptionDao subDao1 = entity1.getSubscriptionDao();
final SubscriptionDao subDao2 = entity2.getSubscriptionDao();
final SubscriptionDao subDao3 = entity3.getSubscriptionDao();
final BandwidthSubscription subDao1 = entity1.getBandwidthSubscription();
final BandwidthSubscription subDao2 = entity2.getBandwidthSubscription();
final BandwidthSubscription subDao3 = entity3.getBandwidthSubscription();
// This persists the subscription dao objects and sets them on the
// retrievals
entity1.setSubscriptionDao(dao.newSubscriptionDao(
entity1.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao1.getSubscription(), subDao1.getBaseReferenceTime()));
entity2.setSubscriptionDao(dao.newSubscriptionDao(
entity2.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao2.getSubscription(), subDao2.getBaseReferenceTime()));
entity3.setSubscriptionDao(dao.newSubscriptionDao(
entity3.setBandwidthSubscription(dao.newBandwidthSubscription(
subDao3.getSubscription(), subDao3.getBaseReferenceTime()));
dao.store(Arrays.asList(entity1, entity2, entity3));
final List<SubscriptionRetrieval> results = dao
.querySubscriptionRetrievals(entity2.getSubscriptionDao());
.querySubscriptionRetrievals(entity2.getBandwidthSubscription());
assertEquals(
"Should have returned one entity for the subscriptionDao!", 1,
results.size());
@ -575,20 +575,20 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
@Test
public void testRemoveSubscriptionDao() throws SerializationException {
final Calendar now = BandwidthUtil.now();
dao.newSubscriptionDao(SubscriptionFixture.INSTANCE.get(1), now);
final SubscriptionDao entity2 = dao.newSubscriptionDao(
dao.newBandwidthSubscription(SubscriptionFixture.INSTANCE.get(1), now);
final BandwidthSubscription entity2 = dao.newBandwidthSubscription(
SubscriptionFixture.INSTANCE.get(2), now);
dao.newSubscriptionDao(SubscriptionFixture.INSTANCE.get(3), now);
dao.newBandwidthSubscription(SubscriptionFixture.INSTANCE.get(3), now);
assertEquals("Incorrect number of entities found!", 3, dao
.getSubscriptions().size());
.getBandwidthSubscriptions().size());
dao.remove(entity2);
final List<SubscriptionDao> subscriptions = dao.getSubscriptions();
final List<BandwidthSubscription> subscriptions = dao.getBandwidthSubscriptions();
assertEquals("Incorrect number of entities found!", 2,
subscriptions.size());
for (SubscriptionDao subscription : subscriptions) {
for (BandwidthSubscription subscription : subscriptions) {
assertFalse(
"Should not have found the entity with the removed entity's id",
subscription.getId() == entity2.getId());
@ -614,7 +614,7 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
.get();
assertEquals("The id should not have been set!",
BandwidthUtil.DEFAULT_IDENTIFIER, entity.getId());
dao.store(entity.getSubscriptionDao());
dao.store(entity.getBandwidthSubscription());
dao.store(Arrays.asList(entity));
assertFalse("The id should have been set!",
BandwidthUtil.DEFAULT_IDENTIFIER == entity.getId());
@ -640,14 +640,14 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
public void testUpdateSubscriptionDao() throws SerializationException {
final long estimatedSize = 25L;
SubscriptionDao entity = dao.newSubscriptionDao(
BandwidthSubscription entity = dao.newBandwidthSubscription(
SubscriptionFixture.INSTANCE.get(), BandwidthUtil.now());
entity.setEstimatedSize(estimatedSize);
dao.update(entity);
assertEquals("Expected the entity to have been updated!", 25L, dao
.getSubscriptions().iterator().next().getEstimatedSize());
.getBandwidthSubscriptions().iterator().next().getEstimatedSize());
}
@Test
@ -656,7 +656,7 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
SubscriptionRetrieval entity = SubscriptionRetrievalFixture.INSTANCE
.get();
dao.store(entity.getSubscriptionDao());
dao.store(entity.getBandwidthSubscription());
dao.store(entity);
entity.setEstimatedSize(estimatedSize);
dao.update(entity);

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.edex.datadelivery.bandwidth;
import org.junit.After;
import org.junit.Before;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao;
@ -66,7 +67,8 @@ public class HibernateBandwidthDaoTest extends
*/
@Override
protected HibernateBandwidthDao getDao() {
return HibernateBandwidthDao.getInstance();
return (HibernateBandwidthDao) EDEXUtil
.getESBComponent("hibernateBandwidthDao");
}
}

View file

@ -41,13 +41,13 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
*/
public class DataSetMetaDataDaoFixture extends
AbstractFixture<DataSetMetaDataDao> {
AbstractFixture<BandwidthDataSetUpdate> {
/**
* {@inheritDoc}
*/
@Override
public DataSetMetaDataDao get(long seedValue) {
public BandwidthDataSetUpdate get(long seedValue) {
return BandwidthUtil
.newDataSetMetaDataDao(OpenDapGriddedDataSetMetaDataFixture.INSTANCE
.get(seedValue));

View file

@ -42,7 +42,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* @version 1.0
*/
public class SubscriptionDaoFixture extends AbstractFixture<SubscriptionDao> {
public class SubscriptionDaoFixture extends AbstractFixture<BandwidthSubscription> {
public static final SubscriptionDaoFixture INSTANCE = new SubscriptionDaoFixture();
@ -57,7 +57,7 @@ public class SubscriptionDaoFixture extends AbstractFixture<SubscriptionDao> {
* {@inheritDoc}
*/
@Override
public SubscriptionDao get(long seedValue) {
public BandwidthSubscription get(long seedValue) {
Subscription sub = SubscriptionFixture.INSTANCE.get(seedValue);
try {
return BandwidthUtil.getSubscriptionDaoForSubscription(sub,

View file

@ -60,11 +60,11 @@ public class SubscriptionRetrievalFixture extends
entity.setDataSetAvailablityDelay(0);
entity.setAgentType(SubscriptionRetrievalAgent.SUBSCRIPTION_AGENT);
entity.setEstimatedSize(seedValue);
entity.setSubscriptionDao(SubscriptionDaoFixture.INSTANCE
entity.setBandwidthSubscription(SubscriptionDaoFixture.INSTANCE
.get(seedValue));
entity.setSubscriptionLatency(0);
try {
entity.setSubscription(entity.getSubscriptionDao()
entity.setSubscription(entity.getBandwidthSubscription()
.getSubscription());
} catch (SerializationException e) {
throw new RuntimeException(e);

View file

@ -1,96 +0,0 @@
/**
* 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.junit.Assert.assertEquals;
import java.util.Calendar;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.SubscriptionRetrievalAgent;
/**
* Test {@link HibernateBandwidthDaoTest}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 10, 2012 0726 djohnson Initial creation
* Oct 26, 2012 1286 djohnson Renamed.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class HibernateBandwidthDaoTest {
@Before
public void setUp() throws Exception {
DatabaseUtil.start();
}
@After
public void tearDown() throws Exception {
DatabaseUtil.shutdown();
}
@Test
public void testPersistence() throws Exception {
final IBandwidthDao dao = HibernateBandwidthDao.getInstance();
BandwidthAllocation allocation = new BandwidthAllocation();
allocation.setAgentType(SubscriptionRetrievalAgent.SUBSCRIPTION_AGENT);
allocation.setEndTime(Calendar.getInstance());
allocation.setEstimatedSize(-1L);
allocation.setPriority(1.0D);
allocation.setNetwork(Network.OPSNET);
allocation.setStartTime(Calendar.getInstance());
dao.store(allocation);
List<BandwidthAllocation> allocations = dao
.getBandwidthAllocations(Network.OPSNET);
assertEquals("Expected to find one persisted entity!", 1,
allocations.size());
}
@Test
public void testLookup() throws Exception {
final IBandwidthDao dao = HibernateBandwidthDao.getInstance();
List<BandwidthAllocation> allocations = dao
.getBandwidthAllocations(Network.OPSNET);
assertEquals("Expected not to find a persisted entity!", 0,
allocations.size());
}
}

View file

@ -19,12 +19,10 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
import org.junit.Ignore;
import com.google.common.eventbus.EventBus;
/**
* Test {@link BandwidthEventBus}.
* A synchronous event bus factory for the bandwidth manager.
*
* <pre>
*
@ -32,39 +30,38 @@ import com.google.common.eventbus.EventBus;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 11, 2012 djohnson Initial creation
* Feb 05, 2013 1580 mpduff EventBus refactor.
* Feb 06, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Ignore
public class BandwidthEventBusTest {
public class BandwidthSyncEventBusFactory implements BandwidthEventBusFactory {
/**
* Create a synchronous {@link BandwidthEventBus}.
* {@inheritDoc}
*/
public static void initSynchronous() {
// Need the normal event bus synchronous as well
BandwidthEventBus.eventBusFactory = new BandwidthEventBusFactory() {
@Override
public EventBus getSubscriptionBus() {
return new EventBus();
}
@Override
public EventBus getSubscriptionBus() {
return new EventBus();
}
@Override
public EventBus getRetrievalBus() {
return new EventBus();
}
@Override
public EventBus getDataSetBus() {
return new EventBus();
}
};
/**
* {@inheritDoc}
*/
@Override
public EventBus getRetrievalBus() {
return new EventBus();
}
/**
* {@inheritDoc}
*/
@Override
public EventBus getDataSetBus() {
return new EventBus();
}
}

View file

@ -1,292 +0,0 @@
/**
* 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.retrieval;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.junit.Ignore;
import com.google.common.collect.Maps;
import com.raytheon.uf.common.datadelivery.registry.Collection;
import com.raytheon.uf.common.datadelivery.registry.DataSet;
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverageFixture;
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaDataFixture;
import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.edex.datadelivery.retrieval.IExtractMetaData;
import com.raytheon.uf.edex.datadelivery.retrieval.IParseMetaData;
import com.raytheon.uf.edex.datadelivery.retrieval.LinkStore;
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory;
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse;
import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
/**
* {@link ServiceFactory} that doesn't do much, just create a fake retrieval.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 30, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Ignore
public class MockServiceFactory extends RetrievalGenerator implements
ServiceFactory, IExtractMetaData, IParseMetaData {
/**
* Just returns a retrieval.
*/
public class MockRetrievalAdapter extends RetrievalAdapter implements
IRetrievalRequestBuilder {
/**
* {@inheritDoc}
*/
@Override
public IRetrievalRequestBuilder createRequestMessage(
RetrievalAttribute prxml) {
return this;
}
/**
* {@inheritDoc}
*/
@Override
public RetrievalResponse performRequest(IRetrievalRequestBuilder request) {
return new RetrievalResponse(request.getAttribute());
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, PluginDataObject[]> processResponse(
IRetrievalResponse response) throws TranslationException {
final Map<String, PluginDataObject[]> map = Maps.newHashMap();
map.put("grid", new PluginDataObject[] { new GridRecord() });
return map;
}
/**
* {@inheritDoc}
*/
@Override
public String processTime(Time prtXML) {
return "someTime";
}
/**
* {@inheritDoc}
*/
@Override
public String processCoverage() {
return "someCoverage";
}
/**
* {@inheritDoc}
*/
@Override
public String getRequest() {
return "someRequest";
}
/**
* {@inheritDoc}
*/
@Override
public RetrievalAttribute getAttribute() {
return new RetrievalAttribute();
}
}
/**
* @param serviceType
*/
public MockServiceFactory(ServiceType serviceType) {
super(serviceType);
}
/**
* @param provider
*/
public MockServiceFactory(Provider provider) {
this(provider.getServiceType());
}
/**
* {@inheritDoc}
*/
@Override
public IExtractMetaData getExtractor() {
return this;
}
/**
* {@inheritDoc}
*/
@Override
public IParseMetaData getParser(Date lastUpdate) {
return this;
}
/**
* {@inheritDoc}
*/
@Override
public RetrievalGenerator getRetrievalGenerator() {
return this;
}
/**
* {@inheritDoc}
*/
@Override
public List<DataSetMetaData> parseMetaData(Provider provider,
LinkStore store, Collection collection, String dataDateFormat) {
return Arrays
.<DataSetMetaData> asList(OpenDapGriddedDataSetMetaDataFixture.INSTANCE
.get());
}
/**
* {@inheritDoc}
*/
@Override
public void storeMetaData(List<DataSetMetaData> metaDatas, DataSet dataSet) {
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, Object> extractMetaData() throws Exception {
return Collections.emptyMap();
}
/**
* {@inheritDoc}
*/
@Override
public boolean checkLastUpdate(Date lastUpdate) {
return true;
}
/**
* {@inheritDoc}
*/
@Override
public void setDataDate() throws Exception {
}
/**
* {@inheritDoc}
*/
@Override
public Date getDataDate() {
return new Date();
}
/**
* {@inheritDoc}
*/
@Override
public void setUrl(String url) {
}
/**
* {@inheritDoc}
*/
@Override
public List<Retrieval> buildRetrieval(SubscriptionBundle bundle) {
final Subscription subscription = bundle.getSubscription();
Retrieval retrieval = new Retrieval();
retrieval.setConnection(bundle.getConnection());
retrieval.setNetwork(subscription.getRoute());
retrieval.setOwner(subscription.getOwner());
retrieval.setProviderType(bundle.getProvider().getProviderType()
.iterator().next());
retrieval.setServiceType(this.getServiceType());
retrieval.setSubscriptionName(subscription.getName());
retrieval.setSubscriptionType(getSubscriptionType(subscription));
final ArrayList<RetrievalAttribute> attributes = new ArrayList<RetrievalAttribute>();
attributes.add(getAttribute(bundle));
attributes.add(getAttribute(bundle));
retrieval.setAttribute(attributes);
return Arrays.asList(retrieval);
}
/**
* @param bundle
* @return
*/
private RetrievalAttribute getAttribute(SubscriptionBundle bundle) {
RetrievalAttribute attribute = new RetrievalAttribute();
attribute.setCoverage(GriddedCoverageFixture.INSTANCE.get());
attribute.setSubName(bundle.getSubscription().getName());
attribute.setProvider(bundle.getProvider().getName());
return attribute;
}
/**
* {@inheritDoc}
*/
@Override
protected RetrievalAdapter getServiceRetrievalAdapter() {
return new MockRetrievalAdapter();
}
/**
* {@inheritDoc}
*/
@Override
protected Subscription removeDuplicates(Subscription sub) {
return sub;
}
}

View file

@ -120,7 +120,7 @@ public class SubscriptionRetrievalAgentTest {
};
agent.processAllocation(subscriptionRetrieval);
RetrievalDao dao = new RetrievalDao();
RetrievalDao dao = RetrievalDao.getInstance();
final List<RetrievalRequestRecord> requests = dao
.getRequests(subscription.getName());
assertThat(requests,

View file

@ -22,12 +22,14 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.retrieval;
import org.junit.Ignore;
import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.edex.datadelivery.retrieval.IServiceFactoryLookup;
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory;
import com.raytheon.uf.edex.datadelivery.retrieval.opendap.MockOpenDapServiceFactory;
/**
* Implementation of {@link IServiceFactoryLookup} that doesn't really
* go out to the internet.
* Implementation of {@link IServiceFactoryLookup} that doesn't really go out to
* the internet.
*
* <pre>
*
@ -43,13 +45,20 @@ import com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory;
* @version 1.0
*/
@Ignore
public class TestRetrievalServiceFactoryLookup implements
IServiceFactoryLookup {
public class TestRetrievalServiceFactoryLookup implements IServiceFactoryLookup {
/**
* {@inheritDoc}
*/
@Override
public ServiceFactory getProviderServiceFactory(Provider provider) {
return new MockServiceFactory(provider);
final ServiceType serviceType = provider.getServiceType();
switch (serviceType) {
case OPENDAP:
return new MockOpenDapServiceFactory(provider);
default:
throw new IllegalArgumentException(
"Don't know how to handle service [" + serviceType + "]");
}
}
}

View file

@ -32,20 +32,18 @@ import java.util.TreeSet;
import org.junit.After;
import org.junit.Before;
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.SubscriptionFixture;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.serialization.SerializationUtilTest;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.time.util.TimeUtilTest;
import com.raytheon.uf.edex.datadelivery.bandwidth.IntegrationTestBandwidthContextFactory;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan;
@ -61,6 +59,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2012 1286 djohnson Initial creation
* Feb 07, 2013 1543 djohnson Remove unnecessary test setup methods.
*
* </pre>
*
@ -81,11 +80,6 @@ public class BandwidthDaoUtilTest {
private RetrievalPlan plan;
@BeforeClass
public static void staticSetup() {
SerializationUtilTest.initSerializationUtil();
}
@Before
public void setUp() {
TimeUtilTest.freezeTime(TimeUtil.MILLIS_PER_DAY * 2);
@ -97,8 +91,8 @@ public class BandwidthDaoUtilTest {
dataSetAvailabilityCalculator);
PathManagerFactoryTest.initLocalization();
map = BandwidthMap.load(new IntegrationTestBandwidthContextFactory()
.getBandwidthMapConfigFile());
map = BandwidthMap.load(IntegrationTestBandwidthContextFactory
.getIntegrationTestBandwidthMapConfigFile());
plan = new RetrievalPlan(Network.OPSNET, map, mockDao);
}
@ -143,7 +137,7 @@ public class BandwidthDaoUtilTest {
@Test
public void testRemoveDoesNotRemoveFromRetrievalPlanIfInUnscheduledState() {
SubscriptionDao subDao = new SubscriptionDao();
BandwidthSubscription subDao = new BandwidthSubscription();
subDao.setId(10L);
BandwidthAllocation alloc1 = new BandwidthAllocation();

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.retrieval.handlers;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
/**
* Test {@link PerformRetrievalPluginDataObjectsFinder}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 06, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class PerformRetrievalPluginDataObjectsFinderTest {
private static final String EXCEPTION_MESSAGE = "thrown on purpose";
private final Retrieval retrievalThatThrowsException = new Retrieval() {
private static final long serialVersionUID = 1109443017002028345L;
@Override
public ArrayList<RetrievalAttribute> getAttributes() {
throw new IllegalStateException(EXCEPTION_MESSAGE);
}
/**
* {@inheritDoc}
*/
@Override
public ServiceType getServiceType() {
return ServiceType.OPENDAP;
}
};
private final RetrievalRequestRecord retrievalThatDoesNotThrowException = RetrievalRequestRecordFixture.INSTANCE
.get();
@Before
public void setUp() {
PathManagerFactoryTest.initLocalization();
}
@Test
public void requestRecordSetToFailedStatusWhenExceptionThrown()
throws SerializationException {
RetrievalRequestRecord record = new RetrievalRequestRecord();
try {
record.setRetrievalObj(retrievalThatThrowsException);
} catch (NullPointerException npe) {
// This is expected because we create an anonymous
// retrievalThatThrowsException
// instance, and can't dynamically serialize it
}
processRetrieval(record);
assertThat(record.getState(), is(equalTo(State.FAILED)));
}
@Test
public void requestRecordSetToCompletedStatusWhenNoExceptionThrown()
throws SerializationException {
processRetrieval(retrievalThatDoesNotThrowException);
assertThat(retrievalThatDoesNotThrowException.getState(),
is(equalTo(State.COMPLETED)));
}
private void processRetrieval(RetrievalRequestRecord retrieval) {
final PerformRetrievalPluginDataObjectsFinder pluginDataObjectsFinder = new PerformRetrievalPluginDataObjectsFinder(
Network.OPSNET);
pluginDataObjectsFinder.process(retrieval);
}
}

View file

@ -40,11 +40,12 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 06, 2012 740 djohnson Initial creation
* Aug 09. 2012 1022 djohnson Changes to RetrievalHandler.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Jan 30, 2013 1543 djohnson RetrievalTask now requires a Network.
* Feb 05, 2013 1580 mpduff EventBus refactor.
* Jul 06, 2012 740 djohnson Initial creation
* Aug 09. 2012 1022 djohnson Changes to RetrievalHandler.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Jan 30, 2013 1543 djohnson RetrievalTask now requires a Network.
* Feb 05, 2013 1580 mpduff EventBus refactor.
* Feb 07, 2013 1543 djohnson Move test to its proper test class, as per peer review comments.
*
* </pre>
*
@ -54,8 +55,6 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
public class RetrievalHandlerTest {
private static final String EXCEPTION_MESSAGE = "thrown on purpose";
private final ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
private final RetrievalDao mockDao = mock(RetrievalDao.class);
@ -75,46 +74,6 @@ public class RetrievalHandlerTest {
verify(mockDao).resetRunningRetrievalsToPending();
}
// FIXME: Create PerformRetrievalPluginDataObjectsFinderTest and move this
// test there
// @Test
// public void testIllegalStateExceptionThrownDuringProcessWillReturnFalse()
// throws SerializationException {
//
// PathManagerFactoryTest.initLocalization();
// Retrieval retrieval = new Retrieval() {
// private static final long serialVersionUID = 1109443017002028345L;
//
// @Override
// public ArrayList<RetrievalAttribute> getAttribute() {
// throw new IllegalStateException(EXCEPTION_MESSAGE);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public ServiceType getServiceType() {
// return ServiceType.OPENDAP;
// }
// };
// RetrievalRequestRecord record = new RetrievalRequestRecord();
// try {
// record.setRetrievalObj(retrieval);
// } catch (NullPointerException npe) {
// // This is expected because we create an anonymous retrieval
// // instance, and can't dynamically serialize it
// }
//
// RetrievalTask task = new RetrievalTask(
// new PerformRetrievalPluginDataObjectsFinder(Network.OPSNET),
// new NotifyOfPluginDataObjectsDecorator(
// mock(IRetrievedDataProcessor.class)),
// retrievalCompleter);
// assertFalse("Expected false when an IllegalStateException was thrown!",
// task.process(record));
// }
@Test
public void testOnNotifyOfSubscriptionsARetrievalTaskIsExecuted() {
handler.notify(Collections.<String> emptyList());

View file

@ -68,7 +68,7 @@ public class RetrievalPluginDataObjectsFixture extends
List<RetrievalAttributePluginDataObjects> retrievalAttributePluginDataObjects = new ArrayList<RetrievalAttributePluginDataObjects>();
try {
for (RetrievalAttribute attribute : requestRecord.getRetrievalObj()
.getAttribute()) {
.getAttributes()) {
// TODO: GridRecordFixture
final GridRecord gridRecord = new GridRecord();
gridRecord.setDataURI("dataUri" + seedValue);

View file

@ -29,9 +29,9 @@ import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.util.AbstractFixture;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.MockServiceFactory;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecordPK;
import com.raytheon.uf.edex.datadelivery.retrieval.opendap.MockOpenDapServiceFactory;
/**
* Fixture for {@link RetrievalRequestRecord}.
@ -91,8 +91,9 @@ public class RetrievalRequestRecordFixture extends
try {
rec.setRetrieval(SerializationUtil
.transformToThrift(new MockServiceFactory(provider)
.buildRetrieval(bundle).iterator().next()));
.transformToThrift(new MockOpenDapServiceFactory(provider)
.getRetrievalGenerator().buildRetrieval(bundle)
.iterator().next()));
} catch (SerializationException e) {
throw new RuntimeException(e);
}

View file

@ -20,10 +20,13 @@
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -40,6 +43,7 @@ import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
@ -56,6 +60,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 30, 2013 1543 djohnson Initial creation
* Feb 07, 2013 1543 djohnson Add test to simulate SBN retrieval task behavior.
*
* </pre>
*
@ -89,11 +94,9 @@ public class RetrievalTaskTest {
}
}
private final RetrievalRequestRecord opsnetRetrieval = RetrievalRequestRecordFixture.INSTANCE
.get(1);
private RetrievalRequestRecord opsnetRetrieval;
private final RetrievalRequestRecord sbnRetrieval = RetrievalRequestRecordFixture.INSTANCE
.get(2);
private RetrievalRequestRecord sbnRetrieval;
private RetrievalDao dao;
@ -106,10 +109,12 @@ public class RetrievalTaskTest {
DatabaseUtil.start();
PathManagerFactoryTest.initLocalization();
opsnetRetrieval = RetrievalRequestRecordFixture.INSTANCE.get(1);
sbnRetrieval = RetrievalRequestRecordFixture.INSTANCE.get(2);
opsnetRetrieval.setNetwork(Network.OPSNET);
sbnRetrieval.setNetwork(Network.SBN);
dao = new RetrievalDao();
dao = RetrievalDao.getInstance();
EventBus.register(this);
}
@ -138,9 +143,9 @@ public class RetrievalTaskTest {
runRetrievalTask();
assertThat(retrievedDataProcessor.pluginDataObjects.size(),
is(equalTo(opsnetRetrieval.getRetrievalObj().getAttribute()
.size())));
assertThat(retrievedDataProcessor.pluginDataObjects,
hasSize(opsnetRetrieval.getRetrievalObj().getAttributes()
.size()));
}
@Test
@ -151,8 +156,9 @@ public class RetrievalTaskTest {
runRetrievalTask();
assertThat(eventsReceived.size(), is(equalTo(opsnetRetrieval
.getRetrievalObj().getAttribute().size())));
final int numberOfRetrievalAttributes = opsnetRetrieval
.getRetrievalObj().getAttributes().size();
assertThat(eventsReceived, hasSize(numberOfRetrievalAttributes));
// TODO: Is there a way to distinguish between the events sent by the
// separate retrieval attributes, e.g. to make sure each attribute sent
// an event and not one attribute sent two?
@ -173,6 +179,35 @@ public class RetrievalTaskTest {
verifyCorrectStateForRetrieval(sbnRetrieval, State.PENDING);
}
@Test
public void retrievalTaskCanStoreDataToDirectoryThatAnotherTaskProcesses()
throws Exception {
RetrievalPluginDataObjects retrievalPluginDataObjects = RetrievalPluginDataObjectsFixture.INSTANCE
.get();
IRetrievalPluginDataObjectsFinder retrievalDataFinder = mock(IRetrievalPluginDataObjectsFinder.class);
when(retrievalDataFinder.findRetrievalPluginDataObjects()).thenReturn(
retrievalPluginDataObjects).thenReturn(null);
IRetrievalResponseCompleter retrievalCompleter = mock(IRetrievalResponseCompleter.class);
final File testDirectory = TestUtil
.setupTestClassDir(RetrievalTaskTest.class);
IRetrievalPluginDataObjectsProcessor serializeToDirectory = new SerializeRetrievedDataToDirectory(
testDirectory);
RetrievalTask downloadTask = new RetrievalTask(Network.OPSNET,
retrievalDataFinder, serializeToDirectory, retrievalCompleter);
RetrievalTask readDownloadsTask = new RetrievalTask(Network.OPSNET,
new DeserializeRetrievedDataFromDirectory(testDirectory),
retrievedDataProcessor, retrievalCompleter);
downloadTask.run();
readDownloadsTask.run();
assertThat(retrievedDataProcessor.pluginDataObjects, hasSize(2));
}
/**
* Stage the retrievals in the database.
*/

View file

@ -0,0 +1,75 @@
/**
* 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.retrieval.metadata.adapters;
import org.junit.Ignore;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverageFixture;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
/**
* Overrides specific methods in {@link GridMetadataAdapter} that require
* database interaction.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 06, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Ignore
public class MockGridMetaDataAdapter extends GridMetadataAdapter {
/**
* Constructor.
*
* @param attXML
* @throws InstantiationException
*/
public MockGridMetaDataAdapter(RetrievalAttribute attXML)
throws InstantiationException {
super(attXML);
}
/**
* {@inheritDoc}
*/
@Override
GridCoverage getCoverageFromCache(GridCoverage coverage) {
return GriddedCoverageFixture.INSTANCE.get().getGridCoverage();
}
/**
* {@inheritDoc}
*/
@Override
Level[] getLevels(RetrievalAttribute attXML) {
return new Level[] { new Level("0.0") };
}
}

View file

@ -0,0 +1,86 @@
/**
* 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.retrieval.opendap;
import java.io.ByteArrayInputStream;
import org.junit.Ignore;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
import com.raytheon.uf.edex.datadelivery.retrieval.response.MockOpenDAPTranslator;
import com.raytheon.uf.edex.datadelivery.retrieval.response.OpenDAPTranslator;
import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
import dods.dap.DConnect;
import dods.dap.DConnectTest;
import dods.dap.DataDDS;
/**
* Overrides specific methods in {@link OpenDAPRetrievalAdapter} that require
* external resources.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 06, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Ignore
public class MockOpenDapRetrievalAdapter extends OpenDAPRetrievalAdapter {
/**
* Instead of connecting to an external OpenDAP system, it reads in the dods
* file and recreates the {@link DataDDS} instance.
*/
@Override
public RetrievalResponse performRequest(IRetrievalRequestBuilder request) {
DConnect dconnect = new DConnect(new ByteArrayInputStream(
TestUtil.readResource(DConnectTest.class,
"/datadelivery/opendap/compressed_rap_dataset.dods")));
DataDDS data = null;
try {
data = dconnect.getData(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
final RetrievalResponse response = new RetrievalResponse(
request.getAttribute());
response.setPayLoad(new Object[] { data });
return response;
}
/**
* {@inheritDoc}
*/
@Override
OpenDAPTranslator getOpenDapTranslator(RetrievalAttribute attribute)
throws InstantiationException {
return new MockOpenDAPTranslator(attribute);
}
}

View file

@ -0,0 +1,103 @@
/**
* 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.retrieval.opendap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Ignore;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverageFixture;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
/**
* Overrides methods in {@link OpenDAPRetrievalGenerator} which require external
* systems (e.g. databases, spring, etc.).
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 06, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Ignore
public class MockOpenDapRetrievalGenerator extends OpenDAPRetrievalGenerator {
/**
* {@inheritDoc}
*/
@Override
protected RetrievalAdapter getServiceRetrievalAdapter() {
return new MockOpenDapRetrievalAdapter();
}
/**
* {@inheritDoc}
*/
@Override
public List<Retrieval> buildRetrieval(SubscriptionBundle bundle) {
final Subscription subscription = bundle.getSubscription();
Retrieval retrieval = new Retrieval();
retrieval.setConnection(bundle.getConnection());
retrieval.setNetwork(subscription.getRoute());
retrieval.setOwner(subscription.getOwner());
retrieval.setProviderType(bundle.getProvider().getProviderType()
.iterator().next());
retrieval.setServiceType(this.getServiceType());
retrieval.setSubscriptionName(subscription.getName());
retrieval.setSubscriptionType(getSubscriptionType(subscription));
final ArrayList<RetrievalAttribute> attributes = new ArrayList<RetrievalAttribute>();
attributes.add(getAttribute(bundle));
attributes.add(getAttribute(bundle));
retrieval.setAttributes(attributes);
return Arrays.asList(retrieval);
}
/**
* @param bundle
* @return
*/
private RetrievalAttribute getAttribute(SubscriptionBundle bundle) {
RetrievalAttribute attribute = new RetrievalAttribute();
attribute.setCoverage(GriddedCoverageFixture.INSTANCE.get());
final Subscription subscription = bundle.getSubscription();
attribute.setSubName(subscription.getName());
attribute.setProvider(bundle.getProvider().getName());
attribute.setParameter(subscription.getParameter().get(0));
attribute.setTime(subscription.getTime());
attribute.setPlugin("grid");
return attribute;
}
}

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.retrieval.opendap;
import org.junit.Ignore;
import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
/**
* Extends {@link OpenDapServiceFactory} to not require external systems.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 30, 2013 1543 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@Ignore
public class MockOpenDapServiceFactory extends OpenDapServiceFactory {
/**
* @param provider
*/
public MockOpenDapServiceFactory(Provider provider) {
super(provider);
}
@Override
public RetrievalGenerator getRetrievalGenerator() {
return new MockOpenDapRetrievalGenerator();
}
}

View file

@ -47,7 +47,6 @@ import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
import com.raytheon.uf.common.serialization.SerializationUtilTest;
import com.raytheon.uf.common.time.util.ImmutableDate;
import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.datadelivery.retrieval.Link;
@ -68,6 +67,7 @@ import dods.dap.parser.ParseException;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 09, 2013 1466 dhladky Unit test for NCOM
* Feb 06, 2013 1543 djohnson Remove test setup methods no longer necessary.
*
* </pre>
*
@ -106,7 +106,6 @@ public class OpenDAPMetaDataParserNCOMTest {
@BeforeClass
public static void classSetUp() throws DASException, ParseException {
SerializationUtilTest.initSerializationUtil();
PathManagerFactoryTest.initLocalization();
ByteArrayInputStream bis = new ByteArrayInputStream(

Some files were not shown because too many files have changed in this diff Show more