Issue #1644 WFO bandwidth manager delegates to NCF bandwidth manager for SBN subscriptions
Amend: Use isEmpty() where possible in BandwidthManager. Change-Id: I85fe54982245e088f60dd33148aed72e6abfc9ec Former-commit-id: 28c97849800c624bdaa161f05777703ee2a510ac
This commit is contained in:
parent
3436c86641
commit
1161125c84
20 changed files with 634 additions and 68 deletions
|
@ -5,7 +5,7 @@
|
|||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
||||
|
||||
<bean id="bandwidthService"
|
||||
class="com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService" />
|
||||
class="com.raytheon.uf.common.datadelivery.bandwidth.WfoBandwidthService" />
|
||||
|
||||
<bean id="subscriptionNotificationService"
|
||||
class="com.raytheon.uf.common.datadelivery.service.SendToServerSubscriptionNotificationService" />
|
||||
|
|
|
@ -25,12 +25,12 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.auth.req.BasePrivilegedServerService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.service.BasePrivilegedDataDeliveryService;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -49,19 +49,29 @@ import com.raytheon.uf.common.util.LogUtil;
|
|||
* Nov 15, 2012 1286 djohnson No longer abstract.
|
||||
* Nov 20, 2012 1286 djohnson Add proposeSchedule methods.
|
||||
* Dec 06, 2012 1397 djohnson Add ability to get bandwidth graph data.
|
||||
* Feb 27, 2013 1644 djohnson Now abstract, sub-classes provide specific service lookup keys.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BandwidthService extends
|
||||
BasePrivilegedDataDeliveryService<IBandwidthRequest> implements
|
||||
public abstract class BandwidthService extends
|
||||
BasePrivilegedServerService<IBandwidthRequest> implements
|
||||
IBandwidthService {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(BandwidthService.class);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param serviceKey
|
||||
*/
|
||||
protected BandwidthService(String serviceKey) {
|
||||
super(serviceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -226,7 +236,6 @@ public class BandwidthService extends
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -237,10 +246,9 @@ public class BandwidthService extends
|
|||
try {
|
||||
return sendRequest(request, BandwidthGraphData.class);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to retrieve bandwidth graph data, returning null.",
|
||||
e);
|
||||
e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.datadelivery.bandwidth;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link IBandwidthService} that communicates with the
|
||||
* WFO bandwidth manager.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 27, 2013 1644 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class WfoBandwidthService extends BandwidthService {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
protected WfoBandwidthService() {
|
||||
super(DataDeliveryConstants.DATA_DELIVERY_SERVER);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,8 @@ Require-Bundle: com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
|||
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.edex.auth;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.plugin.nwsauth;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.util
|
||||
com.raytheon.uf.common.util,
|
||||
com.raytheon.uf.common.datadelivery.request;bundle-version="1.0.0"
|
||||
Export-Package: com.raytheon.uf.edex.datadelivery.bandwidth.interfaces,
|
||||
com.raytheon.uf.edex.datadelivery.bandwidth.processing
|
||||
Import-Package: com.raytheon.uf.common.datadelivery.event.retrieval,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="bandwidthService"
|
||||
class="com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService" />
|
||||
class="com.raytheon.uf.common.datadelivery.bandwidth.WfoBandwidthService" />
|
||||
|
||||
<bean id="bandwidthHandler"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.handler.GraphDataHandler">
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.raytheon.uf.common.auth.exception.AuthorizationException;
|
|||
import com.raytheon.uf.common.auth.user.IUser;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.ProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
|
||||
|
@ -101,6 +102,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Feb 14, 2013 1595 djohnson Check with BandwidthUtil whether or not to reschedule subscriptions on update.
|
||||
* Feb 14, 2013 1596 djohnson Do not reschedule allocations when a subscription is removed.
|
||||
* Feb 20, 2013 1543 djohnson Add try/catch blocks during the shutdown process.
|
||||
* Feb 27, 2013 1644 djohnson Force sub-classes to provide an implementation for how to schedule SBN routed subscriptions.
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -524,7 +526,7 @@ abstract class BandwidthManager extends
|
|||
bandwidthSubscription.getProvider(),
|
||||
bandwidthSubscription.getDataSetName(),
|
||||
bandwidthSubscription.getBaseReferenceTime());
|
||||
if (z.size() > 0) {
|
||||
if (!z.isEmpty()) {
|
||||
retrieval.setStatus(RetrievalStatus.READY);
|
||||
}
|
||||
bandwidthDao.store(retrieval);
|
||||
|
@ -804,14 +806,16 @@ abstract class BandwidthManager extends
|
|||
bandwidthSubscription = itr.next();
|
||||
if (oldCycles.contains(bandwidthSubscription
|
||||
.getCycle())) {
|
||||
bandwidthSubscriptionToRemove.add(bandwidthSubscription);
|
||||
bandwidthSubscriptionToRemove
|
||||
.add(bandwidthSubscription);
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
unscheduled.addAll(remove(bandwidthSubscriptionToRemove));
|
||||
unscheduled
|
||||
.addAll(remove(bandwidthSubscriptionToRemove));
|
||||
}
|
||||
|
||||
if (newCycles.size() > 0) {
|
||||
if (!newCycles.isEmpty()) {
|
||||
unscheduled.addAll(schedule(subscription, newCycles));
|
||||
}
|
||||
}
|
||||
|
@ -1002,25 +1006,25 @@ abstract class BandwidthManager extends
|
|||
response = showRetrievalPlan(requestNetwork);
|
||||
break;
|
||||
case PROPOSE_SCHEDULE_SUBSCRIPTION:
|
||||
final ProposeScheduleResponse proposeResponse = proposeSchedule(subscriptions);
|
||||
response = proposeResponse;
|
||||
Set<String> subscriptionsUnscheduled = proposeResponse
|
||||
.getUnscheduledSubscriptions();
|
||||
if (subscriptionsUnscheduled.isEmpty()) {
|
||||
statusHandler
|
||||
.info("No subscriptions will be unscheduled by scheduling subscriptions "
|
||||
+ subscriptions + ". Applying...");
|
||||
// This is a safe operation as all subscriptions will remain
|
||||
// scheduled, just apply
|
||||
scheduleSubscriptions(subscriptions);
|
||||
} else if (subscriptions.size() == 1) {
|
||||
int requiredLatency = determineRequiredLatency(subscriptions
|
||||
.get(0));
|
||||
proposeResponse.setRequiredLatency(requiredLatency);
|
||||
// SBN subscriptions must go through the NCF
|
||||
if (!subscriptions.isEmpty()
|
||||
&& Network.SBN.equals(subscriptions.get(0).getRoute())) {
|
||||
final IProposeScheduleResponse proposeResponse = proposeScheduleSbnSubscription(subscriptions);
|
||||
response = proposeResponse;
|
||||
} else {
|
||||
// OPSNET subscriptions
|
||||
response = proposeScheduleSubscriptions(subscriptions);
|
||||
}
|
||||
break;
|
||||
case SCHEDULE_SUBSCRIPTION:
|
||||
response = scheduleSubscriptions(subscriptions);
|
||||
// SBN subscriptions must go through the NCF
|
||||
if (!subscriptions.isEmpty()
|
||||
&& Network.SBN.equals(subscriptions.get(0).getRoute())) {
|
||||
response = scheduleSbnSubscriptions(subscriptions);
|
||||
} else {
|
||||
// OPSNET subscriptions
|
||||
response = scheduleSubscriptions(subscriptions);
|
||||
}
|
||||
break;
|
||||
case GET_BANDWIDTH:
|
||||
RetrievalPlan b = retrievalManager.getPlan(requestNetwork);
|
||||
|
@ -1097,6 +1101,58 @@ abstract class BandwidthManager extends
|
|||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the SBN subscriptions.
|
||||
*
|
||||
* @param subscriptions
|
||||
* the subscriptions
|
||||
* @return the set of subscription names unscheduled as a result of
|
||||
* scheduling the subscriptions
|
||||
* @throws SerializationException
|
||||
*/
|
||||
protected abstract Set<String> scheduleSbnSubscriptions(
|
||||
List<Subscription> subscriptions) throws SerializationException;
|
||||
|
||||
/**
|
||||
* Proposes scheduling a list of subscriptions.
|
||||
*
|
||||
* @param subscriptions
|
||||
* the subscriptions
|
||||
* @return the response
|
||||
* @throws SerializationException
|
||||
*/
|
||||
protected ProposeScheduleResponse proposeScheduleSubscriptions(
|
||||
List<Subscription> subscriptions) throws SerializationException {
|
||||
final ProposeScheduleResponse proposeResponse = proposeSchedule(subscriptions);
|
||||
Set<String> subscriptionsUnscheduled = proposeResponse
|
||||
.getUnscheduledSubscriptions();
|
||||
if (subscriptionsUnscheduled.isEmpty()) {
|
||||
statusHandler
|
||||
.info("No subscriptions will be unscheduled by scheduling subscriptions "
|
||||
+ subscriptions + ". Applying...");
|
||||
// This is a safe operation as all subscriptions will remain
|
||||
// scheduled, just apply
|
||||
scheduleSubscriptions(subscriptions);
|
||||
} else if (subscriptions.size() == 1) {
|
||||
int requiredLatency = determineRequiredLatency(subscriptions.get(0));
|
||||
proposeResponse.setRequiredLatency(requiredLatency);
|
||||
}
|
||||
return proposeResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Propose scheduling SBN routed subscriptions. Sub-classes must implement
|
||||
* the specific functionality.
|
||||
*
|
||||
* @param subscriptions
|
||||
* the subscriptions targeted at the SBN
|
||||
* @return the response
|
||||
* @throws Exception
|
||||
* on error
|
||||
*/
|
||||
protected abstract IProposeScheduleResponse proposeScheduleSbnSubscription(
|
||||
List<Subscription> subscriptions) throws Exception;
|
||||
|
||||
/**
|
||||
* Retrieve the bandwidth graph data.
|
||||
*
|
||||
|
@ -1162,7 +1218,7 @@ abstract class BandwidthManager extends
|
|||
* @return the set of subscription names unscheduled
|
||||
* @throws SerializationException
|
||||
*/
|
||||
private Set<String> scheduleSubscriptions(List<Subscription> subscriptions)
|
||||
protected Set<String> scheduleSubscriptions(List<Subscription> subscriptions)
|
||||
throws SerializationException {
|
||||
Set<String> unscheduledSubscriptions = new TreeSet<String>();
|
||||
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.ProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.util.JarUtil;
|
||||
|
@ -43,6 +47,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 30, 2012 1286 djohnson Initial creation
|
||||
* Feb 20, 2013 1543 djohnson For now assume all in-memory bandwidth managers are WFOs.
|
||||
* Feb 27, 2013 1644 djohnson Schedule SBN subscriptions.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -111,4 +116,22 @@ class InMemoryBandwidthManager extends BandwidthManager {
|
|||
return IN_MEMORY_BANDWIDTH_MANAGER_FILES;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected ProposeScheduleResponse proposeScheduleSbnSubscription(
|
||||
List<Subscription> subscriptions) throws Exception {
|
||||
return proposeScheduleSubscriptions(subscriptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Set<String> scheduleSbnSubscriptions(
|
||||
List<Subscription> subscriptions) throws SerializationException {
|
||||
return scheduleSubscriptions(subscriptions);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.ProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.util.JarUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.IEdexBandwidthManagerCreator;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
|
@ -36,6 +42,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 20, 2013 1543 djohnson Initial creation
|
||||
* Feb 27, 2013 1644 djohnson Schedule SBN subscriptions.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,7 +54,7 @@ public class NcfBandwidthManagerCreator implements IEdexBandwidthManagerCreator
|
|||
/**
|
||||
* NCF {@link BandwidthManager} implementation.
|
||||
*/
|
||||
private static class NcfBandwidthManager extends BandwidthManager {
|
||||
static class NcfBandwidthManager extends BandwidthManager {
|
||||
|
||||
private static final String[] NCF_BANDWIDTH_MANAGER_FILES = new String[] {
|
||||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-edex-impl.xml"),
|
||||
|
@ -73,6 +80,24 @@ public class NcfBandwidthManagerCreator implements IEdexBandwidthManagerCreator
|
|||
protected String[] getSpringFilesForNewInstance() {
|
||||
return NCF_BANDWIDTH_MANAGER_FILES;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected ProposeScheduleResponse proposeScheduleSbnSubscription(
|
||||
List<Subscription> subscriptions) throws Exception {
|
||||
return proposeScheduleSubscriptions(subscriptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Set<String> scheduleSbnSubscriptions(
|
||||
List<Subscription> subscriptions) throws SerializationException {
|
||||
return scheduleSubscriptions(subscriptions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
|
||||
|
||||
/**
|
||||
* Implementation of {@link IBandwidthService} that communicates with the NCF
|
||||
* bandwidth manager.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 27, 2013 1644 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class NcfBandwidthService extends BandwidthService {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
protected NcfBandwidthService() {
|
||||
super(DataDeliveryConstants.NCF_BANDWIDTH_MANAGER_SERVICE);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,13 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.util.JarUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.IEdexBandwidthManagerCreator;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
|
@ -36,6 +43,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 20, 2013 1543 djohnson Initial creation
|
||||
* Feb 27, 2013 1644 djohnson Schedule SBN subscriptions by routing to the NCF bandwidth manager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,7 +55,7 @@ public class WfoBandwidthManagerCreator implements IEdexBandwidthManagerCreator
|
|||
/**
|
||||
* WFO {@link BandwidthManager} implementation.
|
||||
*/
|
||||
private static class WfoBandwidthManager extends BandwidthManager {
|
||||
static class WfoBandwidthManager extends BandwidthManager {
|
||||
|
||||
private static final String[] WFO_BANDWIDTH_MANAGER_FILES = new String[] {
|
||||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-edex-impl.xml"),
|
||||
|
@ -55,6 +63,9 @@ public class WfoBandwidthManagerCreator implements IEdexBandwidthManagerCreator
|
|||
JarUtil.getResResourcePath("/spring/thrift-bandwidth.xml"),
|
||||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-wfo.xml") };
|
||||
|
||||
// TODO: Change to be DIed in Spring
|
||||
private final IBandwidthService ncfBandwidthService = new NcfBandwidthService();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -73,6 +84,40 @@ public class WfoBandwidthManagerCreator implements IEdexBandwidthManagerCreator
|
|||
protected String[] getSpringFilesForNewInstance() {
|
||||
return WFO_BANDWIDTH_MANAGER_FILES;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected IProposeScheduleResponse proposeScheduleSbnSubscription(
|
||||
List<Subscription> subscriptions) throws Exception {
|
||||
|
||||
final IProposeScheduleResponse proposeResponse = ncfBandwidthService
|
||||
.proposeSchedule(subscriptions);
|
||||
|
||||
// If the NCF bandwidth manager says they fit without
|
||||
// unscheduling anything, then schedule them at the WFO level to
|
||||
// track retrievals/graphing
|
||||
if (proposeResponse.getUnscheduledSubscriptions().isEmpty()) {
|
||||
scheduleSubscriptions(subscriptions);
|
||||
}
|
||||
|
||||
return proposeResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Set<String> scheduleSbnSubscriptions(
|
||||
List<Subscription> subscriptions) throws SerializationException {
|
||||
|
||||
final Set<String> ncfResponse = ncfBandwidthService
|
||||
.schedule(subscriptions);
|
||||
scheduleSubscriptions(subscriptions);
|
||||
|
||||
return ncfResponse;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
import com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.WfoBandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.TimeWindowData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
|
||||
|
@ -77,6 +78,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Dec 06, 2012 1397 djohnson Add tests for getting bandwidth graph data.
|
||||
* Feb 20, 2013 1543 djohnson Use WFO bandwidth manager.
|
||||
* Feb 26, 2013 1643 djohnson BandwidthService extends reusable class.
|
||||
* Feb 27, 2013 1644 djohnson Bandwidth service is the WFO version.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -96,7 +98,7 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
|
|||
|
||||
private static final int ONE_HUNDRED = 100;
|
||||
|
||||
private final BandwidthService service = new BandwidthService() {
|
||||
private final BandwidthService service = new WfoBandwidthService() {
|
||||
@Override
|
||||
protected Object getResponseFromServer(IBandwidthRequest request)
|
||||
throws Exception {
|
||||
|
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.edex.datadelivery.bandwidth;
|
|||
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.NcfBandwidthManagerCreator.NcfBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
|
@ -37,6 +38,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 18, 2013 1543 djohnson Initial creation
|
||||
* Feb 27, 2013 1644 djohnson Extend NCF bandwidth manager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -44,7 +46,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class IntegrationTestNcfBandwidthManager extends BandwidthManager {
|
||||
public class IntegrationTestNcfBandwidthManager extends NcfBandwidthManager {
|
||||
|
||||
static final String[] INTEGRATION_TEST_SPRING_FILES = new String[] {
|
||||
"/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml",
|
||||
|
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.edex.datadelivery.bandwidth;
|
|||
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.WfoBandwidthManagerCreator.WfoBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
|
||||
|
@ -37,6 +38,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 30, 2012 1286 djohnson Initial creation
|
||||
* Feb 27, 2013 1644 djohnson Extends WFO bandwidth manager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -44,7 +46,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class IntegrationTestWfoBandwidthManager extends BandwidthManager {
|
||||
public class IntegrationTestWfoBandwidthManager extends WfoBandwidthManager {
|
||||
|
||||
static final String[] INTEGRATION_TEST_SPRING_FILES = new String[] {
|
||||
"/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml",
|
||||
|
|
|
@ -0,0 +1,250 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import static org.hamcrest.Matchers.emptyCollectionOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestRouter;
|
||||
import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
||||
import com.raytheon.uf.common.serialization.comm.RequestRouterTest;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.common.util.registry.RegistryException;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.NcfBandwidthManagerCreator.NcfBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.WfoBandwidthManagerCreator.WfoBandwidthManager;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Test interactions between a {@link WfoBandwidthManager} and a
|
||||
* {@link NcfBandwidthManager}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 27, 2013 1644 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class WfoNcfBandwidthManagerIntTest extends
|
||||
AbstractBandwidthManagerIntTest {
|
||||
|
||||
private BandwidthManager ncfBandwidthManager;
|
||||
|
||||
private IBandwidthDao ncfBandwidthDao;
|
||||
|
||||
@Override
|
||||
public void setUp() {
|
||||
super.setUp();
|
||||
|
||||
// Set up the NCF bandwidth manager
|
||||
ApplicationContext ncfBandwidthManagerCtx = new ClassPathXmlApplicationContext(
|
||||
new String[] {
|
||||
DatabaseUtil.UNIT_TEST_DB_BEANS2_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_NCF_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_NCF_XML });
|
||||
ncfBandwidthManager = (BandwidthManager) ncfBandwidthManagerCtx
|
||||
.getBean("bandwidthManager");
|
||||
ncfBandwidthDao = (IBandwidthDao) ncfBandwidthManagerCtx
|
||||
.getBean("bandwidthDao");
|
||||
|
||||
// Add the router to the NCF bandwidth manager
|
||||
RequestRouterTest.clearRegistry();
|
||||
try {
|
||||
RequestRouterTest.register(
|
||||
DataDeliveryConstants.NCF_BANDWIDTH_MANAGER_SERVICE,
|
||||
new IRequestRouter() {
|
||||
@Override
|
||||
public Object route(IServerRequest request)
|
||||
throws Exception {
|
||||
return ncfBandwidthManager
|
||||
.handleRequest((IBandwidthRequest) request);
|
||||
}
|
||||
});
|
||||
} catch (RegistryException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void proposeScheduleSbnSubscriptionIsScheduledForNcf()
|
||||
throws Exception {
|
||||
proposeScheduleSbnSubscriptionThatFits();
|
||||
|
||||
final List<BandwidthAllocation> ncfSbnBandwidthAllocations = ncfBandwidthDao
|
||||
.getBandwidthAllocations(Network.SBN);
|
||||
assertThat(ncfSbnBandwidthAllocations,
|
||||
is(not(emptyCollectionOf(BandwidthAllocation.class))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void proposeScheduleSbnSubscriptionIsScheduledForWfo()
|
||||
throws Exception {
|
||||
proposeScheduleSbnSubscriptionThatFits();
|
||||
|
||||
final List<BandwidthAllocation> wfoSbnBandwidthAllocations = bandwidthDao
|
||||
.getBandwidthAllocations(Network.SBN);
|
||||
assertThat(wfoSbnBandwidthAllocations,
|
||||
is(not(emptyCollectionOf(BandwidthAllocation.class))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tooLargeSbnSubscriptionIsNotScheduledForNcf() throws Exception {
|
||||
proposeScheduleSbnSubscriptionThatDoesNotFit();
|
||||
|
||||
final List<BandwidthAllocation> ncfSbnBandwidthAllocations = ncfBandwidthDao
|
||||
.getBandwidthAllocations(Network.SBN);
|
||||
assertThat(ncfSbnBandwidthAllocations,
|
||||
is(emptyCollectionOf(BandwidthAllocation.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tooLargeSbnSubscriptionIsNotScheduledForWfo() throws Exception {
|
||||
proposeScheduleSbnSubscriptionThatDoesNotFit();
|
||||
|
||||
final List<BandwidthAllocation> wfoSbnBandwidthAllocations = bandwidthDao
|
||||
.getBandwidthAllocations(Network.SBN);
|
||||
assertThat(wfoSbnBandwidthAllocations,
|
||||
is(emptyCollectionOf(BandwidthAllocation.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smallEnoughSbnSubscriptionCanBeScheduledForNcf()
|
||||
throws Exception {
|
||||
scheduleSbnSubscriptionThatFits();
|
||||
|
||||
final List<BandwidthSubscription> subscriptions = ncfBandwidthDao
|
||||
.getBandwidthSubscriptions();
|
||||
assertThat(subscriptions,
|
||||
is(not(emptyCollectionOf(BandwidthSubscription.class))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smallEnoughSbnSubscriptionCanBeScheduledForWfo()
|
||||
throws Exception {
|
||||
scheduleSbnSubscriptionThatFits();
|
||||
|
||||
final List<BandwidthSubscription> subscriptions = bandwidthDao
|
||||
.getBandwidthSubscriptions();
|
||||
assertThat(subscriptions,
|
||||
is(not(emptyCollectionOf(BandwidthSubscription.class))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Propose schedules an SBN routed subscription that will fit within the
|
||||
* bandwidth requirements.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void proposeScheduleSbnSubscriptionThatFits() throws Exception {
|
||||
scheduleSbnSubscription(createSubscriptionThatFillsAThirdOfABucket(),
|
||||
RequestType.PROPOSE_SCHEDULE_SUBSCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Propose schedules an SBN routed subscription that will NOT fit within the
|
||||
* bandwidth requirements.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void proposeScheduleSbnSubscriptionThatDoesNotFit()
|
||||
throws Exception {
|
||||
scheduleSbnSubscription(createSubscriptionThatFillsUpTwoBuckets(),
|
||||
RequestType.PROPOSE_SCHEDULE_SUBSCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules an SBN routed subscription that will fit within the bandwidth
|
||||
* requirements.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void scheduleSbnSubscriptionThatFits() throws Exception {
|
||||
scheduleSbnSubscription(createSubscriptionThatFillsAThirdOfABucket(),
|
||||
RequestType.SCHEDULE_SUBSCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules an SBN routed subscription that will NOT fit within the
|
||||
* bandwidth requirements.
|
||||
*
|
||||
* @param requestType
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void scheduleSbnSubscription(Subscription subscription,
|
||||
RequestType requestType) throws Exception {
|
||||
IBandwidthRequest request = new IBandwidthRequest();
|
||||
request.setRequestType(requestType);
|
||||
request.setNetwork(subscription.getRoute());
|
||||
request.setSubscriptions(Arrays.asList(subscription));
|
||||
|
||||
bandwidthManager.handleRequest(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Network getRouteToUseForSubscription() {
|
||||
return Network.SBN;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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
|
||||
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">
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:unit-testing" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
<property name="defaultAutoCommit" value="false" />
|
||||
</bean>
|
||||
|
||||
<import resource="classpath:/unit-test-db-session.xml" />
|
||||
|
||||
<bean id="metadataSessionFactory"
|
||||
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="annotatedClasses">
|
||||
<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.BandwidthDataSetUpdate</value>
|
||||
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription</value>
|
||||
<value>com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="configLocation">
|
||||
<value>classpath:unit-test-hibernate.cfg.xml</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven transaction-manager="metadataTxManager" />
|
||||
|
||||
<bean id="metadataTxManager"
|
||||
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<!-- Register the application context with EDEXUtil -->
|
||||
<bean class="com.raytheon.uf.edex.core.EDEXUtil" />
|
||||
|
||||
</beans>
|
24
tests/resources/unit-test-db-beans2.xml
Normal file
24
tests/resources/unit-test-db-beans2.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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">
|
||||
|
||||
<!-- Used in the case where a second in-memory database needs to be started
|
||||
in the same unit test -->
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:unit-testing2" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
<property name="defaultAutoCommit" value="false" />
|
||||
</bean>
|
||||
|
||||
<import resource="classpath:/unit-test-db-session.xml" />
|
||||
|
||||
</beans>
|
34
tests/resources/unit-test-db-session.xml
Normal file
34
tests/resources/unit-test-db-session.xml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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="metadataSessionFactory"
|
||||
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="packagesToScan">
|
||||
<list>
|
||||
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao</value>
|
||||
<value>com.raytheon.uf.edex.datadelivery.retrieval.db</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="configLocation">
|
||||
<value>classpath:unit-test-hibernate.cfg.xml</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven transaction-manager="metadataTxManager" />
|
||||
|
||||
<bean id="metadataTxManager"
|
||||
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<!-- Register the application context with EDEXUtil -->
|
||||
<bean class="com.raytheon.uf.edex.core.EDEXUtil" />
|
||||
|
||||
</beans>
|
|
@ -36,6 +36,7 @@ import com.raytheon.uf.edex.core.EDEXUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 0726 djohnson Initial creation
|
||||
* Feb 27, 2013 1644 djohnson Add constant for second in-memory database Spring file.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,6 +51,8 @@ public final class DatabaseUtil {
|
|||
|
||||
public static final String UNIT_TEST_DB_BEANS_XML = "/unit-test-db-beans.xml";
|
||||
|
||||
public static final String UNIT_TEST_DB_BEANS2_XML = "/unit-test-db-beans2.xml";
|
||||
|
||||
private static ApplicationContext originalApplicationContext;
|
||||
|
||||
private static ClassPathXmlApplicationContext applicationContext;
|
||||
|
|
|
@ -27,8 +27,10 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
|
||||
/**
|
||||
|
@ -56,6 +58,11 @@ public class DeserializeRetrievedDataFromDirectoryTest {
|
|||
private final DeserializeRetrievedDataFromDirectory service = new DeserializeRetrievedDataFromDirectory(
|
||||
directory);
|
||||
|
||||
@BeforeClass
|
||||
public static void classSetUp() {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deserializesRetrievedDataFromAFileInTheTargetDirectory()
|
||||
throws Exception {
|
||||
|
|
|
@ -24,8 +24,10 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
|
||||
|
@ -54,6 +56,11 @@ public class SerializeRetrievedDataToDirectoryTest {
|
|||
private final SerializeRetrievedDataToDirectory service = new SerializeRetrievedDataToDirectory(
|
||||
directory);
|
||||
|
||||
@BeforeClass
|
||||
public static void classSetUp() {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializesRetrievedDataToAFileInTheTargetDirectory()
|
||||
throws SerializationException {
|
||||
|
|
Loading…
Add table
Reference in a new issue