public void start() { timerService.registerTimer(timerService.getCurrentProcessingTime() + interval, this); }
public LatencyMarksEmitter( final ProcessingTimeService processingTimeService, final Output<StreamRecord<OUT>> output, long latencyTrackingInterval, final OperatorID operatorId, final int subtaskIndex) { latencyMarkTimer = processingTimeService.scheduleAtFixedRate( new ProcessingTimeCallback() { @Override public void onProcessingTime(long timestamp) throws Exception { try { // ProcessingTimeService callbacks are executed under the checkpointing lock output.emitLatencyMarker(new LatencyMarker(timestamp, operatorId, subtaskIndex)); } catch (Throwable t) { // we catch the Throwables here so that we don't trigger the processing // timer services async exception handler LOG.warn("Error while emitting latency marker.", t); } } }, 0L, latencyTrackingInterval); }
/** * The finalize method shuts down the timer. This is a fail-safe shutdown, in case the original * shutdown method was never called. * * <p>This should not be relied upon! It will cause shutdown to happen much later than if manual * shutdown is attempted, and cause threads to linger for longer than needed. */ @Override protected void finalize() throws Throwable { super.finalize(); if (timerService != null) { if (!timerService.isTerminated()) { LOG.info("Timer service is shutting down."); timerService.shutdownService(); } } cancelables.close(); }
private void tryShutdownTimerService() { if (timerService != null && !timerService.isTerminated()) { try { final long timeoutMs = getEnvironment().getTaskManagerInfo().getConfiguration(). getLong(TaskManagerOptions.TASK_CANCELLATION_TIMEOUT_TIMERS); if (!timerService.shutdownServiceUninterruptible(timeoutMs)) { LOG.warn("Timer service shutdown exceeded time limit of {} ms while waiting for pending " + "timers. Will continue with shutdown procedure.", timeoutMs); } } catch (Throwable t) { // catch and log the exception to not replace the original exception LOG.error("Could not shut down timer service", t); } } }
@Override public long currentTimeMillis() { return processingTimeService.getCurrentProcessingTime(); } };
@Override protected void init() throws Exception { getProcessingTimeService().registerTimer(0, new ProcessingTimeCallback() { @Override public void onProcessingTime(long timestamp) throws Exception { classLoaders.add(Thread.currentThread().getContextClassLoader()); syncLatch.trigger(); } }); }
lastFinishBundleTime = getProcessingTimeService().getCurrentProcessingTime(); checkFinishBundleTimer = getProcessingTimeService() .scheduleAtFixedRate( timestamp -> checkInvokeFinishBundleByTime(), bundleCheckPeriod, bundleCheckPeriod);
timerService.quiesceAndAwaitPending(); timerService.shutdownService();
@Override public long currentProcessingTime() { return processingTimeService.getCurrentProcessingTime(); }
@Override public void processElement2(StreamRecord<String> element) throws Exception { if (!semaphore.tryAcquire()) { Assert.fail("Concurrent invocation of operator functions."); } if (first) { getProcessingTimeService().registerTimer(System.currentTimeMillis() + 100, this); first = false; } numElements++; semaphore.release(); }
lastFinishBundleTime = getProcessingTimeService().getCurrentProcessingTime(); checkFinishBundleTimer = getProcessingTimeService() .scheduleAtFixedRate( timestamp -> checkInvokeFinishBundleByTime(), bundleCheckPeriod, bundleCheckPeriod);
private void tryShutdownTimerService() { if (timerService != null && !timerService.isTerminated()) { try { final long timeoutMs = getEnvironment().getTaskManagerInfo().getConfiguration(). getLong(TaskManagerOptions.TASK_CANCELLATION_TIMEOUT_TIMERS); if (!timerService.shutdownServiceUninterruptible(timeoutMs)) { LOG.warn("Timer service shutdown exceeded time limit of {} ms while waiting for pending " + "timers. Will continue with shutdown procedure.", timeoutMs); } } catch (Throwable t) { // catch and log the exception to not replace the original exception LOG.error("Could not shut down timer service", t); } } }
private void scheduleNextIdleDetectionTask() { if (idleTimeout != -1) { // reset flag; if it remains true when task fires, we have detected idleness failOnNextCheck = true; nextCheck = this.timeService.registerTimer( this.timeService.getCurrentProcessingTime() + idleTimeout, new IdlenessDetectionTask()); } }
bucketState.creationTime = processingTimeService.getCurrentProcessingTime();
@Override public void processElement(StreamRecord<String> element) throws Exception { if (!semaphore.tryAcquire()) { Assert.fail("Concurrent invocation of operator functions."); } if (first) { getProcessingTimeService().registerTimer(System.currentTimeMillis() + 100, this); first = false; } numElements++; semaphore.release(); }
lastFinishBundleTime = getProcessingTimeService().getCurrentProcessingTime(); checkFinishBundleTimer = getProcessingTimeService().scheduleAtFixedRate( new ProcessingTimeCallback() { @Override
@Test public void testExceptionReportingScheduleAtFixedRate() throws InterruptedException { final AtomicBoolean exceptionWasThrown = new AtomicBoolean(false); final OneShotLatch latch = new OneShotLatch(); final Object lock = new Object(); ProcessingTimeService timeServiceProvider = new SystemProcessingTimeService( new AsyncExceptionHandler() { @Override public void handleAsyncException(String message, Throwable exception) { exceptionWasThrown.set(true); latch.trigger(); } }, lock); timeServiceProvider.scheduleAtFixedRate( new ProcessingTimeCallback() { @Override public void onProcessingTime(long timestamp) throws Exception { throw new Exception("Exception in Timer"); } }, 0L, 100L); latch.await(); assertTrue(exceptionWasThrown.get()); }
/** * The finalize method shuts down the timer. This is a fail-safe shutdown, in case the original * shutdown method was never called. * * <p>This should not be relied upon! It will cause shutdown to happen much later than if manual * shutdown is attempted, and cause threads to linger for longer than needed. */ @Override protected void finalize() throws Throwable { super.finalize(); if (timerService != null) { if (!timerService.isTerminated()) { LOG.info("Timer service is shutting down."); timerService.shutdownService(); } } cancelables.close(); }
private void tryShutdownTimerService() { if (timerService != null && !timerService.isTerminated()) { try { final long timeoutMs = getEnvironment().getTaskManagerInfo().getConfiguration(). getLong(TaskManagerOptions.TASK_CANCELLATION_TIMEOUT_TIMERS); if (!timerService.shutdownServiceUninterruptible(timeoutMs)) { LOG.warn("Timer service shutdown exceeded time limit of {} ms while waiting for pending " + "timers. Will continue with shutdown procedure.", timeoutMs); } } catch (Throwable t) { // catch and log the exception to not replace the original exception LOG.error("Could not shut down timer service", t); } } }
@Override public void onProcessingTime(long timestamp) throws Exception { final long currentTime = processingTimeService.getCurrentProcessingTime(); buckets.onProcessingTime(currentTime); processingTimeService.registerTimer(currentTime + bucketCheckInterval, this); }