use of com.emc.storageos.db.client.util.ExecutionWindowHelper in project coprhd-controller by CoprHD.
the class SchedulerDataManager method isExpiredOrder.
private boolean isExpiredOrder(Order order, ExecutionWindow window) {
ExecutionWindowHelper windowHelper = new ExecutionWindowHelper(window);
if (windowHelper.isExpired(order.getScheduledTime())) {
order.setOrderStatus(OrderStatus.ERROR.name());
LOG.info("order {} has expired.", order.getId());
models.save(order);
return true;
}
return false;
}
use of com.emc.storageos.db.client.util.ExecutionWindowHelper in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testDailySpanningMidnight.
@Test
public void testDailySpanningMidnight() {
// Daily at 11:30pm
ExecutionWindow window = createDailyWindow(23, 30);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
Calendar beforeTime = getDateTimeUTC(2013, Calendar.MAY, 6, 23, 0, 0);
assertDateTime(helper.calculateNext(beforeTime), 2013, Calendar.MAY, 6, 23, 30, 0);
assertDateTime(helper.calculateCurrentOrNext(beforeTime), 2013, Calendar.MAY, 6, 23, 30, 0);
Calendar duringTime = getDateTimeUTC(2013, Calendar.MAY, 6, 23, 45, 0);
assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 7, 23, 30, 0);
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 6, 23, 30, 0);
duringTime = getDateTimeUTC(2013, Calendar.MAY, 7, 0, 15, 0);
assertDateTime(helper.calculateNext(duringTime), 2013, Calendar.MAY, 7, 23, 30, 0);
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2013, Calendar.MAY, 6, 23, 30, 0);
Calendar afterTime = getDateTimeUTC(2013, Calendar.MAY, 7, 1, 0, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 7, 23, 30, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 7, 23, 30, 0);
}
use of com.emc.storageos.db.client.util.ExecutionWindowHelper in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testWeeklyAfterTime.
@Test
public void testWeeklyAfterTime() {
// Weekly on Sunday at 1:15am
ExecutionWindow window = createWeeklyWindow(Calendar.SUNDAY, 1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
Calendar afterTime = getDateTimeUTC(2013, Calendar.MAY, 5, 3, 15, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
afterTime = getDateTimeUTC(2013, Calendar.MAY, 6, 1, 10, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
afterTime = getDateTimeUTC(2013, Calendar.MAY, 7, 1, 10, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
afterTime = getDateTimeUTC(2013, Calendar.MAY, 8, 1, 10, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
afterTime = getDateTimeUTC(2013, Calendar.MAY, 9, 1, 10, 0);
assertDateTime(helper.calculateNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2013, Calendar.MAY, 12, 1, 15, 0);
}
use of com.emc.storageos.db.client.util.ExecutionWindowHelper in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testDailyWindowAfterTime.
@Test
public void testDailyWindowAfterTime() {
// Daily at 1:15am
ExecutionWindow window = createDailyWindow(1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
// Right after the window ends
Calendar afterTime = getDateTimeUTC(2000, Calendar.FEBRUARY, 5, 2, 16, 0);
assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
// Should be the next day
afterTime = getDateTimeUTC(2000, Calendar.FEBRUARY, 5, 10, 16, 0);
assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 6, 1, 15, 0);
// Last day of the month, check for rollover
afterTime = getDateTimeUTC(2000, Calendar.JANUARY, 31, 5, 0, 0);
assertDateTime(helper.calculateNext(afterTime), 2000, Calendar.FEBRUARY, 1, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2000, Calendar.FEBRUARY, 1, 1, 15, 0);
// Last day of the year, check for rollover
afterTime = getDateTimeUTC(2000, Calendar.DECEMBER, 31, 5, 0, 0);
assertDateTime(helper.calculateNext(afterTime), 2001, Calendar.JANUARY, 1, 1, 15, 0);
assertDateTime(helper.calculateCurrentOrNext(afterTime), 2001, Calendar.JANUARY, 1, 1, 15, 0);
}
use of com.emc.storageos.db.client.util.ExecutionWindowHelper in project coprhd-controller by CoprHD.
the class ExecutionWindowHelperTest method testDailyWindowDuringTime.
@Test
public void testDailyWindowDuringTime() {
// Daily at 1:15am
ExecutionWindow window = createDailyWindow(1, 15);
setLengthInHours(window, 1);
ExecutionWindowHelper helper = new ExecutionWindowHelper(window);
// Right at the start of the window
Calendar duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 1, 15, 0);
// Next will be the day after
assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
// Current or next will be today
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// One minute after the start of the window
duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 1, 16, 0);
// Next will be the day after
assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
// Current or next will be today
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// One minute before the end of the window
duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 2, 14, 0);
// Next will be the day after
assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
// Current or next will be today
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 10, 1, 15, 0);
Assert.assertTrue(helper.isActive(duringTime));
// Right at the end of the window
duringTime = getDateTimeUTC(2000, Calendar.JANUARY, 10, 2, 15, 0);
// Next will be the day after
assertDateTime(helper.calculateNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
// Current or next will be tomorrow
assertDateTime(helper.calculateCurrentOrNext(duringTime), 2000, Calendar.JANUARY, 11, 1, 15, 0);
Assert.assertFalse(helper.isActive(duringTime));
}
Aggregations