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,
boolean shouldInvalidateMetrics,
String reason)
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(String reason)
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(String reason)
reason
- - the reason for stopping the executionpublic static ExecutorReservationHandle reserveAndAbortOngoingExecutions(Executor executor, org.apache.kafka.common.utils.Time time, Duration executionAbortTimeout, Duration executionRefreshTime, boolean shouldInvalidateMetrics, String reason) 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 aftershouldInvalidateMetrics
- whether to invalidate existing metricsreason
- the reason for aborting the executionAutoCloseableReservationHandle
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