@ThreadSafe public class SbkAdminUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SbkAdminUtils.ReplicaDescription
A description of a certain
TopicPartition 's replicas |
Constructor and Description |
---|
SbkAdminUtils(org.apache.kafka.clients.admin.ConfluentAdmin adminClient,
KafkaCruiseControlConfig config) |
Modifier and Type | Method and Description |
---|---|
AdminClientResult<org.apache.kafka.clients.admin.AlterBrokerReplicaExclusionsResult.ExclusionsResult> |
alterBrokerReplicaExclusions(org.apache.kafka.clients.admin.ExclusionOp op,
Collection<Integer> brokerIds)
Alter replica exclusions for a set of brokers.
|
int |
cancelInterBrokerReplicaMovements(List<org.apache.kafka.common.TopicPartition> partitionReassignmentsToCancel)
Cancels any partition reassignments for the given topic partitions
|
AdminClientResult<KafkaCluster> |
describeCluster()
Describes the Kafka cluster, listing all the online brokers.
|
AdminClientResult<KafkaCluster> |
describeCluster(int timeoutMs)
Describes the Kafka cluster, listing all the online brokers.
|
AdminClientResult<Set<Integer>> |
describeCurrentlyExcludedBrokers()
List brokers with replica exclusions (for any reason)
|
void |
executeIntraBrokerReplicaMovements(List<ExecutionTask> tasksToExecute,
ExecutionTaskManager executionTaskManager)
Execute intra-broker replica movement tasks by sending alterReplicaLogDirs request.
|
Map<ExecutionTask,org.apache.kafka.clients.admin.DescribeReplicaLogDirsResult.ReplicaLogDirInfo> |
getLogdirInfoForExecutionTask(Collection<ExecutionTask> tasks)
Fetch the logdir information for subject replicas in intra-broker replica movement tasks.
|
Map<org.apache.kafka.common.TopicPartition,SbkAdminUtils.ReplicaDescription> |
getReplicasForPartitions(Collection<org.apache.kafka.common.TopicPartition> topicPartitions)
Returns the replicas for a given set of partitions.
|
static RuntimeException |
handleAdminClientException(RuntimeException e)
This looks for cause of
ExecutionException and then gets its cause and
throws that instead. |
boolean |
isOngoingIntraBrokerReplicaMovement(Collection<Integer> brokersToCheck)
Check whether there is ongoing intra-broker replica movement.
|
Map<org.apache.kafka.common.TopicPartition,Executor.PartitionReplicas> |
listTargetReplicasBeingReassigned(Optional<Set<org.apache.kafka.common.TopicPartition>> partitionsOpt)
Lists the partitions being reassigned in the cluster.
|
static <E extends Throwable> |
sneakyThrow(Throwable e) |
public SbkAdminUtils(org.apache.kafka.clients.admin.ConfluentAdmin adminClient, KafkaCruiseControlConfig config)
public AdminClientResult<KafkaCluster> describeCluster() throws InterruptedException
describeClusterResponseTimeoutMs
.AdminClientResult
.InterruptedException
public AdminClientResult<KafkaCluster> describeCluster(int timeoutMs) throws InterruptedException
timeoutMs
.timeoutMs
- AdminClientResult
.InterruptedException
public AdminClientResult<org.apache.kafka.clients.admin.AlterBrokerReplicaExclusionsResult.ExclusionsResult> alterBrokerReplicaExclusions(org.apache.kafka.clients.admin.ExclusionOp op, Collection<Integer> brokerIds) throws InterruptedException
op
- - whether the operation should SET or DELETE the exclusionsbrokerIds
- - brokers to alter replica exclusions forInterruptedException
public AdminClientResult<Set<Integer>> describeCurrentlyExcludedBrokers() throws InterruptedException, TimeoutException
InterruptedException
TimeoutException
public Map<org.apache.kafka.common.TopicPartition,SbkAdminUtils.ReplicaDescription> getReplicasForPartitions(Collection<org.apache.kafka.common.TopicPartition> topicPartitions) throws InterruptedException
topicPartitions
- the partitions to fetch the replicas fortopicPartitions
is present in the map, even if it doesn't exist in Kafka,
and SbkAdminUtils.ReplicaDescription.replicaSet
to point to a listInterruptedException
public int cancelInterBrokerReplicaMovements(List<org.apache.kafka.common.TopicPartition> partitionReassignmentsToCancel)
public Map<ExecutionTask,org.apache.kafka.clients.admin.DescribeReplicaLogDirsResult.ReplicaLogDirInfo> getLogdirInfoForExecutionTask(Collection<ExecutionTask> tasks)
tasks
- The tasks to check.public void executeIntraBrokerReplicaMovements(List<ExecutionTask> tasksToExecute, ExecutionTaskManager executionTaskManager)
tasksToExecute
- The tasks to execute.executionTaskManager
- The task manager to do bookkeeping for task execution state.public boolean isOngoingIntraBrokerReplicaMovement(Collection<Integer> brokersToCheck)
brokersToCheck
- List of broker to check.public Map<org.apache.kafka.common.TopicPartition,Executor.PartitionReplicas> listTargetReplicasBeingReassigned(Optional<Set<org.apache.kafka.common.TopicPartition>> partitionsOpt)
partitionsOpt
- - an option of a set of partitions we want to check for reassignments.
An empty value will search for all reassigning partitionspublic static <E extends Throwable> void sneakyThrow(Throwable e) throws E extends Throwable
E extends Throwable
public static RuntimeException handleAdminClientException(RuntimeException e)
ExecutionException
and then gets its cause and
throws that instead. For AdminClient api failure, the cause is an ApiException
Even though the method always throws and never returns a value, the return type
is a RuntimeException which allows clients to invoke this method as:
throw SbkAdminUtils.handleAdminClientException(e);
which keeps compilers of methods that return a value happy.