/** * Constructor. * * @param defaultEventInterval * default timer value to use for interval between events. * This puts an upper bound for the timer value * @param minimumEventInterval * for loading {@link DistributionSet#getModules()}. This * puts a lower bound to the timer value * @param timerUnit * representing the unit of time to be used for timer. */ EventTimer(final String defaultEventInterval, final String minimumEventInterval, final TemporalUnit timeUnit) { this.defaultEventInterval = defaultEventInterval; this.defaultEventIntervalDuration = MaintenanceScheduleHelper.convertToISODuration(defaultEventInterval); this.minimumEventInterval = minimumEventInterval; this.minimumEventIntervalDuration = MaintenanceScheduleHelper.convertToISODuration(minimumEventInterval); this.timeUnit = timeUnit; }
/** * Constructor. * * @param defaultEventInterval * default timer value to use for interval between events. * This puts an upper bound for the timer value * @param minimumEventInterval * for loading {@link DistributionSet#getModules()}. This * puts a lower bound to the timer value * @param timerUnit * representing the unit of time to be used for timer. */ EventTimer(final String defaultEventInterval, final String minimumEventInterval, final TemporalUnit timeUnit) { this.defaultEventInterval = defaultEventInterval; this.defaultEventIntervalDuration = MaintenanceScheduleHelper.convertToISODuration(defaultEventInterval); this.minimumEventInterval = minimumEventInterval; this.minimumEventIntervalDuration = MaintenanceScheduleHelper.convertToISODuration(minimumEventInterval); this.timeUnit = timeUnit; }
/** * Returns the end time of next available or active maintenance window for * the {@link Action} as {@link ZonedDateTime}. If a maintenance window is * already active, the end time of currently active window is returned. * * @return the end time of window as { @link Optional<ZonedDateTime>}. */ private Optional<ZonedDateTime> getMaintenanceWindowEndTime() { return getMaintenanceWindowStartTime() .map(start -> start.plus(MaintenanceScheduleHelper.convertToISODuration(maintenanceWindowDuration))); }
/** * Returns the end time of next available or active maintenance window for * the {@link Action} as {@link ZonedDateTime}. If a maintenance window is * already active, the end time of currently active window is returned. * * @return the end time of window as { @link Optional<ZonedDateTime>}. */ private Optional<ZonedDateTime> getMaintenanceWindowEndTime() { return getMaintenanceWindowStartTime() .map(start -> start.plus(MaintenanceScheduleHelper.convertToISODuration(maintenanceWindowDuration))); }
final ExecutionTime scheduleExecutor = ExecutionTime.forCron(getCronFromExpression(cronSchedule)); final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.of(timezone)); final ZonedDateTime after = now.minus(convertToISODuration(duration)); final ZonedDateTime next = scheduleExecutor.nextExecution(after); return Optional.of(next);