public class ExecutionTaskPlanner
extends java.lang.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 _defaultReplicaMovementTaskStrategy
.
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,
java.util.List<java.lang.String> defaultReplicaMovementStrategies,
KafkaCruiseControlConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
addExecutionProposals(java.util.Collection<ExecutionProposal> proposals,
org.apache.kafka.common.Cluster cluster,
ReplicaMovementStrategy replicaMovementStrategy)
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.
|
java.util.List<ExecutionTask> |
getInterBrokerReplicaMovementTasks(java.util.Map<java.lang.Integer,java.lang.Integer> readyBrokers,
java.util.Set<org.apache.kafka.common.TopicPartition> inProgressPartitions)
Get a list of executable inter-broker replica movements that comply with the concurrency constraint.
|
java.util.List<ExecutionTask> |
getIntraBrokerReplicaMovementTasks(java.util.Map<java.lang.Integer,java.lang.Integer> readyBrokers)
Get a list of executable intra-broker replica movements that comply with the concurrency constraint.
|
java.util.List<ExecutionTask> |
getLeadershipMovementTasks(int numTasks)
Get the leadership movement tasks, and remove them from _remainingLeadershipMovements.
|
java.util.Set<ExecutionTask> |
remainingInterBrokerReplicaMovements()
Get the remaining inter-broker replica movement tasks.
|
java.util.Set<ExecutionTask> |
remainingIntraBrokerReplicaMovements()
Get the remaining intra-broker replica movement tasks.
|
java.util.Collection<ExecutionTask> |
remainingLeadershipMovements()
Get the remaining leadership movements.
|
public ExecutionTaskPlanner(org.apache.kafka.clients.admin.ConfluentAdmin adminClient, java.util.List<java.lang.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(java.util.Collection<ExecutionProposal> proposals, org.apache.kafka.common.Cluster cluster, ReplicaMovementStrategy replicaMovementStrategy)
proposals
- Execution proposals.cluster
- Kafka cluster state.replicaMovementStrategy
- The strategy used to determine the execution order of generated replica movement tasks.public java.util.Set<ExecutionTask> remainingInterBrokerReplicaMovements()
public java.util.Set<ExecutionTask> remainingIntraBrokerReplicaMovements()
public java.util.Collection<ExecutionTask> remainingLeadershipMovements()
public java.util.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 java.util.List<ExecutionTask> getInterBrokerReplicaMovementTasks(java.util.Map<java.lang.Integer,java.lang.Integer> readyBrokers, java.util.Set<org.apache.kafka.common.TopicPartition> inProgressPartitions)
readyBrokers
- The brokers that is ready to execute more 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 java.util.List<ExecutionTask> getIntraBrokerReplicaMovementTasks(java.util.Map<java.lang.Integer,java.lang.Integer> readyBrokers)
readyBrokers
- The brokers that is ready to execute more movements.public void clear()