@Override public List<ScheduledRuntime> getAllScheduledRunTimes(ProgramId program, SchedulableProgramType programType, long startTimeSecs, long endTimeSecs) throws SchedulerException { return timeScheduler.getAllScheduledRunTimes(program, programType, startTimeSecs, endTimeSecs); }
@Override public List<ScheduledRuntime> getAllScheduledRunTimes(ProgramId program, SchedulableProgramType programType, long startTimeSecs, long endTimeSecs) throws SchedulerException { return timeScheduler.getAllScheduledRunTimes(program, programType, startTimeSecs, endTimeSecs); }
@Test public void testNextSchedule() throws Exception { // a schedule to be triggered every 5 minutes ProgramSchedule sched = new ProgramSchedule("tsched11", "two times schedule", PROG1_ID, ImmutableMap.of("prop2", "xx"), new TimeTrigger("*/5 * * * *"), Collections.emptyList()); timeScheduler.addProgramSchedule(sched); // schedule is by default SUSPENDED after being added, resume it to enable the schedule timeScheduler.resumeProgramSchedule(sched); long currentTimeInSeconds = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()); long startTimeInSeconds = currentTimeInSeconds + TimeUnit.HOURS.toSeconds(1); long endTimeInSeconds = currentTimeInSeconds + TimeUnit.HOURS.toSeconds(3); List<ScheduledRuntime> nextRuntimes = timeScheduler.getAllScheduledRunTimes(PROG1_ID, SchedulableProgramType.WORKFLOW, startTimeInSeconds, endTimeInSeconds); // for a scan range of 1pm to 3pm. since start time is inclusive, from 1pm tp 2pm we will have 13 schedules // and from 2:05 pm to 2:55pm will have 11 schedules as end time is exclusive. in total we expect 24 schedules. Assert.assertEquals(24, nextRuntimes.size()); } }