Class TestProcessingTimeService
- java.lang.Object
-
- org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService
-
- All Implemented Interfaces:
org.apache.flink.api.common.operators.ProcessingTimeService,ProcessingTimeService,TimerService
public class TestProcessingTimeService extends Object implements TimerService
This is aTimerServiceandProcessingTimeServiceused strictly for testing the processing time functionality.
-
-
Constructor Summary
Constructors Constructor Description TestProcessingTimeService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvance(long delta)Set<Long>getActiveTimerTimestamps()longgetCurrentProcessingTime()intgetNumActiveTimers()booleanisTerminated()Returns true if the service has been shut down, false otherwise.CompletableFuture<Void>quiesce()This method puts the service into a state where it does not register new timers, but returns for each call toProcessingTimeService.registerTimer(long, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback)orProcessingTimeService.scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback, long, long)a "mock" future and the "mock" future will be never completed.ScheduledFuture<?>registerTimer(long timestamp, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback target)ScheduledFuture<?>scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)Registers a task to be executed repeatedly at a fixed rate.ScheduledFuture<?>scheduleWithFixedDelay(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)Registers a task to be executed repeatedly with a fixed delay.voidsetCurrentTime(long timestamp)voidshutdownService()Shuts down and clean up the timer service provider hard and immediately.booleanshutdownServiceUninterruptible(long timeoutMs)Shuts down and clean up the timer service provider hard and immediately.
-
-
-
Method Detail
-
getCurrentProcessingTime
public long getCurrentProcessingTime()
- Specified by:
getCurrentProcessingTimein interfaceorg.apache.flink.api.common.operators.ProcessingTimeService
-
registerTimer
public ScheduledFuture<?> registerTimer(long timestamp, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback target)
- Specified by:
registerTimerin interfaceorg.apache.flink.api.common.operators.ProcessingTimeService
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)
Description copied from interface:ProcessingTimeServiceRegisters a task to be executed repeatedly at a fixed rate.This call behaves similar to
ScheduledExecutor.scheduleAtFixedRate(Runnable, long, long, TimeUnit).- Specified by:
scheduleAtFixedRatein interfaceProcessingTimeService- Parameters:
callback- to be executed after the initial delay and then after each periodinitialDelay- initial delay to start executing callbackperiod- after the initial delay after which the callback is executed- Returns:
- Scheduled future representing the task to be executed repeatedly
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)
Description copied from interface:ProcessingTimeServiceRegisters a task to be executed repeatedly with a fixed delay.This call behaves similar to
ScheduledExecutor.scheduleWithFixedDelay(Runnable, long, long, TimeUnit).- Specified by:
scheduleWithFixedDelayin interfaceProcessingTimeService- Parameters:
callback- to be executed after the initial delay and then after each periodinitialDelay- initial delay to start executing callbackperiod- after the initial delay after which the callback is executed- Returns:
- Scheduled future representing the task to be executed repeatedly
-
isTerminated
public boolean isTerminated()
Description copied from interface:TimerServiceReturns true if the service has been shut down, false otherwise.- Specified by:
isTerminatedin interfaceTimerService
-
quiesce
public CompletableFuture<Void> quiesce()
Description copied from interface:ProcessingTimeServiceThis method puts the service into a state where it does not register new timers, but returns for each call toProcessingTimeService.registerTimer(long, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback)orProcessingTimeService.scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback, long, long)a "mock" future and the "mock" future will be never completed. Furthermore, the timers registered before are prevented from firing, but the timers in running are allowed to finish.If no timer is running, the quiesce-completed future is immediately completed and returned. Otherwise, the future returned will be completed when all running timers have finished.
- Specified by:
quiescein interfaceProcessingTimeService
-
shutdownService
public void shutdownService()
Description copied from interface:TimerServiceShuts down and clean up the timer service provider hard and immediately. This does not wait for any timer to complete. Any further call toProcessingTimeService.registerTimer(long, ProcessingTimeCallback)will result in a hard exception.- Specified by:
shutdownServicein interfaceTimerService
-
shutdownServiceUninterruptible
public boolean shutdownServiceUninterruptible(long timeoutMs)
Description copied from interface:TimerServiceShuts down and clean up the timer service provider hard and immediately. This does not wait for any timer to complete. Any further call toProcessingTimeService.registerTimer(long, ProcessingTimeCallback)will result in a hard exception. This call cannot be interrupted and will block until the shutdown is completed or the timeout is exceeded.- Specified by:
shutdownServiceUninterruptiblein interfaceTimerService- Parameters:
timeoutMs- timeout for blocking on the service shutdown in milliseconds.- Returns:
- returns true iff the shutdown was completed.
-
getNumActiveTimers
public int getNumActiveTimers()
-
-