Class MailboxExecutorImpl
- java.lang.Object
-
- org.apache.flink.streaming.runtime.tasks.mailbox.MailboxExecutorImpl
-
- All Implemented Interfaces:
MailboxExecutor
@Internal public final class MailboxExecutorImpl extends Object implements MailboxExecutor
Implementation of an executor service build around a mailbox-based execution model.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.api.common.operators.MailboxExecutor
MailboxExecutor.MailOptions
-
-
Field Summary
-
Fields inherited from interface org.apache.flink.api.common.operators.MailboxExecutor
EMPTY_ARGS
-
-
Constructor Summary
Constructors Constructor Description MailboxExecutorImpl(TaskMailbox mailbox, int priority, StreamTaskActionExecutor actionExecutor)
MailboxExecutorImpl(TaskMailbox mailbox, int priority, StreamTaskActionExecutor actionExecutor, MailboxProcessor mailboxProcessor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(MailboxExecutor.MailOptions mailOptions, ThrowingRunnable<? extends Exception> command, String descriptionFormat, Object... descriptionArgs)
Executes the given command at some time in the future in the mailbox thread.boolean
isIdle()
boolean
shouldInterrupt()
Return if operator/function should interrupt a longer computation and return from the currently processed elemenent/watermark, for example in order to let Flink perform a checkpoint.boolean
tryYield()
This method attempts to run the command at the head of the mailbox.void
yield()
This method starts running the command at the head of the mailbox and is intended to be used by the mailbox thread to yield from a currently ongoing action to another command.
-
-
-
Constructor Detail
-
MailboxExecutorImpl
public MailboxExecutorImpl(@Nonnull TaskMailbox mailbox, int priority, StreamTaskActionExecutor actionExecutor)
-
MailboxExecutorImpl
public MailboxExecutorImpl(@Nonnull TaskMailbox mailbox, int priority, StreamTaskActionExecutor actionExecutor, MailboxProcessor mailboxProcessor)
-
-
Method Detail
-
isIdle
public boolean isIdle()
-
execute
public void execute(MailboxExecutor.MailOptions mailOptions, ThrowingRunnable<? extends Exception> command, String descriptionFormat, Object... descriptionArgs)
Description copied from interface:MailboxExecutor
Executes the given command at some time in the future in the mailbox thread.An optional description can (and should) be added to ease debugging and error-reporting. The description may contain placeholder that refer to the provided description arguments using
Formatter
syntax. The actual description is only formatted on demand.- Specified by:
execute
in interfaceMailboxExecutor
- Parameters:
mailOptions
- additional options to configure behaviour of thecommand
command
- the runnable task to add to the mailbox for execution.descriptionFormat
- the optional description for the command that is used for debugging and error-reporting.descriptionArgs
- the parameters used to format the final description string.
-
yield
public void yield() throws InterruptedException
Description copied from interface:MailboxExecutor
This method starts running the command at the head of the mailbox and is intended to be used by the mailbox thread to yield from a currently ongoing action to another command. The method blocks until another command to run is available in the mailbox and must only be called from the mailbox thread. Must only be called from the mailbox thread to not violate the single-threaded execution model.- Specified by:
yield
in interfaceMailboxExecutor
- Throws:
InterruptedException
- on interruption.
-
tryYield
public boolean tryYield()
Description copied from interface:MailboxExecutor
This method attempts to run the command at the head of the mailbox. This is intended to be used by the mailbox thread to yield from a currently ongoing action to another command. The method returns true if a command was found and executed or false if the mailbox was empty. Must only be called from the mailbox thread to not violate the single-threaded execution model.- Specified by:
tryYield
in interfaceMailboxExecutor
- Returns:
- true on successful yielding to another command, false if there was no command to yield to.
-
shouldInterrupt
public boolean shouldInterrupt()
Description copied from interface:MailboxExecutor
Return if operator/function should interrupt a longer computation and return from the currently processed elemenent/watermark, for example in order to let Flink perform a checkpoint.- Specified by:
shouldInterrupt
in interfaceMailboxExecutor
- Returns:
- whether operator/function should interrupt its computation.
-
-