public class TestProcessingTimeService extends Object implements TimerService
TimerService
and ProcessingTimeService
used strictly for testing
the processing time functionality.Constructor and Description |
---|
TestProcessingTimeService() |
Modifier and Type | Method and Description |
---|---|
void |
advance(long delta) |
Set<Long> |
getActiveTimerTimestamps() |
long |
getCurrentProcessingTime() |
int |
getNumActiveTimers() |
boolean |
isTerminated()
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 to
ProcessingTimeService.registerTimer(long, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback) or ProcessingTimeService.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.
|
void |
setCurrentTime(long timestamp) |
void |
shutdownService()
Shuts down and clean up the timer service provider hard and immediately.
|
boolean |
shutdownServiceUninterruptible(long timeoutMs)
Shuts down and clean up the timer service provider hard and immediately.
|
public long getCurrentProcessingTime()
getCurrentProcessingTime
in interface org.apache.flink.api.common.operators.ProcessingTimeService
public ScheduledFuture<?> registerTimer(long timestamp, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback target)
registerTimer
in interface org.apache.flink.api.common.operators.ProcessingTimeService
public ScheduledFuture<?> scheduleAtFixedRate(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)
ProcessingTimeService
This call behaves similar to ScheduledExecutor.scheduleAtFixedRate(Runnable, long,
long, TimeUnit)
.
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 executedpublic ScheduledFuture<?> scheduleWithFixedDelay(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback callback, long initialDelay, long period)
ProcessingTimeService
This call behaves similar to ScheduledExecutor.scheduleWithFixedDelay(Runnable,
long, long, TimeUnit)
.
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 executedpublic boolean isTerminated()
TimerService
isTerminated
in interface TimerService
public CompletableFuture<Void> quiesce()
ProcessingTimeService
ProcessingTimeService.registerTimer(long, org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback)
or ProcessingTimeService.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.
public void shutdownService()
TimerService
ProcessingTimeService.registerTimer(long,
ProcessingTimeCallback)
will result in a hard exception.shutdownService
in interface TimerService
public boolean shutdownServiceUninterruptible(long timeoutMs)
TimerService
ProcessingTimeService.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.shutdownServiceUninterruptible
in interface TimerService
timeoutMs
- timeout for blocking on the service shutdown in milliseconds.public int getNumActiveTimers()
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.