Package org.apache.flink.runtime.rpc
Class RpcEndpoint.MainThreadExecutor
- java.lang.Object
-
- org.apache.flink.runtime.rpc.RpcEndpoint.MainThreadExecutor
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Executor,ComponentMainThreadExecutor,org.apache.flink.util.concurrent.ScheduledExecutor
- Enclosing class:
- RpcEndpoint
protected static class RpcEndpoint.MainThreadExecutor extends Object implements ComponentMainThreadExecutor, Closeable
Executor which executes runnables in the main thread context.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor
ComponentMainThreadExecutor.DummyComponentMainThreadExecutor
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertRunningInMainThread()Returns true if the method was called in the thread of this executor.voidclose()Shutdown theScheduledThreadPoolExecutorand remove all the pending tasks.voidexecute(Runnable command)ScheduledFuture<?>schedule(Runnable command, long delay, TimeUnit unit)The mainScheduledExecutor manages the task and sends it to the gateway after the given delay.<V> ScheduledFuture<V>schedule(Callable<V> callable, long delay, TimeUnit unit)The mainScheduledExecutor manages the given callable and sends it to the gateway after the given delay.ScheduledFuture<?>scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)ScheduledFuture<?>scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
-
-
-
Method Detail
-
schedule
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
The mainScheduledExecutor manages the task and sends it to the gateway after the given delay.- Specified by:
schedulein interfaceorg.apache.flink.util.concurrent.ScheduledExecutor- Parameters:
command- the task to execute in the futuredelay- the time from now to delay the executionunit- the time unit of the delay parameter- Returns:
- a ScheduledFuture representing the completion of the scheduled task
-
schedule
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
The mainScheduledExecutor manages the given callable and sends it to the gateway after the given delay.- Specified by:
schedulein interfaceorg.apache.flink.util.concurrent.ScheduledExecutor- Type Parameters:
V- result type of the callable- Parameters:
callable- the callable to executedelay- the time from now to delay the executionunit- the time unit of the delay parameter- Returns:
- a ScheduledFuture which holds the future value of the given callable
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
- Specified by:
scheduleAtFixedRatein interfaceorg.apache.flink.util.concurrent.ScheduledExecutor
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
- Specified by:
scheduleWithFixedDelayin interfaceorg.apache.flink.util.concurrent.ScheduledExecutor
-
assertRunningInMainThread
public void assertRunningInMainThread()
Description copied from interface:ComponentMainThreadExecutorReturns true if the method was called in the thread of this executor.- Specified by:
assertRunningInMainThreadin interfaceComponentMainThreadExecutor
-
close
public void close()
Shutdown theScheduledThreadPoolExecutorand remove all the pending tasks.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-