@InterfaceStability.Evolving public abstract class AdminClient extends Object implements AutoCloseable
InterfaceStability
annotation and this notice once the API is considered stable.Constructor and Description |
---|
AdminClient() |
Modifier and Type | Method and Description |
---|---|
AlterConfigsResult |
alterConfigs(Map<ConfigResource,Config> configs)
Deprecated.
Since 2.3. Use
incrementalAlterConfigs(Map) . |
abstract AlterConfigsResult |
alterConfigs(Map<ConfigResource,Config> configs,
AlterConfigsOptions options)
Deprecated.
Since 2.3. Use
incrementalAlterConfigs(Map, AlterConfigsOptions) . |
AlterReplicaLogDirsResult |
alterReplicaLogDirs(Map<TopicPartitionReplica,String> replicaAssignment)
Change the log directory for the specified replicas.
|
abstract AlterReplicaLogDirsResult |
alterReplicaLogDirs(Map<TopicPartitionReplica,String> replicaAssignment,
AlterReplicaLogDirsOptions options)
Change the log directory for the specified replicas.
|
void |
close()
Close the AdminClient and release all associated resources.
|
abstract void |
close(Duration timeout)
Close the AdminClient and release all associated resources.
|
void |
close(long duration,
TimeUnit unit)
Deprecated.
Since 2.2. Use
close(Duration) or close() . |
static AdminClient |
create(Map<String,Object> conf)
Create a new AdminClient with the given configuration.
|
static AdminClient |
create(Properties props)
Create a new AdminClient with the given configuration.
|
CreateAclsResult |
createAcls(Collection<AclBinding> acls)
This is a convenience method for #
createAcls(Collection, CreateAclsOptions) with
default options. |
abstract CreateAclsResult |
createAcls(Collection<AclBinding> acls,
CreateAclsOptions options)
Creates access control lists (ACLs) which are bound to specific resources.
|
CreateDelegationTokenResult |
createDelegationToken()
Create a Delegation Token.
|
abstract CreateDelegationTokenResult |
createDelegationToken(CreateDelegationTokenOptions options)
Create a Delegation Token.
|
CreatePartitionsResult |
createPartitions(Map<String,NewPartitions> newPartitions)
Increase the number of partitions of the topics given as the keys of
newPartitions
according to the corresponding values. |
abstract CreatePartitionsResult |
createPartitions(Map<String,NewPartitions> newPartitions,
CreatePartitionsOptions options)
Increase the number of partitions of the topics given as the keys of
newPartitions
according to the corresponding values. |
CreateTopicsResult |
createTopics(Collection<NewTopic> newTopics)
Create a batch of new topics with the default options.
|
abstract CreateTopicsResult |
createTopics(Collection<NewTopic> newTopics,
CreateTopicsOptions options)
Create a batch of new topics.
|
DeleteAclsResult |
deleteAcls(Collection<AclBindingFilter> filters)
This is a convenience method for #
deleteAcls(Collection, DeleteAclsOptions) with default options. |
abstract DeleteAclsResult |
deleteAcls(Collection<AclBindingFilter> filters,
DeleteAclsOptions options)
Deletes access control lists (ACLs) according to the supplied filters.
|
DeleteConsumerGroupsResult |
deleteConsumerGroups(Collection<String> groupIds)
Delete consumer groups from the cluster with the default options.
|
abstract DeleteConsumerGroupsResult |
deleteConsumerGroups(Collection<String> groupIds,
DeleteConsumerGroupsOptions options)
Delete consumer groups from the cluster.
|
DeleteRecordsResult |
deleteRecords(Map<TopicPartition,RecordsToDelete> recordsToDelete)
Delete records whose offset is smaller than the given offset of the corresponding partition.
|
abstract DeleteRecordsResult |
deleteRecords(Map<TopicPartition,RecordsToDelete> recordsToDelete,
DeleteRecordsOptions options)
Delete records whose offset is smaller than the given offset of the corresponding partition.
|
DeleteTopicsResult |
deleteTopics(Collection<String> topics)
This is a convenience method for #
deleteTopics(Collection, DeleteTopicsOptions)
with default options. |
abstract DeleteTopicsResult |
deleteTopics(Collection<String> topics,
DeleteTopicsOptions options)
Delete a batch of topics.
|
DescribeAclsResult |
describeAcls(AclBindingFilter filter)
This is a convenience method for #
describeAcls(AclBindingFilter, DescribeAclsOptions) with
default options. |
abstract DescribeAclsResult |
describeAcls(AclBindingFilter filter,
DescribeAclsOptions options)
Lists access control lists (ACLs) according to the supplied filter.
|
DescribeClusterResult |
describeCluster()
Get information about the nodes in the cluster, using the default options.
|
abstract DescribeClusterResult |
describeCluster(DescribeClusterOptions options)
Get information about the nodes in the cluster.
|
DescribeConfigsResult |
describeConfigs(Collection<ConfigResource> resources)
Get the configuration for the specified resources with the default options.
|
abstract DescribeConfigsResult |
describeConfigs(Collection<ConfigResource> resources,
DescribeConfigsOptions options)
Get the configuration for the specified resources.
|
DescribeConsumerGroupsResult |
describeConsumerGroups(Collection<String> groupIds)
Describe some group IDs in the cluster, with the default options.
|
abstract DescribeConsumerGroupsResult |
describeConsumerGroups(Collection<String> groupIds,
DescribeConsumerGroupsOptions options)
Describe some group IDs in the cluster.
|
DescribeDelegationTokenResult |
describeDelegationToken()
Describe the Delegation Tokens.
|
abstract DescribeDelegationTokenResult |
describeDelegationToken(DescribeDelegationTokenOptions options)
Describe the Delegation Tokens.
|
DescribeLogDirsResult |
describeLogDirs(Collection<Integer> brokers)
Query the information of all log directories on the given set of brokers
This is a convenience method for #
describeLogDirs(Collection, DescribeLogDirsOptions) with default options. |
abstract DescribeLogDirsResult |
describeLogDirs(Collection<Integer> brokers,
DescribeLogDirsOptions options)
Query the information of all log directories on the given set of brokers
This operation is supported by brokers with version 1.0.0 or higher.
|
DescribeReplicaLogDirsResult |
describeReplicaLogDirs(Collection<TopicPartitionReplica> replicas)
Query the replica log directory information for the specified replicas.
|
abstract DescribeReplicaLogDirsResult |
describeReplicaLogDirs(Collection<TopicPartitionReplica> replicas,
DescribeReplicaLogDirsOptions options)
Query the replica log directory information for the specified replicas.
|
DescribeTopicsResult |
describeTopics(Collection<String> topicNames)
Describe some topics in the cluster, with the default options.
|
abstract DescribeTopicsResult |
describeTopics(Collection<String> topicNames,
DescribeTopicsOptions options)
Describe some topics in the cluster.
|
ElectPreferredLeadersResult |
electPreferredLeaders(Collection<TopicPartition> partitions)
Elect the preferred broker of the given
partitions as leader, or
elect the preferred broker for all partitions as leader if the argument to partitions is null. |
abstract ElectPreferredLeadersResult |
electPreferredLeaders(Collection<TopicPartition> partitions,
ElectPreferredLeadersOptions options)
Elect the preferred broker of the given
partitions as leader, or
elect the preferred broker for all partitions as leader if the argument to partitions is null. |
ExpireDelegationTokenResult |
expireDelegationToken(byte[] hmac)
Expire a Delegation Token.
|
abstract ExpireDelegationTokenResult |
expireDelegationToken(byte[] hmac,
ExpireDelegationTokenOptions options)
Expire a Delegation Token.
|
AlterConfigsResult |
incrementalAlterConfigs(Map<ConfigResource,Collection<AlterConfigOp>> configs)
Incrementally updates the configuration for the specified resources with default options.
|
abstract AlterConfigsResult |
incrementalAlterConfigs(Map<ConfigResource,Collection<AlterConfigOp>> configs,
AlterConfigsOptions options)
Incrementally update the configuration for the specified resources.
|
ListConsumerGroupOffsetsResult |
listConsumerGroupOffsets(String groupId)
List the consumer group offsets available in the cluster with the default options.
|
abstract ListConsumerGroupOffsetsResult |
listConsumerGroupOffsets(String groupId,
ListConsumerGroupOffsetsOptions options)
List the consumer group offsets available in the cluster.
|
ListConsumerGroupsResult |
listConsumerGroups()
List the consumer groups available in the cluster with the default options.
|
abstract ListConsumerGroupsResult |
listConsumerGroups(ListConsumerGroupsOptions options)
List the consumer groups available in the cluster.
|
ListTopicsResult |
listTopics()
List the topics available in the cluster with the default options.
|
abstract ListTopicsResult |
listTopics(ListTopicsOptions options)
List the topics available in the cluster.
|
abstract Map<MetricName,? extends Metric> |
metrics()
Get the metrics kept by the adminClient
|
RenewDelegationTokenResult |
renewDelegationToken(byte[] hmac)
Renew a Delegation Token.
|
abstract RenewDelegationTokenResult |
renewDelegationToken(byte[] hmac,
RenewDelegationTokenOptions options)
Renew a Delegation Token.
|
public static AdminClient create(Properties props)
props
- The configuration.public static AdminClient create(Map<String,Object> conf)
conf
- The configuration.public void close()
close(long, TimeUnit)
close
in interface AutoCloseable
@Deprecated public void close(long duration, TimeUnit unit)
close(Duration)
or close()
.duration
- The duration to use for the wait time.unit
- The time unit to use for the wait time.public abstract void close(Duration timeout)
timeout
- The time to use for the wait time.public CreateTopicsResult createTopics(Collection<NewTopic> newTopics)
createTopics(Collection, CreateTopicsOptions)
with default options.
See the overload for more details.
This operation is supported by brokers with version 0.10.1.0 or higher.newTopics
- The new topics to create.public abstract CreateTopicsResult createTopics(Collection<NewTopic> newTopics, CreateTopicsOptions options)
CreateTopicsResult
returns
success for all the brokers to become aware that the topics have been created.
During this time, listTopics()
and describeTopics(Collection)
may not return information about the new topics.
This operation is supported by brokers with version 0.10.1.0 or higher. The validateOnly option is supported
from version 0.10.2.0.newTopics
- The new topics to create.options
- The options to use when creating the new topics.public DeleteTopicsResult deleteTopics(Collection<String> topics)
deleteTopics(Collection, DeleteTopicsOptions)
with default options. See the overload for more details.
This operation is supported by brokers with version 0.10.1.0 or higher.topics
- The topic names to delete.public abstract DeleteTopicsResult deleteTopics(Collection<String> topics, DeleteTopicsOptions options)
DeleteTopicsResult
returns
success for all the brokers to become aware that the topics are gone.
During this time, AdminClient#listTopics and AdminClient#describeTopics
may continue to return information about the deleted topics.
If delete.topic.enable is false on the brokers, deleteTopics will mark
the topics for deletion, but not actually delete them. The futures will
return successfully in this case.
This operation is supported by brokers with version 0.10.1.0 or higher.topics
- The topic names to delete.options
- The options to use when deleting the topics.public ListTopicsResult listTopics()
listTopics(ListTopicsOptions)
with default options.
See the overload for more details.public abstract ListTopicsResult listTopics(ListTopicsOptions options)
options
- The options to use when listing the topics.public DescribeTopicsResult describeTopics(Collection<String> topicNames)
describeTopics(Collection, DescribeTopicsOptions)
with
default options. See the overload for more details.topicNames
- The names of the topics to describe.public abstract DescribeTopicsResult describeTopics(Collection<String> topicNames, DescribeTopicsOptions options)
topicNames
- The names of the topics to describe.options
- The options to use when describing the topic.public DescribeClusterResult describeCluster()
describeCluster(DescribeClusterOptions)
with default options.
See the overload for more details.public abstract DescribeClusterResult describeCluster(DescribeClusterOptions options)
options
- The options to use when getting information about the cluster.public DescribeAclsResult describeAcls(AclBindingFilter filter)
describeAcls(AclBindingFilter, DescribeAclsOptions)
with
default options. See the overload for more details.
This operation is supported by brokers with version 0.11.0.0 or higher.filter
- The filter to use.public abstract DescribeAclsResult describeAcls(AclBindingFilter filter, DescribeAclsOptions options)
filter
- The filter to use.options
- The options to use when listing the ACLs.public CreateAclsResult createAcls(Collection<AclBinding> acls)
createAcls(Collection, CreateAclsOptions)
with
default options. See the overload for more details.
This operation is supported by brokers with version 0.11.0.0 or higher.acls
- The ACLs to createpublic abstract CreateAclsResult createAcls(Collection<AclBinding> acls, CreateAclsOptions options)
acls
- The ACLs to createoptions
- The options to use when creating the ACLs.public DeleteAclsResult deleteAcls(Collection<AclBindingFilter> filters)
deleteAcls(Collection, DeleteAclsOptions)
with default options.
See the overload for more details.
This operation is supported by brokers with version 0.11.0.0 or higher.filters
- The filters to use.public abstract DeleteAclsResult deleteAcls(Collection<AclBindingFilter> filters, DeleteAclsOptions options)
filters
- The filters to use.options
- The options to use when deleting the ACLs.public DescribeConfigsResult describeConfigs(Collection<ConfigResource> resources)
describeConfigs(Collection, DescribeConfigsOptions)
with default options.
See the overload for more details.
This operation is supported by brokers with version 0.11.0.0 or higher.resources
- The resources (topic and broker resource types are currently supported)public abstract DescribeConfigsResult describeConfigs(Collection<ConfigResource> resources, DescribeConfigsOptions options)
null
so that sensitive information
is not disclosed.
Config entries where isReadOnly() is true cannot be updated.
This operation is supported by brokers with version 0.11.0.0 or higher.resources
- The resources (topic and broker resource types are currently supported)options
- The options to use when describing configs@Deprecated public AlterConfigsResult alterConfigs(Map<ConfigResource,Config> configs)
incrementalAlterConfigs(Map)
.alterConfigs(Map, AlterConfigsOptions)
with default options.
See the overload for more details.
This operation is supported by brokers with version 0.11.0.0 or higher.configs
- The resources with their configs (topic is the only resource type with configs that can
be updated currently)@Deprecated public abstract AlterConfigsResult alterConfigs(Map<ConfigResource,Config> configs, AlterConfigsOptions options)
incrementalAlterConfigs(Map, AlterConfigsOptions)
.configs
- The resources with their configs (topic is the only resource type with configs that can
be updated currently)options
- The options to use when describing configspublic AlterConfigsResult incrementalAlterConfigs(Map<ConfigResource,Collection<AlterConfigOp>> configs)
incrementalAlterConfigs(Map, AlterConfigsOptions)
with default options.
See the overload for more details.*
This operation is supported by brokers with version 2.3.0 or higher.configs
- The resources with their configspublic abstract AlterConfigsResult incrementalAlterConfigs(Map<ConfigResource,Collection<AlterConfigOp>> configs, AlterConfigsOptions options)
The following exceptions can be anticipated when calling get()
on the futures obtained from
the returned IncrementalAlterConfigsResult
:
ClusterAuthorizationException
if the authenticated user didn't have alter access to the cluster.TopicAuthorizationException
if the authenticated user didn't have alter access to the Topic.InvalidRequestException
if the request details are invalid. e.g., a configuration key was specified more than once for a resourceconfigs
- The resources with their configsoptions
- The options to use when altering configspublic AlterReplicaLogDirsResult alterReplicaLogDirs(Map<TopicPartitionReplica,String> replicaAssignment)
alterReplicaLogDirs(Map, AlterReplicaLogDirsOptions)
with default options.
See the overload for more details.
This operation is supported by brokers with version 1.1.0 or higher.replicaAssignment
- The replicas with their log directory absolute pathpublic abstract AlterReplicaLogDirsResult alterReplicaLogDirs(Map<TopicPartitionReplica,String> replicaAssignment, AlterReplicaLogDirsOptions options)
replicaAssignment
- The replicas with their log directory absolute pathoptions
- The options to use when changing replica dirpublic DescribeLogDirsResult describeLogDirs(Collection<Integer> brokers)
describeLogDirs(Collection, DescribeLogDirsOptions)
with default options.
See the overload for more details.
This operation is supported by brokers with version 1.0.0 or higher.brokers
- A list of brokerspublic abstract DescribeLogDirsResult describeLogDirs(Collection<Integer> brokers, DescribeLogDirsOptions options)
brokers
- A list of brokersoptions
- The options to use when querying log dir infopublic DescribeReplicaLogDirsResult describeReplicaLogDirs(Collection<TopicPartitionReplica> replicas)
describeReplicaLogDirs(Collection, DescribeReplicaLogDirsOptions)
with default options. See the overload for more details.
This operation is supported by brokers with version 1.0.0 or higher.replicas
- The replicas to querypublic abstract DescribeReplicaLogDirsResult describeReplicaLogDirs(Collection<TopicPartitionReplica> replicas, DescribeReplicaLogDirsOptions options)
replicas
- The replicas to queryoptions
- The options to use when querying replica log dir infopublic CreatePartitionsResult createPartitions(Map<String,NewPartitions> newPartitions)
Increase the number of partitions of the topics given as the keys of newPartitions
according to the corresponding values. If partitions are increased for a topic that has a key,
the partition logic or ordering of the messages will be affected.
This is a convenience method for createPartitions(Map, CreatePartitionsOptions)
with default options.
See the overload for more details.
newPartitions
- The topics which should have new partitions created, and corresponding parameters
for the created partitions.public abstract CreatePartitionsResult createPartitions(Map<String,NewPartitions> newPartitions, CreatePartitionsOptions options)
Increase the number of partitions of the topics given as the keys of newPartitions
according to the corresponding values. If partitions are increased for a topic that has a key,
the partition logic or ordering of the messages will be affected.
This operation is not transactional so it may succeed for some topics while fail for others.
It may take several seconds after this method returns
success for all the brokers to become aware that the partitions have been created.
During this time, describeTopics(Collection)
may not return information about the new partitions.
This operation is supported by brokers with version 1.0.0 or higher.
The following exceptions can be anticipated when calling get()
on the futures obtained from the
values()
method of the returned CreatePartitionsResult
AuthorizationException
if the authenticated user is not authorized to alter the topicTimeoutException
if the request was not completed in within the given AbstractOptions.timeoutMs()
.ReassignmentInProgressException
if a partition reassignment is currently in progressBrokerNotAvailableException
if the requested NewPartitions.assignments()
contain a broker that is currently unavailable.InvalidReplicationFactorException
if no NewPartitions.assignments()
are given and it is impossible for the broker to assign
replicas with the topics replication factor.KafkaException
if the request is invalid in some way.newPartitions
- The topics which should have new partitions created, and corresponding parameters
for the created partitions.options
- The options to use when creating the new paritions.public DeleteRecordsResult deleteRecords(Map<TopicPartition,RecordsToDelete> recordsToDelete)
deleteRecords(Map, DeleteRecordsOptions)
with default options.
See the overload for more details.
This operation is supported by brokers with version 0.11.0.0 or higher.recordsToDelete
- The topic partitions and related offsets from which records deletion starts.public abstract DeleteRecordsResult deleteRecords(Map<TopicPartition,RecordsToDelete> recordsToDelete, DeleteRecordsOptions options)
recordsToDelete
- The topic partitions and related offsets from which records deletion starts.options
- The options to use when deleting records.public CreateDelegationTokenResult createDelegationToken()
Create a Delegation Token.
This is a convenience method for createDelegationToken(CreateDelegationTokenOptions)
with default options.
See the overload for more details.
public abstract CreateDelegationTokenResult createDelegationToken(CreateDelegationTokenOptions options)
Create a Delegation Token.
This operation is supported by brokers with version 1.1.0 or higher.
The following exceptions can be anticipated when calling get()
on the futures obtained from the
delegationToken()
method of the returned CreateDelegationTokenResult
UnsupportedByAuthenticationException
If the request sent on PLAINTEXT/1-way SSL channels or delegation token authenticated channels.InvalidPrincipalTypeException
if the renewers principal type is not supported.DelegationTokenDisabledException
if the delegation token feature is disabled.TimeoutException
if the request was not completed in within the given AbstractOptions.timeoutMs()
.options
- The options to use when creating delegation token.public RenewDelegationTokenResult renewDelegationToken(byte[] hmac)
Renew a Delegation Token.
This is a convenience method for renewDelegationToken(byte[], RenewDelegationTokenOptions)
with default options.
See the overload for more details.
hmac
- HMAC of the Delegation tokenpublic abstract RenewDelegationTokenResult renewDelegationToken(byte[] hmac, RenewDelegationTokenOptions options)
Renew a Delegation Token.
This operation is supported by brokers with version 1.1.0 or higher.
The following exceptions can be anticipated when calling get()
on the futures obtained from the
expiryTimestamp()
method of the returned RenewDelegationTokenResult
UnsupportedByAuthenticationException
If the request sent on PLAINTEXT/1-way SSL channels or delegation token authenticated channels.DelegationTokenDisabledException
if the delegation token feature is disabled.DelegationTokenNotFoundException
if the delegation token is not found on server.DelegationTokenOwnerMismatchException
if the authenticated user is not owner/renewer of the token.DelegationTokenExpiredException
if the delegation token is expired.TimeoutException
if the request was not completed in within the given AbstractOptions.timeoutMs()
.hmac
- HMAC of the Delegation tokenoptions
- The options to use when renewing delegation token.public ExpireDelegationTokenResult expireDelegationToken(byte[] hmac)
Expire a Delegation Token.
This is a convenience method for expireDelegationToken(byte[], ExpireDelegationTokenOptions)
with default options.
This will expire the token immediately. See the overload for more details.
hmac
- HMAC of the Delegation tokenpublic abstract ExpireDelegationTokenResult expireDelegationToken(byte[] hmac, ExpireDelegationTokenOptions options)
Expire a Delegation Token.
This operation is supported by brokers with version 1.1.0 or higher.
The following exceptions can be anticipated when calling get()
on the futures obtained from the
expiryTimestamp()
method of the returned ExpireDelegationTokenResult
UnsupportedByAuthenticationException
If the request sent on PLAINTEXT/1-way SSL channels or delegation token authenticated channels.DelegationTokenDisabledException
if the delegation token feature is disabled.DelegationTokenNotFoundException
if the delegation token is not found on server.DelegationTokenOwnerMismatchException
if the authenticated user is not owner/renewer of the requested token.DelegationTokenExpiredException
if the delegation token is expired.TimeoutException
if the request was not completed in within the given AbstractOptions.timeoutMs()
.hmac
- HMAC of the Delegation tokenoptions
- The options to use when expiring delegation token.public DescribeDelegationTokenResult describeDelegationToken()
Describe the Delegation Tokens.
This is a convenience method for describeDelegationToken(DescribeDelegationTokenOptions)
with default options.
This will return all the user owned tokens and tokens where user have Describe permission. See the overload for more details.
public abstract DescribeDelegationTokenResult describeDelegationToken(DescribeDelegationTokenOptions options)
Describe the Delegation Tokens.
This operation is supported by brokers with version 1.1.0 or higher.
The following exceptions can be anticipated when calling get()
on the futures obtained from the
delegationTokens()
method of the returned DescribeDelegationTokenResult
UnsupportedByAuthenticationException
If the request sent on PLAINTEXT/1-way SSL channels or delegation token authenticated channels.DelegationTokenDisabledException
if the delegation token feature is disabled.TimeoutException
if the request was not completed in within the given AbstractOptions.timeoutMs()
.options
- The options to use when describing delegation tokens.public abstract DescribeConsumerGroupsResult describeConsumerGroups(Collection<String> groupIds, DescribeConsumerGroupsOptions options)
groupIds
- The IDs of the groups to describe.options
- The options to use when describing the groups.public DescribeConsumerGroupsResult describeConsumerGroups(Collection<String> groupIds)
This is a convenience method for
#describeConsumerGroups(Collection, DescribeConsumerGroupsOptions)
with
default options. See the overload for more details.
groupIds
- The IDs of the groups to describe.public abstract ListConsumerGroupsResult listConsumerGroups(ListConsumerGroupsOptions options)
options
- The options to use when listing the consumer groups.public ListConsumerGroupsResult listConsumerGroups()
listConsumerGroups(ListConsumerGroupsOptions)
with default options.
See the overload for more details.public abstract ListConsumerGroupOffsetsResult listConsumerGroupOffsets(String groupId, ListConsumerGroupOffsetsOptions options)
options
- The options to use when listing the consumer group offsets.public ListConsumerGroupOffsetsResult listConsumerGroupOffsets(String groupId)
listConsumerGroupOffsets(String, ListConsumerGroupOffsetsOptions)
with default options.public abstract DeleteConsumerGroupsResult deleteConsumerGroups(Collection<String> groupIds, DeleteConsumerGroupsOptions options)
options
- The options to use when deleting a consumer group.public DeleteConsumerGroupsResult deleteConsumerGroups(Collection<String> groupIds)
public ElectPreferredLeadersResult electPreferredLeaders(Collection<TopicPartition> partitions)
partitions
as leader, or
elect the preferred broker for all partitions as leader if the argument to partitions
is null.
This is a convenience method for electPreferredLeaders(Collection, ElectPreferredLeadersOptions)
with default options.
See the overload for more details.partitions
- The partitions for which the preferred leader should be elected.public abstract ElectPreferredLeadersResult electPreferredLeaders(Collection<TopicPartition> partitions, ElectPreferredLeadersOptions options)
partitions
as leader, or
elect the preferred broker for all partitions as leader if the argument to partitions
is null.
This operation is not transactional so it may succeed for some partitions while fail for others.
It may take several seconds after this method returns
success for all the brokers in the cluster to become aware that the partitions have new leaders.
During this time, describeTopics(Collection)
may not return information about the partitions' new leaders.
This operation is supported by brokers with version 2.2.0 or higher.
The following exceptions can be anticipated when calling get()
on the futures obtained from
the returned ElectPreferredLeadersResult
:
ClusterAuthorizationException
if the authenticated user didn't have alter access to the cluster.UnknownTopicOrPartitionException
if the topic or partition did not exist within the cluster.InvalidTopicException
if the topic was already queued for deletion.NotControllerException
if the request was sent to a broker that was not the controller for the cluster.TimeoutException
if the request timed out before the election was complete.LeaderNotAvailableException
if the preferred leader was not alive or not in the ISR.partitions
- The partitions for which the preferred leader should be elected.options
- The options to use when electing the preferred leaders.public abstract Map<MetricName,? extends Metric> metrics()