AHeise commented on a change in pull request #9564: [FLINK-12481][FLINK-12482][FLINK-12958] Streaming runtime: integrate mailbox for timer triggers, checkpoints and AsyncWaitOperator URL: https://github.com/apache/flink/pull/9564#discussion_r319417621
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/SystemProcessingTimeService.java ########## @@ -249,89 +239,53 @@ int getNumTasksScheduled() { // ------------------------------------------------------------------------ /** - * Internal task that is invoked by the timer service and triggers the target. + * A context to which {@link ProcessingTimeCallback} would be passed to be invoked when a timer is up. */ - private static final class TriggerTask implements Runnable { + public interface ScheduledCallbackExecutionContext { - private final AtomicInteger serviceStatus; - private final Object lock; - private final ProcessingTimeCallback target; - private final long timestamp; - private final AsyncExceptionHandler exceptionHandler; - - private TriggerTask( - final AtomicInteger serviceStatus, - final AsyncExceptionHandler exceptionHandler, - final Object lock, - final ProcessingTimeCallback target, - final long timestamp) { - - this.serviceStatus = Preconditions.checkNotNull(serviceStatus); - this.exceptionHandler = Preconditions.checkNotNull(exceptionHandler); - this.lock = Preconditions.checkNotNull(lock); - this.target = Preconditions.checkNotNull(target); - this.timestamp = timestamp; - } + void invoke(ProcessingTimeCallback callback, long timestamp) throws InterruptedException; + } - @Override - public void run() { - synchronized (lock) { - try { - if (serviceStatus.get() == STATUS_ALIVE) { - target.onProcessingTime(timestamp); - } - } catch (Throwable t) { - TimerException asyncException = new TimerException(t); - exceptionHandler.handleAsyncException("Caught exception while processing timer.", asyncException); - } - } - } + private Runnable wrapOnTimerCallback(ProcessingTimeCallback callback, long timestamp) { + return new TimeTrackingDelegate(status, callbackExecutionContext, callback, timestamp, 0); } - /** - * Internal task which is repeatedly called by the processing time service. - */ - private static final class RepeatedTriggerTask implements Runnable { + private Runnable wrapOnTimerCallback(ProcessingTimeCallback callback, long nextTimestamp, long period) { + return new TimeTrackingDelegate(status, callbackExecutionContext, callback, nextTimestamp, period); + } + private static final class TimeTrackingDelegate implements Runnable { Review comment: Is this really a delegate? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services