public class Executor
extends java.lang.Object
The executor class is responsible for talking to the Kafka cluster to execute the rebalance proposals. The executor is thread-safe.
Modifier and Type | Class and Description |
---|---|
class |
Executor.ReservationHandle
A helper auto closeable class for acquiring the Executor's reservation.
|
Constructor and Description |
---|
Executor(KafkaCruiseControlConfig config,
scala.Option<org.apache.zookeeper.client.ZKClientConfig> zkClientConfig,
org.apache.kafka.common.utils.Time time,
DataBalancerMetricsRegistry metricRegistry,
long demotionHistoryRetentionTimeMs,
long removalHistoryRetentionTimeMs,
AnomalyDetector anomalyDetector)
The executor class that execute the proposals generated by optimizer.
|
Modifier and Type | Method and Description |
---|---|
void |
dropRecentlyRemovedBrokers(java.util.Set<java.lang.Integer> brokersToDrop)
Drop the given brokers from the recently removed brokers.
|
java.util.concurrent.Future<?> |
executeProposals(java.util.Collection<ExecutionProposal> proposals,
java.util.Set<java.lang.Integer> unthrottledBrokers,
java.util.Set<java.lang.Integer> removedBrokers,
LoadMonitor loadMonitor,
java.lang.Integer requestedInterBrokerPartitionMovementConcurrency,
java.lang.Integer requestedIntraBrokerPartitionMovementConcurrency,
java.lang.Integer requestedLeadershipMovementConcurrency,
ReplicaMovementStrategy replicaMovementStrategy,
java.lang.String uuid,
BalanceOpExecutionCompletionCallback completionCallback)
Initialize proposal execution and start execution.
|
boolean |
hasOngoingExecution()
Whether there is an ongoing operation triggered by current Cruise Control deployment.
|
boolean |
hasOngoingPartitionReassignments()
Whether there is any ongoing partition reassignment.
|
boolean |
isReservedByOther()
Whether the Executor's is reserved (paused) by another thread.
|
java.util.Set<java.lang.Integer> |
recentlyDemotedBrokers()
Recently demoted brokers are the ones for which a demotion was started, regardless of how the process was completed.
|
java.util.Set<java.lang.Integer> |
recentlyRemovedBrokers()
Recently removed brokers are the ones for which a removal was started, regardless of how the process was completed.
|
Executor.ReservationHandle |
reserveAndAbortOngoingExecutions(java.time.Duration executionAbortTimeout)
Attempts to acquire a reservation on the Executor, blocking other threads from executing proposals
and, if successfully reserved, aborts all of its ongoing executions.
|
void |
shutdown()
Shutdown the executor.
|
void |
startUp() |
ExecutorState |
state()
Check whether the executor is executing a set of proposals.
|
boolean |
updateThrottle(long newThrottle)
Update the throttle rate in ZK (for ongoing executions)
and set a new throttle value, persisted in memory until the process dies
|
void |
userTriggeredStopExecution()
Request the executor to stop any ongoing execution.
|
public Executor(KafkaCruiseControlConfig config, scala.Option<org.apache.zookeeper.client.ZKClientConfig> zkClientConfig, org.apache.kafka.common.utils.Time time, DataBalancerMetricsRegistry metricRegistry, long demotionHistoryRetentionTimeMs, long removalHistoryRetentionTimeMs, AnomalyDetector anomalyDetector)
config
- The configurations for Cruise Control.public void startUp() throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.lang.InterruptedException
public Executor.ReservationHandle reserveAndAbortOngoingExecutions(java.time.Duration executionAbortTimeout) throws java.util.concurrent.TimeoutException
isReservedByOther()
prior to calling this method.AutoCloseableReservationHandle
if the reservation is taken successfullyjava.lang.IllegalStateException
- if the Executor is already reserved by another threadjava.util.concurrent.TimeoutException
- if the aborted proposal execution doesn't stop before #executionAbortTimeout
public void userTriggeredStopExecution()
public void dropRecentlyRemovedBrokers(java.util.Set<java.lang.Integer> brokersToDrop)
brokersToDrop
- Brokers to drop from the _latestRemoveStartTimeMsByBrokerId
.public void shutdown()
public boolean hasOngoingExecution()
public boolean isReservedByOther()
public boolean updateThrottle(long newThrottle)
newThrottle
- The new throttle rate, in bytespublic boolean hasOngoingPartitionReassignments()
public java.util.Set<java.lang.Integer> recentlyDemotedBrokers()
_demotionHistoryRetentionTimeMs
.public java.util.Set<java.lang.Integer> recentlyRemovedBrokers()
_removalHistoryRetentionTimeMs
.public ExecutorState state()
public java.util.concurrent.Future<?> executeProposals(java.util.Collection<ExecutionProposal> proposals, java.util.Set<java.lang.Integer> unthrottledBrokers, java.util.Set<java.lang.Integer> removedBrokers, LoadMonitor loadMonitor, java.lang.Integer requestedInterBrokerPartitionMovementConcurrency, java.lang.Integer requestedIntraBrokerPartitionMovementConcurrency, java.lang.Integer requestedLeadershipMovementConcurrency, ReplicaMovementStrategy replicaMovementStrategy, java.lang.String uuid, BalanceOpExecutionCompletionCallback completionCallback)
proposals
- Proposals to be executed.unthrottledBrokers
- Brokers that are not throttled in terms of the number of in/out replica movements.removedBrokers
- Removed brokers, null if no brokers has been removed.loadMonitor
- Load monitor.requestedInterBrokerPartitionMovementConcurrency
- The maximum number of concurrent inter-broker partition movements
per broker(if null, use num.concurrent.partition.movements.per.broker).requestedIntraBrokerPartitionMovementConcurrency
- The maximum number of concurrent intra-broker partition movements
(if null, use num.concurrent.intra.broker.partition.movements).requestedLeadershipMovementConcurrency
- The maximum number of concurrent leader movements
(if null, use num.concurrent.leader.movements).replicaMovementStrategy
- The strategy used to determine the execution order of generated replica movement tasks.uuid
- UUID of the execution.completionCallback
- -- a Consumer of (success, failure exception) to be invoked when the execution completes. NOT
to be invoked if this fails with an exception.