Issue #2709 updated devRegistry.sh and added retrieval monolithic for running shareds in devRegistry.
Amend: update from peer review. Change-Id: I1986de99319fdecd21a94579c499266b048d382a Former-commit-id: 4057294c4f777ffb4ea3523bbaea7ed1a084cbd6
This commit is contained in:
parent
d9d985eee4
commit
02f9fd20dc
8 changed files with 349 additions and 106 deletions
|
@ -27,3 +27,6 @@ export EDEX_JMX_PORT=1620
|
||||||
export LOG_CONF=logback-registry.xml
|
export LOG_CONF=logback-registry.xml
|
||||||
export MGMT_PORT=9605
|
export MGMT_PORT=9605
|
||||||
export EBXML_REGISTRY_FEDERATION_ENABLED=false
|
export EBXML_REGISTRY_FEDERATION_ENABLED=false
|
||||||
|
export NCF_HOST=${DATADELIVERY_HOST}
|
||||||
|
export NCF_ADDRESS=http://${NCF_HOST}:${EBXML_REGISTRY_WEBSERVER_PORT}
|
||||||
|
export NCF_BANDWIDTH_MANAGER_SERVICE=http://${NCF_HOST}:${EBXML_THRIFT_SERVICE_PORT}/services
|
||||||
|
|
|
@ -66,7 +66,8 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
||||||
* Jan 08, 2014 2615 bgonzale Implement calculate start and calculate end methods.
|
* Jan 08, 2014 2615 bgonzale Implement calculate start and calculate end methods.
|
||||||
* Jan 14, 2014 2459 mpduff Add subscription state.
|
* Jan 14, 2014 2459 mpduff Add subscription state.
|
||||||
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
|
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
|
||||||
* Jan 24, 2013 2709 bgonzale Fix setting of active period end.
|
* Jan 24, 2013 2709 bgonzale Fix setting of active period end. Change active period checks
|
||||||
|
* to check day of year. removed now unused active period methods.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -269,6 +270,17 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
@SlotAttribute(Subscription.SUBSCRIPTION_STATE_SLOT)
|
@SlotAttribute(Subscription.SUBSCRIPTION_STATE_SLOT)
|
||||||
private SubscriptionState subscriptionState = SubscriptionState.ON;
|
private SubscriptionState subscriptionState = SubscriptionState.ON;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Active Period starting day of the year. Calculated from
|
||||||
|
* activePeriodStart.
|
||||||
|
*/
|
||||||
|
private Integer startActivePeriodDayOfYear;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Active Period ending day of the year. Calculated from activePeriodEnd.
|
||||||
|
*/
|
||||||
|
private Integer endActivePeriodDayOfYear;
|
||||||
|
|
||||||
/** Flag stating if the object should be updated */
|
/** Flag stating if the object should be updated */
|
||||||
private boolean shouldUpdate = false;
|
private boolean shouldUpdate = false;
|
||||||
|
|
||||||
|
@ -433,6 +445,7 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
@Override
|
@Override
|
||||||
public void setActivePeriodStart(Date activePeriodStart) {
|
public void setActivePeriodStart(Date activePeriodStart) {
|
||||||
this.activePeriodStart = activePeriodStart;
|
this.activePeriodStart = activePeriodStart;
|
||||||
|
this.startActivePeriodDayOfYear = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -454,56 +467,35 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
@Override
|
@Override
|
||||||
public void setActivePeriodEnd(Date activePeriodEnd) {
|
public void setActivePeriodEnd(Date activePeriodEnd) {
|
||||||
this.activePeriodEnd = activePeriodEnd;
|
this.activePeriodEnd = activePeriodEnd;
|
||||||
|
this.endActivePeriodDayOfYear = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Calendar getActivePeriodStart(Calendar base) {
|
private Integer getStartActivePeriodDayOfYear() {
|
||||||
// active period values are month and day of month only, use base
|
if (startActivePeriodDayOfYear == null && activePeriodStart != null) {
|
||||||
// Calendar for active period year
|
startActivePeriodDayOfYear = TimeUtil
|
||||||
Calendar activePeriodStartCal = TimeUtil.newCalendar(activePeriodStart);
|
.newCalendar(activePeriodStart).get(Calendar.DAY_OF_YEAR);
|
||||||
TimeUtil.minCalendarFields(activePeriodStartCal, Calendar.MILLISECOND,
|
}
|
||||||
Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY);
|
return startActivePeriodDayOfYear;
|
||||||
activePeriodStartCal.set(Calendar.YEAR, base.get(Calendar.YEAR));
|
|
||||||
return activePeriodStartCal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Calendar getActivePeriodEnd(Calendar base) {
|
private Integer getEndActivePeriodDayOfYear() {
|
||||||
// active period values are month and day of month only, use base
|
if (endActivePeriodDayOfYear == null && activePeriodEnd != null) {
|
||||||
// Calendar for active period year
|
endActivePeriodDayOfYear = TimeUtil.newCalendar(activePeriodEnd)
|
||||||
Calendar activePeriodEndCal = TimeUtil.newCalendar(activePeriodEnd);
|
.get(Calendar.DAY_OF_YEAR);
|
||||||
TimeUtil.minCalendarFields(activePeriodEndCal, Calendar.MILLISECOND,
|
}
|
||||||
Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY);
|
return endActivePeriodDayOfYear;
|
||||||
activePeriodEndCal.set(Calendar.YEAR, base.get(Calendar.YEAR));
|
|
||||||
return activePeriodEndCal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Calendar calculateStart(Calendar startConstraint) {
|
public Calendar calculateStart(Calendar startConstraint) {
|
||||||
Calendar realStart = null;
|
return TimeUtil.newCalendar(TimeUtil.max(subscriptionStart,
|
||||||
boolean hasActivePeriodStart = activePeriodStart != null;
|
startConstraint));
|
||||||
if (hasActivePeriodStart) {
|
|
||||||
realStart = getActivePeriodStart(startConstraint);
|
|
||||||
if (realStart.before(startConstraint)) {
|
|
||||||
realStart = startConstraint;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
realStart = startConstraint;
|
|
||||||
}
|
|
||||||
return TimeUtil.newCalendar(TimeUtil.max(subscriptionStart, realStart));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Calendar calculateEnd(Calendar endConstraint) {
|
public Calendar calculateEnd(Calendar endConstraint) {
|
||||||
Calendar realEnd = null;
|
return TimeUtil.newCalendar(TimeUtil
|
||||||
boolean hasActivePeriodEnd = activePeriodEnd != null;
|
.min(subscriptionEnd, endConstraint));
|
||||||
if (hasActivePeriodEnd) {
|
|
||||||
realEnd = getActivePeriodEnd(endConstraint);
|
|
||||||
if (realEnd.after(endConstraint)) {
|
|
||||||
realEnd = endConstraint;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
realEnd = endConstraint;
|
|
||||||
}
|
|
||||||
return TimeUtil.newCalendar(TimeUtil.min(subscriptionEnd, realEnd));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -930,9 +922,8 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
|
|
||||||
// At this point the subscription is in the ON state
|
// At this point the subscription is in the ON state
|
||||||
Calendar cal = TimeUtil.newGmtCalendar();
|
Calendar cal = TimeUtil.newGmtCalendar();
|
||||||
Date today = cal.getTime();
|
|
||||||
|
|
||||||
if (inWindow(today)) {
|
if (inActivePeriodWindow(cal)) {
|
||||||
return SubscriptionStatus.ACTIVE;
|
return SubscriptionStatus.ACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,54 +947,33 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
||||||
* @param checkDate
|
* @param checkDate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean shouldScheduleForTime(Date checkDate) {
|
public boolean shouldScheduleForTime(Calendar checkCal) {
|
||||||
if (!isExpired(checkDate) && inWindow(checkDate)) {
|
if (!isExpired(checkCal.getTime()) && inActivePeriodWindow(checkCal)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inWindow(Date checkDate) {
|
public boolean inActivePeriodWindow(Calendar checkDate) {
|
||||||
if (activePeriodStart == null && activePeriodEnd == null) {
|
if (activePeriodStart == null && activePeriodEnd == null) {
|
||||||
|
// no active period set
|
||||||
return true;
|
return true;
|
||||||
} else if (activePeriodStart != null && activePeriodEnd != null) {
|
} else {
|
||||||
|
Integer startDay = getStartActivePeriodDayOfYear();
|
||||||
|
Integer endDay = getEndActivePeriodDayOfYear();
|
||||||
|
int checkDay = checkDate.get(Calendar.DAY_OF_YEAR);
|
||||||
|
|
||||||
Calendar startCal = TimeUtil.newGmtCalendar();
|
boolean isAfterPeriodStart = startDay <= checkDay;
|
||||||
startCal.setTime(activePeriodStart);
|
boolean isBeforePeriodEnd = checkDay < endDay;
|
||||||
startCal = TimeUtil.minCalendarFields(startCal,
|
boolean periodCrossesYearBoundary = endDay < startDay;
|
||||||
Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND,
|
|
||||||
Calendar.MILLISECOND);
|
|
||||||
// add the current year for true comparison
|
|
||||||
startCal = TimeUtil.addCurrentYearCalendar(startCal);
|
|
||||||
|
|
||||||
activePeriodStart = startCal.getTime();
|
if (periodCrossesYearBoundary) {
|
||||||
|
return isAfterPeriodStart || isBeforePeriodEnd;
|
||||||
Calendar endCal = TimeUtil.newGmtCalendar();
|
} else {
|
||||||
endCal.setTime(activePeriodEnd);
|
return isAfterPeriodStart && isBeforePeriodEnd;
|
||||||
endCal = TimeUtil.maxCalendarFields(endCal, Calendar.HOUR_OF_DAY,
|
|
||||||
Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND);
|
|
||||||
// add the current year for true comparison
|
|
||||||
endCal = TimeUtil.addCurrentYearCalendar(endCal);
|
|
||||||
// If the period crosses a year boundary, add a year to the end
|
|
||||||
if (endCal.before(startCal)) {
|
|
||||||
endCal.add(Calendar.YEAR, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activePeriodEnd = endCal.getTime();
|
|
||||||
|
|
||||||
// Only concerned with month and day, need to set the
|
|
||||||
// years on equal footing for comparison sake.
|
|
||||||
Calendar c = TimeUtil.newGmtCalendar();
|
|
||||||
c.setTime(checkDate);
|
|
||||||
// set the date to compare with the current date from the start
|
|
||||||
c.set(Calendar.YEAR, startCal.get(Calendar.YEAR));
|
|
||||||
Date date = c.getTime();
|
|
||||||
|
|
||||||
return (activePeriodStart.before(date) && activePeriodEnd
|
|
||||||
.after(date));
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,9 +43,10 @@ import com.raytheon.uf.common.datadelivery.registry.Utils.SubscriptionStatus;
|
||||||
* Jul 11, 2013 2106 djohnson SubscriptionPriority allows comparison.
|
* Jul 11, 2013 2106 djohnson SubscriptionPriority allows comparison.
|
||||||
* Sept 30,2013 1797 dhladky Abstracted and genericized.
|
* Sept 30,2013 1797 dhladky Abstracted and genericized.
|
||||||
* Oct 23, 2013 2484 dhladky Unique ID for subscriptions updated.
|
* Oct 23, 2013 2484 dhladky Unique ID for subscriptions updated.
|
||||||
* Nov 14, 2013 2548 mpduff Add a subscription type information.
|
* Nov 14, 2013 2548 mpduff Add a subscription type information.
|
||||||
* Jan 08, 2014 2615 bgonzale Added calculate start and calculate end methods.
|
* Jan 08, 2014 2615 bgonzale Added calculate start and calculate end methods.
|
||||||
* Jan 14, 2014 2459 mpduff Change Subscription status code
|
* Jan 14, 2014 2459 mpduff Change Subscription status code
|
||||||
|
* Jan 24, 2013 2709 bgonzale Added method inActivePeriodWindow.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -339,6 +340,17 @@ public interface Subscription<T extends Time, C extends Coverage> {
|
||||||
*/
|
*/
|
||||||
Calendar calculateEnd(Calendar endConstraint);
|
Calendar calculateEnd(Calendar endConstraint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given value's month/day is in the Subscription's active
|
||||||
|
* window.
|
||||||
|
*
|
||||||
|
* @param time
|
||||||
|
* time with month/day value to check.
|
||||||
|
*
|
||||||
|
* @return true if in the active period; false otherwise
|
||||||
|
*/
|
||||||
|
boolean inActivePeriodWindow(Calendar time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* isNotify flag for subscription.
|
* isNotify flag for subscription.
|
||||||
*
|
*
|
||||||
|
|
|
@ -139,6 +139,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
||||||
* Jan 14, 2014 2692 dhladky Bad Point scheduling final Empty list.
|
* Jan 14, 2014 2692 dhladky Bad Point scheduling final Empty list.
|
||||||
* Jan 14, 2014 2459 mpduff Change to subscription status.
|
* Jan 14, 2014 2459 mpduff Change to subscription status.
|
||||||
* Jan 25, 2014 2636 mpduff Don't do an initial adhoc query for a new subscription.
|
* Jan 25, 2014 2636 mpduff Don't do an initial adhoc query for a new subscription.
|
||||||
|
* Jan 24, 2013 2709 bgonzale Before scheduling adhoc, check if in active period window.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -677,11 +678,13 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
||||||
plan.getPlanStart()).getTime();
|
plan.getPlanStart()).getTime();
|
||||||
Date subscriptionValidEnd = subscription.calculateEnd(
|
Date subscriptionValidEnd = subscription.calculateEnd(
|
||||||
plan.getPlanEnd()).getTime();
|
plan.getPlanEnd()).getTime();
|
||||||
Date now = TimeUtil.newDate();
|
Calendar nowCalendar = TimeUtil.newCalendar();
|
||||||
|
Date now = nowCalendar.getTime();
|
||||||
|
|
||||||
if ((now.equals(subscriptionValidStart) || now
|
if ((now.equals(subscriptionValidStart) || now
|
||||||
.after(subscriptionValidStart))
|
.after(subscriptionValidStart))
|
||||||
&& now.before(subscriptionValidEnd)) {
|
&& now.before(subscriptionValidEnd)
|
||||||
|
&& subscription.inActivePeriodWindow(nowCalendar)) {
|
||||||
unscheduled = scheduleAdhoc(adhoc);
|
unscheduled = scheduleAdhoc(adhoc);
|
||||||
} else {
|
} else {
|
||||||
statusHandler.info(String.format(
|
statusHandler.info(String.format(
|
||||||
|
|
|
@ -115,6 +115,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
||||||
* Jan 13, 2014 2679 dhladky Small Point data updates.
|
* Jan 13, 2014 2679 dhladky Small Point data updates.
|
||||||
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
|
||||||
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
|
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
|
||||||
|
* Jan 24, 2013 2709 bgonzale Changed parameter to shouldScheduleForTime to a Calendar.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -312,25 +313,19 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
||||||
// TODO Check if we need to set sub to "OFF" state and save to
|
// TODO Check if we need to set sub to "OFF" state and save to
|
||||||
// registry
|
// registry
|
||||||
if (((RecurringSubscription<T, C>) subscription)
|
if (((RecurringSubscription<T, C>) subscription)
|
||||||
.shouldScheduleForTime(next.getTime())) {
|
.shouldScheduleForTime(next)) {
|
||||||
|
|
||||||
// Since subscriptions are based on cycles in a day, add
|
// Since subscriptions are based on cycles in a day, add
|
||||||
// one
|
// one day to the completed BandwidthSubscription to get
|
||||||
// day
|
// the next days retrieval.
|
||||||
// to the
|
|
||||||
// completed BandwidthSubscription to get the next days
|
|
||||||
// retrieval.
|
|
||||||
|
|
||||||
// Now check if that BandwidthSubscription has already
|
// Now check if that BandwidthSubscription has already
|
||||||
// been
|
// been scheduled.
|
||||||
// scheduled.
|
|
||||||
BandwidthSubscription a = bandwidthDao
|
BandwidthSubscription a = bandwidthDao
|
||||||
.getBandwidthSubscription(dao.getRegistryId(), next);
|
.getBandwidthSubscription(dao.getRegistryId(), next);
|
||||||
if (a == null) {
|
if (a == null) {
|
||||||
// Create the new BandwidthSubscription record with
|
// Create the new BandwidthSubscription record with
|
||||||
// the
|
// the next time..
|
||||||
// next
|
|
||||||
// time..
|
|
||||||
a = bandwidthDao.newBandwidthSubscription(subscription,
|
a = bandwidthDao.newBandwidthSubscription(subscription,
|
||||||
next);
|
next);
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,9 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||||
* Jan 08, 2014 2615 bgonzale Refactored getRetrievalTimes into RecurringSubscription
|
* Jan 08, 2014 2615 bgonzale Refactored getRetrievalTimes into RecurringSubscription
|
||||||
* calculateStart and calculateEnd methods.
|
* calculateStart and calculateEnd methods.
|
||||||
* Jan 24, 2014 2636 mpduff Refactored retrieval time generation.
|
* Jan 24, 2014 2636 mpduff Refactored retrieval time generation.
|
||||||
|
* Jan 24, 2013 2709 bgonzale Added inActivePeriodWindow check during retrieval time calculations
|
||||||
|
* because the calculate start and end time methods no longer use
|
||||||
|
* active period.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author djohnson
|
* @author djohnson
|
||||||
|
@ -173,11 +176,11 @@ public class BandwidthDaoUtil<T extends Time, C extends Coverage> {
|
||||||
Calendar planStart = plan.getPlanStart();
|
Calendar planStart = plan.getPlanStart();
|
||||||
|
|
||||||
// starting time when when subscription is first valid for scheduling
|
// starting time when when subscription is first valid for scheduling
|
||||||
// based on plan start, subscription start, and active period start.
|
// based on plan start and subscription start.
|
||||||
Calendar subscriptionCalculatedStart = subscription
|
Calendar subscriptionCalculatedStart = subscription
|
||||||
.calculateStart(planStart);
|
.calculateStart(planStart);
|
||||||
// end time when when subscription is last valid for scheduling based on
|
// end time when when subscription is last valid for scheduling based on
|
||||||
// plan end, subscription end, and active period end.
|
// plan end and subscription end.
|
||||||
Calendar subscriptionCalculatedEnd = subscription.calculateEnd(planEnd);
|
Calendar subscriptionCalculatedEnd = subscription.calculateEnd(planEnd);
|
||||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||||
statusHandler.debug("**** PlanStart: " + planStart.getTime());
|
statusHandler.debug("**** PlanStart: " + planStart.getTime());
|
||||||
|
@ -218,7 +221,9 @@ public class BandwidthDaoUtil<T extends Time, C extends Coverage> {
|
||||||
**/
|
**/
|
||||||
// Subscription Start and End time first
|
// Subscription Start and End time first
|
||||||
if (time.after(subscriptionCalculatedEnd)
|
if (time.after(subscriptionCalculatedEnd)
|
||||||
|| time.before(start)) {
|
|| time.before(start)
|
||||||
|
|| !subscription
|
||||||
|
.inActivePeriodWindow(time)) {
|
||||||
// don't schedule this retrieval time,
|
// don't schedule this retrieval time,
|
||||||
// outside subscription window
|
// outside subscription window
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||||
|
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
|
||||||
|
|
||||||
|
<!-- A RetrievalTask takes three constructor arguments:
|
||||||
|
1) How to find retrievals, in this case perform the actual retrieval and return it
|
||||||
|
2) What to do with found retrievals, in this case process it and send a notification event
|
||||||
|
3) How to complete retrievals, in this case update the database and send a notification event
|
||||||
|
-->
|
||||||
|
<bean id="opsnetRetrievalTask"
|
||||||
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalTask">
|
||||||
|
<constructor-arg value="OPSNET" />
|
||||||
|
<constructor-arg>
|
||||||
|
<bean
|
||||||
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.PerformRetrievalsThenReturnFinder">
|
||||||
|
<constructor-arg ref="retrievalQueue" />
|
||||||
|
<constructor-arg ref="retrievalDao" />
|
||||||
|
</bean>
|
||||||
|
</constructor-arg>
|
||||||
|
<constructor-arg>
|
||||||
|
<bean
|
||||||
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.StoreRetrievedData">
|
||||||
|
<constructor-arg value="direct-vm:dataDeliveryNotify" />
|
||||||
|
<constructor-arg ref="retrievalDao" />
|
||||||
|
</bean>
|
||||||
|
</constructor-arg>
|
||||||
|
<constructor-arg>
|
||||||
|
<bean
|
||||||
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalResponseCompleter">
|
||||||
|
<constructor-arg ref="subNotifyTask" />
|
||||||
|
<constructor-arg ref="retrievalDao" />
|
||||||
|
</bean>
|
||||||
|
</constructor-arg>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- Pick up SBN retrievals from the drop-off point -->
|
||||||
|
<bean id="sbnRetrievalTask"
|
||||||
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalTask">
|
||||||
|
<constructor-arg value="SBN" />
|
||||||
|
<constructor-arg>
|
||||||
|
<bean
|
||||||
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.PerformRetrievalsThenReturnFinder">
|
||||||
|
<constructor-arg ref="retrievalQueue" />
|
||||||
|
<constructor-arg ref="retrievalDao" />
|
||||||
|
</bean>
|
||||||
|
</constructor-arg>
|
||||||
|
<constructor-arg>
|
||||||
|
<bean
|
||||||
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.StoreRetrievedData">
|
||||||
|
<constructor-arg value="direct-vm:dataDeliveryNotify" />
|
||||||
|
<constructor-arg ref="retrievalDao" />
|
||||||
|
</bean>
|
||||||
|
</constructor-arg>
|
||||||
|
<constructor-arg>
|
||||||
|
<bean
|
||||||
|
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalResponseCompleter" >
|
||||||
|
<constructor-arg ref="subNotifyTask" />
|
||||||
|
<constructor-arg ref="retrievalDao" />
|
||||||
|
</bean>
|
||||||
|
</constructor-arg>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<util:list id="retrievalTaskList"
|
||||||
|
value-type="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalTask.RetrievalTask">
|
||||||
|
<ref bean="opsnetRetrievalTask" />
|
||||||
|
<ref bean="sbnRetrievalTask" />
|
||||||
|
</util:list>
|
||||||
|
|
||||||
|
</beans>
|
|
@ -30,6 +30,7 @@ import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -43,6 +44,7 @@ import java.util.TreeSet;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthMap;
|
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthMap;
|
||||||
|
@ -58,6 +60,7 @@ import com.raytheon.uf.common.localization.LocalizationFile;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||||
|
import com.raytheon.uf.common.time.SimulatedTime;
|
||||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||||
import com.raytheon.uf.common.time.util.TimeUtilTest;
|
import com.raytheon.uf.common.time.util.TimeUtilTest;
|
||||||
import com.raytheon.uf.edex.datadelivery.bandwidth.InMemoryBandwidthBucketDao;
|
import com.raytheon.uf.edex.datadelivery.bandwidth.InMemoryBandwidthBucketDao;
|
||||||
|
@ -86,6 +89,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||||
* Sep 25, 2013 1797 dhladky separated time and gridded time
|
* Sep 25, 2013 1797 dhladky separated time and gridded time
|
||||||
* Jan 07, 2014 2636 mpduff Removed dataset availability offset calculator (not used).
|
* Jan 07, 2014 2636 mpduff Removed dataset availability offset calculator (not used).
|
||||||
* Jan 08, 2014 2615 bgonzale Updated test.
|
* Jan 08, 2014 2615 bgonzale Updated test.
|
||||||
|
* Jan 26, 2014 2709 bgonzale Added tests for year scheduling boundary.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -97,10 +101,9 @@ public class BandwidthDaoUtilTest {
|
||||||
|
|
||||||
private final IBandwidthDao mockDao = mock(IBandwidthDao.class);
|
private final IBandwidthDao mockDao = mock(IBandwidthDao.class);
|
||||||
|
|
||||||
private final RetrievalManager retrievalManager = mock(RetrievalManager.class);
|
private RetrievalManager retrievalManager;
|
||||||
|
|
||||||
private final BandwidthDaoUtil bandwidthDaoUtil = new BandwidthDaoUtil(
|
private BandwidthDaoUtil bandwidthDaoUtil;
|
||||||
mockDao, retrievalManager);
|
|
||||||
|
|
||||||
private BandwidthMap map;
|
private BandwidthMap map;
|
||||||
|
|
||||||
|
@ -133,6 +136,9 @@ public class BandwidthDaoUtilTest {
|
||||||
Map<Network, RetrievalPlan> retrievalPlans = Maps
|
Map<Network, RetrievalPlan> retrievalPlans = Maps
|
||||||
.newEnumMap(Network.class);
|
.newEnumMap(Network.class);
|
||||||
retrievalPlans.put(Network.OPSNET, plan);
|
retrievalPlans.put(Network.OPSNET, plan);
|
||||||
|
retrievalManager = Mockito.spy(new RetrievalManager(mockDao,
|
||||||
|
new Object()));
|
||||||
|
bandwidthDaoUtil = new BandwidthDaoUtil(mockDao, retrievalManager);
|
||||||
when(retrievalManager.getRetrievalPlans()).thenReturn(retrievalPlans);
|
when(retrievalManager.getRetrievalPlans()).thenReturn(retrievalPlans);
|
||||||
|
|
||||||
// Just used to initialize the retrieval plans that are used on the mock
|
// Just used to initialize the retrieval plans that are used on the mock
|
||||||
|
@ -148,6 +154,142 @@ public class BandwidthDaoUtilTest {
|
||||||
TimeUtilTest.resumeTime();
|
TimeUtilTest.resumeTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Calendar createCal(int year, int dayOfYear) {
|
||||||
|
Calendar cal = TimeUtil.newCalendar();
|
||||||
|
cal.set(Calendar.YEAR, year);
|
||||||
|
cal.set(Calendar.DAY_OF_YEAR, dayOfYear);
|
||||||
|
return cal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Subscription createOverYearBoundary(int planStart,
|
||||||
|
int planStartYear, int subStart, int subStartYear, int subEnd,
|
||||||
|
int subEndYear, int activeStart, int activeStartYear,
|
||||||
|
int activeEnd, int activeEndYear, int planDays) {
|
||||||
|
Calendar planStartDay = createCal(planStartYear, planStart);
|
||||||
|
Calendar subStartDay = createCal(subStartYear, subStart);
|
||||||
|
Calendar subEndDay = createCal(subEndYear, subEnd);
|
||||||
|
Calendar activeStartDay = createCal(activeStartYear, activeStart);
|
||||||
|
Calendar activeEndDay = createCal(activeEndYear, activeEnd);
|
||||||
|
|
||||||
|
// setup plan with specific start time for this test.
|
||||||
|
SimulatedTime.getSystemTime().setTime(planStartDay.getTimeInMillis());
|
||||||
|
map.getRoute(Network.OPSNET).setPlanDays(planDays);
|
||||||
|
retrievalManager.getPlan(Network.OPSNET).setMap(map);
|
||||||
|
// re-init plans with new simulated time
|
||||||
|
retrievalManager.initRetrievalPlans();
|
||||||
|
return new SubscriptionBuilder()
|
||||||
|
.withSubscriptionStart(subStartDay.getTime())
|
||||||
|
.withActivePeriodStart(activeStartDay.getTime())
|
||||||
|
.withActivePeriodEnd(activeEndDay.getTime())
|
||||||
|
.withSubscriptionEnd(subEndDay.getTime()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testActivePeriodOverYearBoundary() {
|
||||||
|
int y1970 = 1970;
|
||||||
|
int y1971 = 1971;
|
||||||
|
int planStart = 364;
|
||||||
|
int subStart = 364;
|
||||||
|
int activeStart = 365;
|
||||||
|
int activeEnd = 2;
|
||||||
|
int subEnd = 3;
|
||||||
|
int planDays = 5;
|
||||||
|
Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||||
|
subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||||
|
y1971, planDays);
|
||||||
|
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||||
|
Integer.valueOf(9), Integer.valueOf(0)));
|
||||||
|
|
||||||
|
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||||
|
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||||
|
|
||||||
|
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||||
|
.getRetrievalTimes(subscription, cycles);
|
||||||
|
|
||||||
|
List<Calendar> calendarDaysOfTheYear = createCalendarListForSpecifiedDaysOfTheYear(
|
||||||
|
Arrays.asList(365), y1970);
|
||||||
|
calendarDaysOfTheYear
|
||||||
|
.addAll(createCalendarListForSpecifiedDaysOfTheYear(
|
||||||
|
Arrays.asList(01), y1971));
|
||||||
|
|
||||||
|
verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||||
|
calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testActivePeriodJustBeforeYearBoundary() {
|
||||||
|
int y1970 = 1970;
|
||||||
|
int y1971 = 1971;
|
||||||
|
int planStart = 362;
|
||||||
|
int subStart = 362;
|
||||||
|
int activeStart = 363;
|
||||||
|
int activeEnd = 365;
|
||||||
|
int subEnd = 2;
|
||||||
|
int planDays = 5;
|
||||||
|
Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||||
|
subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||||
|
y1971, planDays);
|
||||||
|
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||||
|
Integer.valueOf(9), Integer.valueOf(0)));
|
||||||
|
|
||||||
|
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||||
|
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||||
|
|
||||||
|
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||||
|
.getRetrievalTimes(subscription, cycles);
|
||||||
|
|
||||||
|
List<Calendar> calendarDaysOfTheYear = createCalendarListForSpecifiedDaysOfTheYear(
|
||||||
|
Arrays.asList(363, 364), y1970);
|
||||||
|
|
||||||
|
verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||||
|
calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testActivePeriodJustAfterYearBoundary() {
|
||||||
|
int y1970 = 1970;
|
||||||
|
int y1971 = 1971;
|
||||||
|
int planStart = 364;
|
||||||
|
int subStart = 364;
|
||||||
|
int activeStart = 1;
|
||||||
|
int activeEnd = 3;
|
||||||
|
int subEnd = 4;
|
||||||
|
int planDays = 6;
|
||||||
|
Subscription subscription = createOverYearBoundary(planStart, y1970,
|
||||||
|
subStart, y1970, subEnd, y1971, activeStart, y1970, activeEnd,
|
||||||
|
y1971, planDays);
|
||||||
|
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||||
|
Integer.valueOf(9), Integer.valueOf(0)));
|
||||||
|
|
||||||
|
TreeSet<Integer> cycles = new TreeSet<Integer>(
|
||||||
|
((GriddedTime) subscription.getTime()).getCycleTimes());
|
||||||
|
|
||||||
|
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||||
|
.getRetrievalTimes(subscription, cycles);
|
||||||
|
|
||||||
|
List<Calendar> calendarDaysOfTheYear = createCalendarListForSpecifiedDaysOfTheYear(
|
||||||
|
Arrays.asList(1, 2), y1971);
|
||||||
|
|
||||||
|
verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||||
|
calendarDaysOfTheYear, cycles, subscriptionTimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Calendar> createCalendarListForSpecifiedDaysOfTheYear(
|
||||||
|
Collection<Integer> daysOfTheYear, int year) {
|
||||||
|
List<Calendar> calendarList = new ArrayList<Calendar>(
|
||||||
|
daysOfTheYear.size());
|
||||||
|
for (int dayOfTheYear : daysOfTheYear) {
|
||||||
|
Calendar cal = TimeUtil.newCalendar();
|
||||||
|
cal.set(Calendar.YEAR, year);
|
||||||
|
cal.set(Calendar.DAY_OF_YEAR, dayOfTheYear);
|
||||||
|
calendarList.add(cal);
|
||||||
|
}
|
||||||
|
return calendarList;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRetrievalTimesReturnsBaseReferenceTimesInPlanWindow() {
|
public void testGetRetrievalTimesReturnsBaseReferenceTimesInPlanWindow() {
|
||||||
// Make sure the subscription is "active" within the plan period
|
// Make sure the subscription is "active" within the plan period
|
||||||
|
@ -165,7 +307,7 @@ public class BandwidthDaoUtilTest {
|
||||||
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
SortedSet<Calendar> subscriptionTimes = bandwidthDaoUtil
|
||||||
.getRetrievalTimes(subscription, cycles);
|
.getRetrievalTimes(subscription, cycles);
|
||||||
|
|
||||||
final List<Integer> daysOfTheYear = Arrays.asList(3, 4);
|
final List<Integer> daysOfTheYear = Arrays.asList(3);
|
||||||
verifySubscriptionTimesContainsCyclesForSpecifiedDays(daysOfTheYear,
|
verifySubscriptionTimesContainsCyclesForSpecifiedDays(daysOfTheYear,
|
||||||
cycles, subscriptionTimes);
|
cycles, subscriptionTimes);
|
||||||
}
|
}
|
||||||
|
@ -257,10 +399,15 @@ public class BandwidthDaoUtilTest {
|
||||||
.getRetrievalTimes(subscription, interval);
|
.getRetrievalTimes(subscription, interval);
|
||||||
|
|
||||||
// Expected size is two per hour (0 and 30 minutes), for every hour,
|
// Expected size is two per hour (0 and 30 minutes), for every hour,
|
||||||
// over the retrieval plan days (2), plus 1 because the retrieval plan
|
// over the retrieval plan days (2), minus the hours for the last day
|
||||||
// ends on a 0 minute time
|
// because active period is exclusive of the last day (ending hour
|
||||||
final int expectedSize = TimeUtil.HOURS_PER_DAY * plan.getPlanDays()
|
// constraint for the last day is 00Z)
|
||||||
* 2 + 1;
|
Calendar activeEnd = (Calendar) plan.getPlanEnd().clone();
|
||||||
|
activeEnd = TimeUtil.minCalendarFields(activeEnd, Calendar.MILLISECOND,
|
||||||
|
Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY);
|
||||||
|
long subPeriodInHours = (activeEnd.getTimeInMillis() - plan
|
||||||
|
.getPlanStart().getTimeInMillis()) / TimeUtil.MILLIS_PER_HOUR;
|
||||||
|
final int expectedSize = (int) (subPeriodInHours * 2);
|
||||||
assertThat(subscriptionTimes, hasSize(expectedSize));
|
assertThat(subscriptionTimes, hasSize(expectedSize));
|
||||||
|
|
||||||
// Make sure we have the expected number of 0 and 30 minute scheduled
|
// Make sure we have the expected number of 0 and 30 minute scheduled
|
||||||
|
@ -277,7 +424,7 @@ public class BandwidthDaoUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
final int halfTheTimes = subscriptionTimes.size() / 2;
|
final int halfTheTimes = subscriptionTimes.size() / 2;
|
||||||
assertThat(numberOfZeroMinuteTimes, is(equalTo(halfTheTimes + 1)));
|
assertThat(numberOfZeroMinuteTimes, is(equalTo(halfTheTimes)));
|
||||||
assertThat(numberOfThirtyMinuteTimes, is(equalTo(halfTheTimes)));
|
assertThat(numberOfThirtyMinuteTimes, is(equalTo(halfTheTimes)));
|
||||||
|
|
||||||
// Would be nice to verify the days and hours, but the cycle based tests
|
// Would be nice to verify the days and hours, but the cycle based tests
|
||||||
|
@ -311,6 +458,44 @@ public class BandwidthDaoUtilTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies the subscription times contains the cycles for the specified
|
||||||
|
* days.
|
||||||
|
*
|
||||||
|
* @param daysOfTheYear
|
||||||
|
* @param cycles
|
||||||
|
* @param subscriptionTimes
|
||||||
|
*/
|
||||||
|
private void verifySubscriptionTimesContainsCyclesForSpecifiedCalendarDays(
|
||||||
|
Collection<Calendar> daysOfTheYear, Collection<Integer> cycles,
|
||||||
|
SortedSet<Calendar> subscriptionTimes) {
|
||||||
|
boolean success = true;
|
||||||
|
StringBuilder sb = new StringBuilder(
|
||||||
|
"Expected to find retrieval times: ");
|
||||||
|
int countOfTimes = 0;
|
||||||
|
|
||||||
|
for (Calendar dayOfTheYear : daysOfTheYear) {
|
||||||
|
for (Integer cycle : cycles) {
|
||||||
|
Calendar cal = (Calendar) dayOfTheYear.clone();
|
||||||
|
TimeUtil.minCalendarFields(cal, Calendar.MILLISECOND,
|
||||||
|
Calendar.SECOND, Calendar.MINUTE);
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, cycle);
|
||||||
|
success = success && subscriptionTimes.contains(cal);
|
||||||
|
++countOfTimes;
|
||||||
|
sb.append(BandwidthUtil.format(cal)).append(
|
||||||
|
String.format(" %1$tZ ", cal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append("\nIn: ");
|
||||||
|
for (Calendar subTime : subscriptionTimes) {
|
||||||
|
sb.append(BandwidthUtil.format(subTime)).append(
|
||||||
|
String.format(" %1$tZ ", subTime));
|
||||||
|
}
|
||||||
|
assertTrue(sb.toString(), success);
|
||||||
|
assertTrue(sb.toString(),
|
||||||
|
countOfTimes == subscriptionTimes.size());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies the subscription times do not contain the cycles for the
|
* Verifies the subscription times do not contain the cycles for the
|
||||||
* specified days.
|
* specified days.
|
||||||
|
|
Loading…
Add table
Reference in a new issue