Class DueDateChecker
- All Implemented Interfaces:
StreamProcessorLifecycleAware
This class is thread safe and can be used concurrently. However, it cannot entirely prevent
that multiple executions are scheduled. See the comment in execute(TaskResultBuilder)
for details.
-
Constructor Summary
ConstructorDescriptionDueDateChecker
(long timerResolution, boolean scheduleAsync, Function<TaskResultBuilder, Long> visitor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
onClose()
Callback which is called when StreamProcessor is on closing phase.void
onFailed()
Callback which is called when the StreamProcessor failed, during startup or processing.void
onPaused()
Callback which is called when the processing is paused, will only called after onRecovered was called before.void
onRecovered
(ReadonlyStreamProcessorContext processingContext) Callback after reprocessing was successful and before regular processing beginsvoid
Callback which is called when the processing is resumed, will only called after onPaused was called before.void
schedule
(long dueDate) Schedules the next execution of the checker and stores it innextExecution
.
-
Constructor Details
-
DueDateChecker
public DueDateChecker(long timerResolution, boolean scheduleAsync, Function<TaskResultBuilder, Long> visitor) - Parameters:
timerResolution
- The resolution in ms for the timerscheduleAsync
- Whether to schedule the execution happens asynchronously or notvisitor
- Function that runs the task and returns the next due date or -1 if there is none
-
-
Method Details
-
schedule
public void schedule(long dueDate) Schedules the next execution of the checker and stores it innextExecution
.When called it guarantees that there is an execution scheduled at or before the provided due date within the
timerResolution
.If there is no execution scheduled, it always schedules a new one. If there is already an execution scheduled for a later time (within the timer resolution), that execution is cancelled and replaced by the new one. In all other cases, no new execution is scheduled.
It is guaranteed that the next execution is scheduled at least
timerResolution
ms into the future. For example when the due date is in the past, now or in the very near future. This is to prevent the checker from being immediately rescheduled and thus not giving any other tasks a chance to run.This method is thread safe and can be called concurrently. On concurrent scheduling, this execution is cancelled and rescheduled.
- Parameters:
dueDate
- The due date for the next execution
-
onRecovered
Description copied from interface:StreamProcessorLifecycleAware
Callback after reprocessing was successful and before regular processing begins- Specified by:
onRecovered
in interfaceStreamProcessorLifecycleAware
-
onClose
public void onClose()Description copied from interface:StreamProcessorLifecycleAware
Callback which is called when StreamProcessor is on closing phase.- Specified by:
onClose
in interfaceStreamProcessorLifecycleAware
-
onFailed
public void onFailed()Description copied from interface:StreamProcessorLifecycleAware
Callback which is called when the StreamProcessor failed, during startup or processing.- Specified by:
onFailed
in interfaceStreamProcessorLifecycleAware
-
onPaused
public void onPaused()Description copied from interface:StreamProcessorLifecycleAware
Callback which is called when the processing is paused, will only called after onRecovered was called before.- Specified by:
onPaused
in interfaceStreamProcessorLifecycleAware
-
onResumed
public void onResumed()Description copied from interface:StreamProcessorLifecycleAware
Callback which is called when the processing is resumed, will only called after onPaused was called before.- Specified by:
onResumed
in interfaceStreamProcessorLifecycleAware
-