Issue #2398 Fixed scheduling outside of active period/ expired window
Change-Id: I6a07a597e84351d02cb1a0da29f796d86af28107 Former-commit-id:dfc0d6d9f5
[formerly470ce5269e
[formerlyae45dee861
] [formerlydfc0d6d9f5
[formerly d5e3fdf7bd51177d24312d9daa6af7a2a4920f06]]] Former-commit-id:470ce5269e
[formerlyae45dee861
] Former-commit-id:470ce5269e
Former-commit-id:8e3f8b878c
This commit is contained in:
parent
26005e35f9
commit
7dd47d0fff
2 changed files with 62 additions and 21 deletions
|
@ -65,6 +65,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
* Nov 14, 2013 2548 mpduff Add a subscription type slot.
|
||||
* Jan 08, 2014 2615 bgonzale Implement calculate start and calculate end methods.
|
||||
* Jan 14, 2014 2459 mpduff Add subscription state.
|
||||
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -897,6 +898,19 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
|
||||
return expired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for expiration on date
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
private boolean isExpired(Date date) {
|
||||
boolean expired = false;
|
||||
if (subscriptionEnd != null && date.after(subscriptionEnd)) {
|
||||
expired = true;
|
||||
}
|
||||
return expired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current subscription status.
|
||||
|
@ -935,6 +949,19 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
return subscriptionState == SubscriptionState.ON
|
||||
&& !checkAndSetExpiration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this be scheduled for this time.
|
||||
* @param checkDate
|
||||
* @return
|
||||
*/
|
||||
public boolean shouldScheduleForTime(Date checkDate) {
|
||||
if (!isExpired(checkDate) && inWindow(checkDate)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean inWindow(Date checkDate) {
|
||||
if (activePeriodStart == null && activePeriodEnd == null) {
|
||||
|
|
|
@ -49,6 +49,7 @@ import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
|||
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PointDataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PointTime;
|
||||
import com.raytheon.uf.common.datadelivery.registry.RecurringSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||
|
@ -112,7 +113,8 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* notifications. Republish dataset metadata registry
|
||||
* insert and update events as dataset metadata events.
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -306,28 +308,40 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
for (int day = 1; day <= days; day++) {
|
||||
|
||||
next.add(Calendar.DAY_OF_YEAR, 1);
|
||||
// Since subscriptions are based on cycles in a day, add one day
|
||||
// to the
|
||||
// completed BandwidthSubscription to get the next days
|
||||
// retrieval.
|
||||
|
||||
// Now check if that BandwidthSubscription has already been
|
||||
// scheduled.
|
||||
BandwidthSubscription a = bandwidthDao
|
||||
.getBandwidthSubscription(dao.getRegistryId(), next);
|
||||
if (a == null) {
|
||||
// Create the new BandwidthSubscription record with the next
|
||||
// time..
|
||||
a = bandwidthDao.newBandwidthSubscription(subscription,
|
||||
next);
|
||||
// TODO Check if we need to set sub to "OFF" state and save to
|
||||
// registry
|
||||
if (((RecurringSubscription<T, C>) subscription)
|
||||
.shouldScheduleForTime(next.getTime())) {
|
||||
|
||||
schedule(subscription, a);
|
||||
} else {
|
||||
statusHandler
|
||||
.info("Subscription ["
|
||||
+ subscription.getName()
|
||||
+ "] has already been scheduled for baseReferenceTime ["
|
||||
+ BandwidthUtil.format(next) + "]");
|
||||
// Since subscriptions are based on cycles in a day, add
|
||||
// one
|
||||
// day
|
||||
// to the
|
||||
// completed BandwidthSubscription to get the next days
|
||||
// retrieval.
|
||||
|
||||
// Now check if that BandwidthSubscription has already
|
||||
// been
|
||||
// scheduled.
|
||||
BandwidthSubscription a = bandwidthDao
|
||||
.getBandwidthSubscription(dao.getRegistryId(), next);
|
||||
if (a == null) {
|
||||
// Create the new BandwidthSubscription record with
|
||||
// the
|
||||
// next
|
||||
// time..
|
||||
a = bandwidthDao.newBandwidthSubscription(subscription,
|
||||
next);
|
||||
|
||||
schedule(subscription, a);
|
||||
} else {
|
||||
statusHandler
|
||||
.info("Subscription ["
|
||||
+ subscription.getName()
|
||||
+ "] has already been scheduled for baseReferenceTime ["
|
||||
+ BandwidthUtil.format(next) + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue