Issue #2448 Fixed retrievals before activePeriod begins and after activePeriod expires.
Change-Id: I75269bad24731990720d30683ebf5f27344661f3 Former-commit-id: 060e719f27c20f24bae9a5603cc51d90434b8fa4
This commit is contained in:
parent
43b2f50a0a
commit
4227f3a59f
14 changed files with 186 additions and 108 deletions
|
@ -61,6 +61,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
|
||||
* Sept 30,2013 1797 dhladky Generics
|
||||
* Oct 23, 2013 2484 dhladky Unique ID for subscriptions updated.
|
||||
* Oct 30, 2013 2448 dhladky Fixed pulling data before and after activePeriod starting and ending.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -868,18 +869,23 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
if (activePeriodStart == null && activePeriodEnd == null) {
|
||||
return true;
|
||||
} else if (activePeriodStart != null && activePeriodEnd != null) {
|
||||
|
||||
Calendar startCal = TimeUtil.newGmtCalendar();
|
||||
startCal.setTime(activePeriodStart);
|
||||
startCal = TimeUtil.minCalendarFields(startCal,
|
||||
Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND,
|
||||
Calendar.MILLISECOND);
|
||||
// add the current year for true comparison
|
||||
startCal = TimeUtil.addCurrentYearCalendar(startCal);
|
||||
|
||||
activePeriodStart = startCal.getTime();
|
||||
|
||||
Calendar endCal = TimeUtil.newGmtCalendar();
|
||||
endCal.setTime(activePeriodEnd);
|
||||
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);
|
||||
|
@ -887,12 +893,14 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
|
||||
activePeriodEnd = endCal.getTime();
|
||||
|
||||
// Only concerned with month and day, need to set the years equal
|
||||
// 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));
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.raytheon.uf.common.time.domain.api.ITimePoint;
|
|||
* Mar 20, 2013 1774 randerso Add SECONDS_PER_DAY, changed SECONDS_PER_HOUR to int.
|
||||
* Apr 24, 2013 1628 mschenke Added GMT TimeZone Object constant
|
||||
* Jun 05, 2013 DR 16279 D. Friedman Add timeOfDayToAbsoluteTime
|
||||
* Oct 30, 2013 2448 dhladky Added current year addition to calendar object.
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
|
@ -458,4 +459,48 @@ public final class TimeUtil {
|
|||
*/
|
||||
private TimeUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* New Calendar from a Date
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Calendar newCalendar(final Date date) {
|
||||
Calendar t = null;
|
||||
if (date != null) {
|
||||
t = TimeUtil.newCalendar();
|
||||
t.setTime(date);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* New Calendar from an existing calendar
|
||||
* @param calendar
|
||||
* @return
|
||||
*/
|
||||
public static Calendar newCalendar(final Calendar calendar) {
|
||||
Calendar t = null;
|
||||
if (calendar != null) {
|
||||
t = TimeUtil.newCalendar();
|
||||
t.setTimeInMillis(calendar.getTimeInMillis());
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the current year to the calendar object that does not already have it set.
|
||||
* Some calendar objects are only concerned with the day and month. When a
|
||||
* comparison of years is necessary, you must add the current year to that calendar object.
|
||||
* @param calendar
|
||||
* @return
|
||||
*/
|
||||
public static Calendar addCurrentYearCalendar(final Calendar calendar) {
|
||||
|
||||
Calendar yearTime = TimeUtil.newGmtCalendar();
|
||||
calendar.set(Calendar.YEAR, yearTime.get(Calendar.YEAR));
|
||||
|
||||
return calendar;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
|
|||
* adhoc subscription.
|
||||
* Sept 25, 2013 1797 dhladky separated time from gridded time
|
||||
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
|
||||
* Oct 30, 2013 2448 dhladky Moved methods to TimeUtil.
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -307,7 +308,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
.getBandwidthSubscription();
|
||||
Calendar retrievalTime = bandwidthSubscription
|
||||
.getBaseReferenceTime();
|
||||
Calendar startTime = BandwidthUtil.copy(retrievalTime);
|
||||
Calendar startTime = TimeUtil.newCalendar(retrievalTime);
|
||||
|
||||
int delayMinutes = retrieval.getDataSetAvailablityDelay();
|
||||
int maxLatency = retrieval.getSubscriptionLatency();
|
||||
|
@ -472,7 +473,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage>
|
|||
|
||||
for (SubscriptionRetrieval retrieval : retrievals) {
|
||||
retrieval.setStartTime(now);
|
||||
Calendar endTime = BandwidthUtil.copy(now);
|
||||
Calendar endTime = TimeUtil.newCalendar(now);
|
||||
endTime.add(Calendar.MINUTE, retrieval.getSubscriptionLatency());
|
||||
retrieval.setEndTime(endTime);
|
||||
// Store the SubscriptionRetrieval - retrievalManager expects
|
||||
|
|
|
@ -262,7 +262,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
return;
|
||||
}
|
||||
|
||||
Calendar next = BandwidthUtil.copy(dao.getBaseReferenceTime());
|
||||
Calendar next = TimeUtil.newCalendar(dao.getBaseReferenceTime());
|
||||
// See how far into the future the plan goes..
|
||||
int days = retrievalManager.getPlan(dao.getRoute()).getPlanDays();
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ import javax.persistence.Table;
|
|||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.IDeepCopyable;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
||||
|
@ -41,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Oct 12, 2012 0726 djohnson Add SW history, use string version of enum.
|
||||
* Jun 24, 2013 2106 djohnson Add copy constructor.
|
||||
* Jul 11, 2013 2106 djohnson Use SubscriptionPriority enum.
|
||||
* Oct 30, 2013 2448 dhladky Moved methods to TimeUtil.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -55,7 +56,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
@DynamicSerialize
|
||||
@SequenceGenerator(name = "BANDWIDTH_SEQ", sequenceName = "bandwidth_seq", allocationSize = 1, initialValue = 1)
|
||||
public class BandwidthAllocation implements IPersistableDataObject<Long>,
|
||||
ISerializableObject, Serializable, IDeepCopyable<BandwidthAllocation> {
|
||||
Serializable, IDeepCopyable<BandwidthAllocation> {
|
||||
|
||||
private static final long serialVersionUID = 743702044231376839L;
|
||||
|
||||
|
@ -130,19 +131,19 @@ public class BandwidthAllocation implements IPersistableDataObject<Long>,
|
|||
public BandwidthAllocation(BandwidthAllocation from) {
|
||||
final Calendar fromActualEnd = from.getActualEnd();
|
||||
if (fromActualEnd != null) {
|
||||
this.setActualEnd(BandwidthUtil.copy(fromActualEnd));
|
||||
this.setActualEnd(TimeUtil.newCalendar(fromActualEnd));
|
||||
}
|
||||
final Calendar fromActualStart = from.getActualStart();
|
||||
if (fromActualStart != null) {
|
||||
this.setActualStart(BandwidthUtil.copy(fromActualStart));
|
||||
this.setActualStart(TimeUtil.newCalendar(fromActualStart));
|
||||
}
|
||||
final Calendar fromStartTime = from.getStartTime();
|
||||
if (fromStartTime != null) {
|
||||
this.setStartTime(BandwidthUtil.copy(fromStartTime));
|
||||
this.setStartTime(TimeUtil.newCalendar(fromStartTime));
|
||||
}
|
||||
final Calendar fromEndTime = from.getEndTime();
|
||||
if (fromEndTime != null) {
|
||||
this.setEndTime(BandwidthUtil.copy(fromEndTime));
|
||||
this.setEndTime(TimeUtil.newCalendar(fromEndTime));
|
||||
}
|
||||
|
||||
this.setAgentType(from.getAgentType());
|
||||
|
|
|
@ -15,9 +15,9 @@ import org.hibernate.annotations.Cache;
|
|||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.IDeepCopyable;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
||||
|
||||
|
@ -33,6 +33,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 19, 2012 0726 djohnson Added SW history.
|
||||
* Jun 24, 2013 2106 djohnson Add copy constructor.
|
||||
* Oct 30, 2013 2448 dhladky Moved methods to TimeUtil.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -45,7 +46,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
@SequenceGenerator(name = "BANDWIDTH_SEQ", sequenceName = "bandwidth_datasetupdate_seq", allocationSize = 1)
|
||||
@DynamicSerialize
|
||||
public class BandwidthDataSetUpdate implements IPersistableDataObject<Long>,
|
||||
Serializable, ISerializableObject, IDeepCopyable<BandwidthDataSetUpdate> {
|
||||
Serializable, IDeepCopyable<BandwidthDataSetUpdate> {
|
||||
|
||||
private static final long serialVersionUID = 20120723L;
|
||||
|
||||
|
@ -92,13 +93,12 @@ public class BandwidthDataSetUpdate implements IPersistableDataObject<Long>,
|
|||
* the instance to copy
|
||||
*/
|
||||
public BandwidthDataSetUpdate(BandwidthDataSetUpdate bandwidthDataSetUpdate) {
|
||||
this.dataSetBaseTime = BandwidthUtil
|
||||
.copy(bandwidthDataSetUpdate.dataSetBaseTime);
|
||||
this.dataSetBaseTime = TimeUtil.newCalendar(bandwidthDataSetUpdate.dataSetBaseTime);
|
||||
this.dataSetName = bandwidthDataSetUpdate.dataSetName;
|
||||
this.dataSetType = bandwidthDataSetUpdate.dataSetType;
|
||||
this.id = bandwidthDataSetUpdate.id;
|
||||
this.providerName = bandwidthDataSetUpdate.providerName;
|
||||
this.updateTime = BandwidthUtil.copy(bandwidthDataSetUpdate.updateTime);
|
||||
this.updateTime = TimeUtil.newCalendar(bandwidthDataSetUpdate.updateTime);
|
||||
this.url = bandwidthDataSetUpdate.url;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ import javax.persistence.Table;
|
|||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
|
||||
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.IDeepCopyable;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
||||
|
||||
|
@ -37,6 +37,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Jun 13, 2013 2095 djohnson Add flag for whether or not data set update should be looked for on aggregating.
|
||||
* Jun 24, 2013 2106 djohnson Add copy constructor.
|
||||
* Jul 11, 2013 2106 djohnson Use SubscriptionPriority enum, remove the Subscription.
|
||||
* Oct 30, 2013 2448 dhladky Moved methods to TimeUtil.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,8 +49,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
@DynamicSerialize
|
||||
@SequenceGenerator(name = "BANDWIDTH_SEQ", sequenceName = "bandwidth_seq", allocationSize = 1, initialValue = 1)
|
||||
public class BandwidthSubscription extends PersistableDataObject<Long>
|
||||
implements Serializable, ISerializableObject,
|
||||
IDeepCopyable<BandwidthSubscription> {
|
||||
implements Serializable, IDeepCopyable<BandwidthSubscription> {
|
||||
|
||||
private static final long serialVersionUID = 20120723L;
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class BandwidthSubscription extends PersistableDataObject<Long>
|
|||
* @param bandwidthSubscription
|
||||
*/
|
||||
public BandwidthSubscription(BandwidthSubscription bandwidthSubscription) {
|
||||
this.baseReferenceTime = BandwidthUtil.copy(bandwidthSubscription
|
||||
this.baseReferenceTime = TimeUtil.newCalendar(bandwidthSubscription
|
||||
.getBaseReferenceTime());
|
||||
this.checkForDataSetUpdate = bandwidthSubscription.checkForDataSetUpdate;
|
||||
this.cycle = bandwidthSubscription.cycle;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Calendar;
|
|||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.IDeepCopyable;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
||||
|
@ -22,6 +23,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Nov 09, 2012 1286 djohnson Add getters for bytes.
|
||||
* Jun 24, 2013 2106 djohnson Add copy constructor.
|
||||
* Jul 11, 2013 2106 djohnson Use SubscriptionPriority enum.
|
||||
* Oct 30, 2013 2448 dhladky Moved methods to TimeUtil.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -85,12 +87,12 @@ public class BandwidthReservation implements Serializable,
|
|||
*/
|
||||
public BandwidthReservation(BandwidthReservation from) {
|
||||
this.bandwidthBucket = from.bandwidthBucket;
|
||||
this.endTime = BandwidthUtil.copy(from.endTime);
|
||||
this.endTime = TimeUtil.newCalendar(from.endTime);
|
||||
this.id = from.id;
|
||||
this.network = from.network;
|
||||
this.priority = from.priority;
|
||||
this.size = from.size;
|
||||
this.startTime = BandwidthUtil.copy(from.startTime);
|
||||
this.startTime = TimeUtil.newCalendar(from.startTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Oct 23, 2012 1286 djohnson Add ability to get/set the default bandwidth.
|
||||
* Nov 20, 2012 1286 djohnson Handle null bucketIds being returned.
|
||||
* Jun 25, 2013 2106 djohnson Separate state into other classes, promote BandwidthBucket to a class proper.
|
||||
* Oct 30, 2013 2448 dhladky Moved methods to TimeUtil.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,7 +53,7 @@ public class RetrievalPlan {
|
|||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RetrievalPlan.class);
|
||||
|
||||
private IBandwidthDao bandwidthDao;
|
||||
private IBandwidthDao<?, ?> bandwidthDao;
|
||||
|
||||
// which retrieval plan
|
||||
private Network network;
|
||||
|
@ -110,7 +111,7 @@ public class RetrievalPlan {
|
|||
if (found) {
|
||||
Calendar currentBucket = BandwidthUtil.now();
|
||||
planStart = BandwidthUtil.now();
|
||||
planEnd = BandwidthUtil.copy(planStart);
|
||||
planEnd = TimeUtil.newCalendar(planStart);
|
||||
planEnd.add(Calendar.DAY_OF_YEAR, planDays);
|
||||
|
||||
// Make the buckets...
|
||||
|
@ -183,7 +184,7 @@ public class RetrievalPlan {
|
|||
// The end of the plan should always be planDays from
|
||||
// now...
|
||||
Calendar currentBucket = BandwidthUtil.now();
|
||||
Calendar newEndOfPlan = BandwidthUtil.copy(currentBucket);
|
||||
Calendar newEndOfPlan = TimeUtil.newCalendar(currentBucket);
|
||||
newEndOfPlan.add(Calendar.DAY_OF_YEAR, planDays);
|
||||
|
||||
resize(currentBucket, newEndOfPlan);
|
||||
|
@ -299,7 +300,7 @@ public class RetrievalPlan {
|
|||
this.map = map;
|
||||
}
|
||||
|
||||
public void setBandwidthDao(IBandwidthDao bandwidthDao) {
|
||||
public void setBandwidthDao(IBandwidthDao<?, ?> bandwidthDao) {
|
||||
this.bandwidthDao = bandwidthDao;
|
||||
}
|
||||
|
||||
|
@ -411,13 +412,13 @@ public class RetrievalPlan {
|
|||
public Calendar getPlanEnd() {
|
||||
// Don't want an inadvertent change to plan end, so make a copy of the
|
||||
// Calendar Object and return that.
|
||||
return BandwidthUtil.copy(planEnd);
|
||||
return TimeUtil.newCalendar(planEnd);
|
||||
}
|
||||
|
||||
public Calendar getPlanStart() {
|
||||
// Don't want an inadvertent change to plan start, so make a copy of the
|
||||
// Calendar Object and return that.
|
||||
return BandwidthUtil.copy(planStart);
|
||||
return TimeUtil.newCalendar(planStart);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -577,8 +578,8 @@ public class RetrievalPlan {
|
|||
this.bucketMinutes = fromPlan.bucketMinutes;
|
||||
this.bytesPerBucket = fromPlan.bytesPerBucket;
|
||||
this.planDays = fromPlan.planDays;
|
||||
this.planEnd = BandwidthUtil.copy(fromPlan.planEnd);
|
||||
this.planStart = BandwidthUtil.copy(fromPlan.planStart);
|
||||
this.planEnd = TimeUtil.newCalendar(fromPlan.planEnd);
|
||||
this.planStart = TimeUtil.newCalendar(fromPlan.planStart);
|
||||
this.requestMap.clear();
|
||||
this.requestMap.putAll(fromPlan.requestMap);
|
||||
this.associator.copyState(fromPlan.associator);
|
||||
|
|
|
@ -69,6 +69,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
|||
* no metadata found.
|
||||
* Sept 24, 2013 1797 dhladky separated time from GriddedTime
|
||||
* Oct 10, 2013 1797 bgonzale Refactored registry Time objects.
|
||||
* Oct 30, 2013 2448 dhladky Fixed pulling data before and after activePeriod starting and ending.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -161,92 +162,101 @@ public class BandwidthDaoUtil<T extends Time, C extends Coverage> {
|
|||
|
||||
Calendar planEnd = plan.getPlanEnd();
|
||||
Calendar planStart = plan.getPlanStart();
|
||||
Calendar activePeriodStart = null;
|
||||
Calendar activePeriodEnd = null;
|
||||
|
||||
// Make sure the RetrievalPlan's start and end times intersect
|
||||
// the Subscription's active period.
|
||||
Date activePeriodEnd = subscription.getActivePeriodEnd();
|
||||
|
||||
if (activePeriodEnd != null) {
|
||||
Date activePeriodStart = subscription.getActivePeriodStart();
|
||||
Calendar active = BandwidthUtil.copy(activePeriodStart);
|
||||
|
||||
if (subscription.getActivePeriodEnd() != null
|
||||
&& subscription.getActivePeriodStart() != null) {
|
||||
|
||||
activePeriodStart = TimeUtil.newCalendar(subscription
|
||||
.getActivePeriodStart());
|
||||
// Substitute the active periods month and day for the
|
||||
// plan start month and day.
|
||||
Calendar s = BandwidthUtil.copy(planStart);
|
||||
s.set(Calendar.MONTH, active.get(Calendar.MONTH));
|
||||
s.set(Calendar.DAY_OF_MONTH, active.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
// If the active period start in outside the plan bounds,
|
||||
Calendar start = BandwidthUtil.planToPeriodCompareCalendar(planStart, activePeriodStart);
|
||||
// If the active period start is outside the plan bounds,
|
||||
// there is no intersection - just return an empty set.
|
||||
if (s.before(planStart) && s.after(planEnd)) {
|
||||
if (start.after(planEnd)) {
|
||||
return subscriptionTimes;
|
||||
}
|
||||
|
||||
// Do the same for active plan end..
|
||||
activePeriodStart = subscription.getActivePeriodEnd();
|
||||
active = BandwidthUtil.copy(activePeriodStart);
|
||||
|
||||
activePeriodEnd = TimeUtil.newCalendar(subscription.getActivePeriodEnd());
|
||||
// Substitute the active periods month and day for the
|
||||
// plan ends month and day.
|
||||
s = BandwidthUtil.copy(planStart);
|
||||
s.set(Calendar.MONTH, active.get(Calendar.MONTH));
|
||||
s.set(Calendar.DAY_OF_MONTH, active.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
Calendar end = BandwidthUtil.planToPeriodCompareCalendar(planStart, activePeriodEnd);
|
||||
// If the active period end is before the start of the plan,
|
||||
// there is no intersection - just return an empty set.
|
||||
if (s.before(planStart)) {
|
||||
if (end.before(planStart)) {
|
||||
return subscriptionTimes;
|
||||
}
|
||||
}
|
||||
|
||||
// Now check the Subscription start and end times for intersection
|
||||
// with the RetrievalPlan...
|
||||
|
||||
// Figure out the 'active' period for a subscription..
|
||||
|
||||
Calendar subscriptionEndDate = BandwidthUtil.copy(subscription
|
||||
Calendar subscriptionEnd = TimeUtil.newCalendar(subscription
|
||||
.getSubscriptionEnd());
|
||||
Calendar subscriptionStartDate = null;
|
||||
Calendar subscriptionStart = null;
|
||||
// Check to see if this is a non-expiring subscription
|
||||
if (subscriptionEndDate == null) {
|
||||
if (subscriptionEnd == null) {
|
||||
// If there is no subscription start end dates then the largest
|
||||
// window that can be scheduled is the RetrievalPlan size..
|
||||
subscriptionEndDate = BandwidthUtil.copy(planEnd);
|
||||
subscriptionStartDate = BandwidthUtil.copy(planStart);
|
||||
subscriptionEnd = TimeUtil.newCalendar(planEnd);
|
||||
subscriptionStart = TimeUtil.newCalendar(planStart);
|
||||
} else {
|
||||
// If there is a start and end time, then modify the start and
|
||||
// end times to 'fit' within the RetrievalPlan times
|
||||
subscriptionStartDate = BandwidthUtil.copy(BandwidthUtil.max(
|
||||
subscriptionStart = TimeUtil.newCalendar(BandwidthUtil.max(
|
||||
subscription.getSubscriptionStart(), planStart));
|
||||
subscriptionEndDate = BandwidthUtil.copy(BandwidthUtil.min(
|
||||
subscriptionEnd = TimeUtil.newCalendar(BandwidthUtil.min(
|
||||
subscription.getSubscriptionEnd(), planEnd));
|
||||
}
|
||||
|
||||
// Create a Set of Calendars for all the baseReferenceTimes that a
|
||||
// Subscription can contain...
|
||||
TimeUtil.minCalendarFields(subscriptionStartDate, Calendar.MILLISECOND,
|
||||
TimeUtil.minCalendarFields(subscriptionStart, Calendar.MILLISECOND,
|
||||
Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY);
|
||||
TimeUtil.maxCalendarFields(subscriptionEnd, Calendar.MILLISECOND,
|
||||
Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY);
|
||||
|
||||
// setup active period checks if necessary
|
||||
if (activePeriodStart != null && activePeriodEnd != null) {
|
||||
// need to add the current year in order to make the checks relevant
|
||||
activePeriodStart = TimeUtil.addCurrentYearCalendar(activePeriodStart);
|
||||
activePeriodEnd = TimeUtil.addCurrentYearCalendar(activePeriodEnd);
|
||||
}
|
||||
|
||||
outerloop: while (!subscriptionStartDate.after(subscriptionEndDate)) {
|
||||
outerloop: while (!subscriptionStart.after(subscriptionEnd)) {
|
||||
|
||||
for (Integer cycle : hours) {
|
||||
subscriptionStartDate.set(Calendar.HOUR_OF_DAY, cycle);
|
||||
subscriptionStart.set(Calendar.HOUR_OF_DAY, cycle);
|
||||
for (Integer minute : minutes) {
|
||||
subscriptionStartDate.set(Calendar.MINUTE, minute);
|
||||
if (subscriptionStartDate.after(subscriptionEndDate)) {
|
||||
subscriptionStart.set(Calendar.MINUTE, minute);
|
||||
if (subscriptionStart.after(subscriptionEnd)) {
|
||||
break outerloop;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Calendar time = TimeUtil.newCalendar();
|
||||
time.setTimeInMillis(subscriptionStartDate
|
||||
time.setTimeInMillis(subscriptionStart
|
||||
.getTimeInMillis());
|
||||
// Last check for time window, this checks fine grain by hour and minute
|
||||
if (activePeriodStart != null && activePeriodEnd != null) {
|
||||
if (time.after(activePeriodEnd) || time.before(activePeriodStart)) {
|
||||
// discard this retrieval time, outside activePeriod window
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
subscriptionTimes.add(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start the next day..
|
||||
subscriptionStartDate.add(Calendar.DAY_OF_YEAR, 1);
|
||||
subscriptionStartDate.set(Calendar.HOUR_OF_DAY, hours.first());
|
||||
subscriptionStart.add(Calendar.DAY_OF_YEAR, 1);
|
||||
subscriptionStart.set(Calendar.HOUR_OF_DAY, hours.first());
|
||||
}
|
||||
|
||||
// Now walk the subscription times and throw away anything outside the
|
||||
|
@ -257,7 +267,7 @@ public class BandwidthDaoUtil<T extends Time, C extends Coverage> {
|
|||
while (itr.hasNext()) {
|
||||
|
||||
Calendar time = itr.next();
|
||||
Calendar withAvailabilityDelay = BandwidthUtil.copy(time);
|
||||
Calendar withAvailabilityDelay = TimeUtil.newCalendar(time);
|
||||
withAvailabilityDelay.add(Calendar.MINUTE, availabilityDelay);
|
||||
|
||||
// We allow base reference times that are still possible to retrieve
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
|||
* Jun 13, 2013 2095 djohnson Point subscriptions don't check for dataset updates on aggregation.
|
||||
* Jun 25, 2013 2106 djohnson CheapClone was cheap in ease, not performance.
|
||||
* Jul 11, 2013 2106 djohnson Use SubscriptionPriority enum.
|
||||
* Oct 30, 2013 2448 dhladky Moved methods to TimeUtil.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,18 +60,18 @@ public class BandwidthUtil {
|
|||
private BandwidthUtil() {
|
||||
};
|
||||
|
||||
public static int getSubscriptionLatency(Subscription subscription) {
|
||||
public static int getSubscriptionLatency(Subscription<?, ?> subscription) {
|
||||
return instance.subscriptionLatencyCalculator.getLatency(subscription);
|
||||
}
|
||||
|
||||
public static Calendar min(Date lhs, Calendar rhs) {
|
||||
return min(copy(lhs), rhs);
|
||||
return min(TimeUtil.newCalendar(lhs), rhs);
|
||||
}
|
||||
|
||||
public static Calendar max(Date lhs, Calendar rhs) {
|
||||
return max(copy(lhs), rhs);
|
||||
return max(TimeUtil.newCalendar(lhs), rhs);
|
||||
}
|
||||
|
||||
|
||||
public static Calendar max(Calendar lhs, Calendar rhs) {
|
||||
Calendar calendar = null;
|
||||
if (lhs != null && rhs != null) {
|
||||
|
@ -95,24 +96,6 @@ public class BandwidthUtil {
|
|||
return calendar;
|
||||
}
|
||||
|
||||
public static Calendar copy(final Date date) {
|
||||
Calendar t = null;
|
||||
if (date != null) {
|
||||
t = TimeUtil.newCalendar();
|
||||
t.setTime(date);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Calendar copy(final Calendar calendar) {
|
||||
Calendar t = null;
|
||||
if (calendar != null) {
|
||||
t = TimeUtil.newCalendar();
|
||||
t.setTimeInMillis(calendar.getTimeInMillis());
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seconds and milliseconds on a Calendar are not used in bandwidth
|
||||
* management and can alter some of the time arithmetic that is used
|
||||
|
@ -137,7 +120,7 @@ public class BandwidthUtil {
|
|||
*
|
||||
* @return The delay in minutes.
|
||||
*/
|
||||
public static int getDataSetAvailablityDelay(Subscription subscription) {
|
||||
public static int getDataSetAvailablityDelay(Subscription<?, ?> subscription) {
|
||||
return instance.dataSetAvailabilityCalculator
|
||||
.getDataSetAvailablityDelay(subscription);
|
||||
}
|
||||
|
@ -205,7 +188,7 @@ public class BandwidthUtil {
|
|||
* on error serializing the subscription
|
||||
*/
|
||||
public static BandwidthSubscription getSubscriptionDaoForSubscription(
|
||||
Subscription subscription, Calendar baseReferenceTime) {
|
||||
Subscription<?, ?> subscription, Calendar baseReferenceTime) {
|
||||
BandwidthSubscription dao = new BandwidthSubscription();
|
||||
|
||||
dao.setDataSetName(subscription.getDataSetName());
|
||||
|
@ -231,13 +214,13 @@ public class BandwidthUtil {
|
|||
* @return the dao
|
||||
*/
|
||||
public static BandwidthDataSetUpdate newDataSetMetaDataDao(
|
||||
DataSetMetaData dataSetMetaData) {
|
||||
DataSetMetaData<?> dataSetMetaData) {
|
||||
BandwidthDataSetUpdate dao = new BandwidthDataSetUpdate();
|
||||
// Set the fields we need to have..
|
||||
dao.setDataSetName(dataSetMetaData.getDataSetName());
|
||||
dao.setProviderName(dataSetMetaData.getProviderName());
|
||||
dao.setUpdateTime(BandwidthUtil.now());
|
||||
dao.setDataSetBaseTime(BandwidthUtil.copy(dataSetMetaData.getDate()));
|
||||
dao.setDataSetBaseTime(TimeUtil.newCalendar(dataSetMetaData.getDate()));
|
||||
dao.setUrl(dataSetMetaData.getUrl());
|
||||
|
||||
return dao;
|
||||
|
@ -280,8 +263,21 @@ public class BandwidthUtil {
|
|||
* @return true if the subscription should be rescheduled
|
||||
*/
|
||||
public static boolean subscriptionRequiresReschedule(
|
||||
Subscription subscription, Subscription old) {
|
||||
Subscription<?, ?> subscription, Subscription<?, ?> old) {
|
||||
return instance.subscriptionRescheduleStrategy
|
||||
.subscriptionRequiresReschedule(subscription, old);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the activePeriod Start/End to plan Start/End calendar
|
||||
*/
|
||||
public static Calendar planToPeriodCompareCalendar(Calendar planCalendar, Calendar activePeriod) {
|
||||
|
||||
Calendar cal = TimeUtil.newCalendar(planCalendar);
|
||||
cal.set(Calendar.MONTH, activePeriod.get(Calendar.MONTH));
|
||||
cal.set(Calendar.DAY_OF_MONTH, activePeriod.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
return cal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* end since the times will be correct now.
|
||||
* Oct 1, 2013 1797 dhladky Generics
|
||||
* Oct 10, 2013 1797 bgonzale Refactored registry Time objects.
|
||||
* Oct 28, 2013 2448 dhladky Request start time incorrectly used subscription start time.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -195,8 +196,9 @@ public class WfsRequestBuilder<T extends Time, C extends Coverage> extends Reque
|
|||
String endDateString = null;
|
||||
String startDateString = null;
|
||||
|
||||
endDateString = ogcDateFormat.get().format(inTime.getEnd());
|
||||
startDateString = ogcDateFormat.get().format(inTime.getStart());
|
||||
// need to grab the request start and end times
|
||||
endDateString = ogcDateFormat.get().format(inTime.getRequestEnd());
|
||||
startDateString = ogcDateFormat.get().format(inTime.getRequestStart());
|
||||
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
sb.append(PROPRERTYISGREATERTHAN_OPEN).append(NEW_LINE);
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||
|
@ -17,6 +18,7 @@ import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
|
|||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
||||
|
||||
|
@ -37,7 +39,8 @@ import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
|||
* Jun 04, 2013 1763 dhladky Readied for WFS Retrievals.
|
||||
* Jun 18, 2013 2120 dhladky Fixed times.
|
||||
* Sep 18, 2013 2383 bgonzale Added subscription name to log output.
|
||||
* Oct 2, 2013 1797 dhladky Generics time gridded time separation
|
||||
* Oct 2, 2013 1797 dhladky Generics time gridded time separation.
|
||||
* Oct 28, 2013 2448 dhladky Request start time incorrectly used subscription start time.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -85,8 +88,6 @@ class WfsRetrievalGenerator extends RetrievalGenerator {
|
|||
|
||||
if (sub != null) {
|
||||
|
||||
PointTime subTime = sub.getTime();
|
||||
|
||||
if (sub.getUrl() == null) {
|
||||
statusHandler
|
||||
.info("Skipping subscription "
|
||||
|
@ -94,6 +95,16 @@ class WfsRetrievalGenerator extends RetrievalGenerator {
|
|||
+ " that is unfulfillable with the current metadata (null URL.)");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
PointTime subTime = sub.getTime();
|
||||
// Gets the most recent time, which is kept as the end time.
|
||||
Date endDate = subTime.getEnd();
|
||||
// We add a little extra padding in the interval to prevent gaps in data.
|
||||
long intervalMillis = (long) (subTime.getInterval() * TimeUtil.MILLIS_PER_MINUTE * 1.5);
|
||||
// create the request start and end times.
|
||||
subTime.setRequestEnd(endDate);
|
||||
Date requestStartDate = new Date(endDate.getTime() - intervalMillis);
|
||||
subTime.setRequestStart(requestStartDate);
|
||||
|
||||
// with point data they all have the same data
|
||||
Parameter param = null;
|
||||
|
|
|
@ -77,6 +77,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Nov 12, 2012 1286 djohnson Initial creation
|
||||
* Jun 03, 2013 2038 djohnson Add test getting retrievals by dataset, provider, and status.
|
||||
* Oct 21, 2013 2292 mpduff Implement multiple data types.
|
||||
* Oct 30, 2013 2248 dhladky Moved methods to TimeUtil
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -238,7 +239,7 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
|
|||
alloc1.setStatus(RetrievalStatus.DEFERRED);
|
||||
alloc1.setEndTime(now);
|
||||
|
||||
Calendar after = BandwidthUtil.copy(now);
|
||||
Calendar after = TimeUtil.newCalendar(now);
|
||||
after.add(Calendar.HOUR, 1);
|
||||
|
||||
SubscriptionRetrieval alloc2 = SubscriptionRetrievalFixture.INSTANCE
|
||||
|
@ -451,10 +452,10 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
|
|||
// Give each a unique time
|
||||
final Calendar one = BandwidthUtil.now();
|
||||
subDao1.setBaseReferenceTime(one);
|
||||
final Calendar two = BandwidthUtil.copy(one);
|
||||
final Calendar two = TimeUtil.newCalendar(one);
|
||||
two.add(Calendar.HOUR, 1);
|
||||
subDao2.setBaseReferenceTime(two);
|
||||
final Calendar three = BandwidthUtil.copy(two);
|
||||
final Calendar three = TimeUtil.newCalendar(two);
|
||||
three.add(Calendar.HOUR, 1);
|
||||
subDao3.setBaseReferenceTime(three);
|
||||
|
||||
|
@ -508,9 +509,9 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
|
|||
public void testGetSubscriptionsByProviderDataSetAndBaseReferenceTime()
|
||||
throws SerializationException {
|
||||
final Calendar one = BandwidthUtil.now();
|
||||
final Calendar two = BandwidthUtil.copy(one);
|
||||
final Calendar two = TimeUtil.newCalendar(one);
|
||||
two.add(Calendar.HOUR, 1);
|
||||
final Calendar three = BandwidthUtil.copy(two);
|
||||
final Calendar three = TimeUtil.newCalendar(two);
|
||||
three.add(Calendar.HOUR, 1);
|
||||
|
||||
// Three entities all the same except for base reference time
|
||||
|
@ -784,7 +785,7 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
|
|||
startTime.add(Calendar.HOUR, i);
|
||||
|
||||
// ... and end time
|
||||
Calendar endTime = BandwidthUtil.copy(startTime);
|
||||
Calendar endTime = TimeUtil.newCalendar(startTime);
|
||||
endTime.add(Calendar.MINUTE, 5);
|
||||
entity.setEndTime(endTime);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue