public class ExecutorReservationHandle extends Object implements AutoCloseable
This reservation should be closed by the same thread that acquired it,
otherwise an #IllegalMonitorStateException
will be thrown.
A reservation cannot be acquired twice - any subsequent reservation
attempts after a successful one will result in #IllegalStateException
Constructor and Description |
---|
ExecutorReservationHandle(Executor executor,
org.apache.kafka.common.utils.Time time)
Acquires the Executor's reservation
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
static ExecutorReservationHandle |
reserveAndAbortOngoingExecutions(Executor executor,
org.apache.kafka.common.utils.Time time,
Duration executionAbortTimeout,
Duration executionRefreshTime)
Attempts to acquire a reservation on the given
executor , blocking other threads from executing proposals
and, if successfully reserved, aborts all of its ongoing executions. |
void |
stopExecution()
Asynchronously stop the execution of execution proposal tasks
|
public ExecutorReservationHandle(Executor executor, org.apache.kafka.common.utils.Time time)
public void close()
close
in interface AutoCloseable
public void stopExecution()
public static ExecutorReservationHandle reserveAndAbortOngoingExecutions(Executor executor, org.apache.kafka.common.utils.Time time, Duration executionAbortTimeout, Duration executionRefreshTime) throws TimeoutException
executor
, blocking other threads from executing proposals
and, if successfully reserved, aborts all of its ongoing executions.
Additionally, awaits a certain refresh time executionRefreshTime
if an ongoing execution was aborted to allow metadata
to reset in the underlying Kafka brokers.
This method is blocking. After this method returns, the caller is ensured that the given executor
is not executing any proposals.executor
- the executor to which this handle applies toexecutionAbortTimeout
- the time to await for the execution to be abortedexecutionRefreshTime
- the time to wait afterAutoCloseableReservationHandle
if the reservation is taken successfullyIllegalStateException
- if the Executor is already reserved by another threadTimeoutException
- if the aborted proposal execution doesn't stop before #executionAbortTimeout