public class ExecutionTaskPlanner extends Object
Each proposal is processed and may generate one leadership movement, one inter-broker partition movement and several intra-broker partition movement tasks. Each task is assigned an execution id and managed in two ways.
This class tracks the partition movements for each broker using a sorted Set.
The task's position in this set represents its execution order. For inter-broker partition movement task, the position
is determined by the passed in ReplicaMovementStrategy
or KafkaCruiseControlConfig.DEFAULT_REPLICA_MOVEMENT_STRATEGIES_CONFIG
.
For intra-broker partition movement task, the position is determined by assigned execution id in ascending order.
The task is tracked both under source broker and destination broker's plan.
Once a task is fulfilled, the task will be removed from both source broker and destination broker's execution plan.
This class is not thread safe.
Constructor and Description |
---|
ExecutionTaskPlanner(org.apache.kafka.clients.admin.ConfluentAdmin adminClient,
List<String> defaultReplicaMovementStrategies,
KafkaCruiseControlConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
addExecutionProposals(Collection<ExecutionProposal> proposals,
org.apache.kafka.common.Cluster cluster)
Add each given proposal to execute, unless the given cluster state indicates that the proposal would be a no-op.
|
void |
clear()
Clear all the states.
|
List<ExecutionTask> |
drainInterBrokerTasks(BrokerExecutionTaskTracker brokerExecutionTracker,
Set<org.apache.kafka.common.TopicPartition> inProgressPartitions)
Drains a chunk of executable inter-broker replica movements away that comply with the concurrency constraint.
|
List<ExecutionTask> |
drainIntraBrokerTasks(BrokerExecutionTaskTracker brokerExecutionTracker)
Drains a chunk of executable intra-broker replica movements that comply with the concurrency constraint.
|
List<ExecutionTask> |
getLeadershipMovementTasks(int numTasks)
Get the leadership movement tasks, and remove them from _remainingLeadershipMovements.
|
void |
overrideInterBrokerTasksWithOrdering(Collection<ExecutionTask> tasks,
org.apache.kafka.common.Cluster cluster)
Overrides the existing inter-broker replica movements with a given set of
ExecutionTask s. |
Set<ExecutionTask> |
remainingInterBrokerReplicaMovements()
Get the remaining inter-broker replica movement tasks.
|
Set<ExecutionTask> |
remainingIntraBrokerReplicaMovements()
Get the remaining intra-broker replica movement tasks.
|
Collection<ExecutionTask> |
remainingLeadershipMovements()
Get the remaining leadership movements.
|
public ExecutionTaskPlanner(org.apache.kafka.clients.admin.ConfluentAdmin adminClient, List<String> defaultReplicaMovementStrategies, KafkaCruiseControlConfig config)
adminClient
- The adminClient to send describeReplicaLogDirs request.defaultReplicaMovementStrategies
- List of replica movement strategies.config
- The config object that holds all the Cruise Control related configs.public void addExecutionProposals(Collection<ExecutionProposal> proposals, org.apache.kafka.common.Cluster cluster)
proposals
- Execution proposals.cluster
- Kafka cluster state.public void overrideInterBrokerTasksWithOrdering(Collection<ExecutionTask> tasks, org.apache.kafka.common.Cluster cluster)
ExecutionTask
s.tasks
- - the execution tasks to be orderedcluster
- - the Kafka cluster's stateIllegalStateException
- - in case this method is called while the ExecutionTaskPlanner
still has remaining inter-broker movements.public Set<ExecutionTask> remainingInterBrokerReplicaMovements()
public Set<ExecutionTask> remainingIntraBrokerReplicaMovements()
public Collection<ExecutionTask> remainingLeadershipMovements()
public List<ExecutionTask> getLeadershipMovementTasks(int numTasks)
numTasks
- Number of tasks to remove from the _remainingLeadershipMovements. If _remainingLeadershipMovements
has less than numTasks, all tasks are removed.public List<ExecutionTask> drainInterBrokerTasks(BrokerExecutionTaskTracker brokerExecutionTracker, Set<org.apache.kafka.common.TopicPartition> inProgressPartitions)
brokerExecutionTracker
- Object tracking current replica movements.inProgressPartitions
- Topic partitions of replicas that are already in progress. This is needed because the
controller does not allow updating the ongoing replica reassignment for a partition
whose replica is being reassigned.public List<ExecutionTask> drainIntraBrokerTasks(BrokerExecutionTaskTracker brokerExecutionTracker)
brokerExecutionTracker
- Object tracking current replica movements.public void clear()