@InterfaceStability.Evolving public class KafkaAdminClient extends AdminClient
AdminClient
. An instance of this class is created by invoking one of the
create()
methods in AdminClient
. Users should not refer to this class directly.
The API of this class is evolving, see AdminClient
for details.Modifier and Type | Method and Description |
---|---|
AlterConfigsResult |
alterConfigs(java.util.Map<ConfigResource,Config> configs,
AlterConfigsOptions options)
Update the configuration for the specified resources with the default options.
|
AlterReplicaLogDirsResult |
alterReplicaLogDirs(java.util.Map<TopicPartitionReplica,java.lang.String> replicaAssignment,
AlterReplicaLogDirsOptions options)
Change the log directory for the specified replicas.
|
void |
close(long duration,
java.util.concurrent.TimeUnit unit)
Close the AdminClient and release all associated resources.
|
CreateAclsResult |
createAcls(java.util.Collection<AclBinding> acls,
CreateAclsOptions options)
Creates access control lists (ACLs) which are bound to specific resources.
|
CreateDelegationTokenResult |
createDelegationToken(CreateDelegationTokenOptions options)
Create a Delegation Token.
|
CreatePartitionsResult |
createPartitions(java.util.Map<java.lang.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(java.util.Collection<NewTopic> newTopics,
CreateTopicsOptions options)
Create a batch of new topics.
|
DeleteAclsResult |
deleteAcls(java.util.Collection<AclBindingFilter> filters,
DeleteAclsOptions options)
Deletes access control lists (ACLs) according to the supplied filters.
|
DeleteConsumerGroupsResult |
deleteConsumerGroups(java.util.Collection<java.lang.String> groupIds,
DeleteConsumerGroupsOptions options)
Delete consumer groups from the cluster.
|
DeleteRecordsResult |
deleteRecords(java.util.Map<TopicPartition,RecordsToDelete> recordsToDelete,
DeleteRecordsOptions options)
Delete records whose offset is smaller than the given offset of the corresponding partition.
|
DeleteTopicsResult |
deleteTopics(java.util.Collection<java.lang.String> topicNames,
DeleteTopicsOptions options)
Delete a batch of topics.
|
DescribeAclsResult |
describeAcls(AclBindingFilter filter,
DescribeAclsOptions options)
Lists access control lists (ACLs) according to the supplied filter.
|
DescribeClusterResult |
describeCluster(DescribeClusterOptions options)
Get information about the nodes in the cluster.
|
DescribeConfigsResult |
describeConfigs(java.util.Collection<ConfigResource> configResources,
DescribeConfigsOptions options)
Get the configuration for the specified resources.
|
DescribeConsumerGroupsResult |
describeConsumerGroups(java.util.Collection<java.lang.String> groupIds,
DescribeConsumerGroupsOptions options)
Describe some group IDs in the cluster.
|
DescribeDelegationTokenResult |
describeDelegationToken(DescribeDelegationTokenOptions options)
Describe the Delegation Tokens.
|
DescribeLogDirsResult |
describeLogDirs(java.util.Collection<java.lang.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(java.util.Collection<TopicPartitionReplica> replicas,
DescribeReplicaLogDirsOptions options)
Query the replica log directory information for the specified replicas.
|
DescribeTopicsResult |
describeTopics(java.util.Collection<java.lang.String> topicNames,
DescribeTopicsOptions options)
Describe some topics in the cluster.
|
ExpireDelegationTokenResult |
expireDelegationToken(byte[] hmac,
ExpireDelegationTokenOptions options)
Expire a Delegation Token.
|
ListConsumerGroupOffsetsResult |
listConsumerGroupOffsets(java.lang.String groupId,
ListConsumerGroupOffsetsOptions options)
List the consumer group offsets available in the cluster.
|
ListConsumerGroupsResult |
listConsumerGroups(ListConsumerGroupsOptions options)
List the consumer groups available in the cluster.
|
ListTopicsResult |
listTopics(ListTopicsOptions options)
List the topics available in the cluster.
|
RenewDelegationTokenResult |
renewDelegationToken(byte[] hmac,
RenewDelegationTokenOptions options)
Renew a Delegation Token.
|
alterConfigs, alterReplicaLogDirs, close, create, create, createAcls, createDelegationToken, createPartitions, createTopics, deleteAcls, deleteConsumerGroups, deleteRecords, deleteTopics, describeAcls, describeCluster, describeConfigs, describeConsumerGroups, describeDelegationToken, describeLogDirs, describeReplicaLogDirs, describeTopics, expireDelegationToken, listConsumerGroupOffsets, listConsumerGroups, listTopics, renewDelegationToken
public void close(long duration, java.util.concurrent.TimeUnit unit)
AdminClient
close
in class AdminClient
duration
- The duration to use for the wait time.unit
- The time unit to use for the wait time.public CreateTopicsResult createTopics(java.util.Collection<NewTopic> newTopics, CreateTopicsOptions options)
AdminClient
CreateTopicsResult
returns
success for all the brokers to become aware that the topics have been created.
During this time, AdminClient.listTopics()
and AdminClient.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.createTopics
in class AdminClient
newTopics
- The new topics to create.options
- The options to use when creating the new topics.public DeleteTopicsResult deleteTopics(java.util.Collection<java.lang.String> topicNames, DeleteTopicsOptions options)
AdminClient
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.deleteTopics
in class AdminClient
topicNames
- The topic names to delete.options
- The options to use when deleting the topics.public ListTopicsResult listTopics(ListTopicsOptions options)
AdminClient
listTopics
in class AdminClient
options
- The options to use when listing the topics.public DescribeTopicsResult describeTopics(java.util.Collection<java.lang.String> topicNames, DescribeTopicsOptions options)
AdminClient
describeTopics
in class AdminClient
topicNames
- The names of the topics to describe.options
- The options to use when describing the topic.public DescribeClusterResult describeCluster(DescribeClusterOptions options)
AdminClient
describeCluster
in class AdminClient
options
- The options to use when getting information about the cluster.public DescribeAclsResult describeAcls(AclBindingFilter filter, DescribeAclsOptions options)
AdminClient
describeAcls
in class AdminClient
filter
- The filter to use.options
- The options to use when listing the ACLs.public CreateAclsResult createAcls(java.util.Collection<AclBinding> acls, CreateAclsOptions options)
AdminClient
createAcls
in class AdminClient
acls
- The ACLs to createoptions
- The options to use when creating the ACLs.public DeleteAclsResult deleteAcls(java.util.Collection<AclBindingFilter> filters, DeleteAclsOptions options)
AdminClient
deleteAcls
in class AdminClient
filters
- The filters to use.options
- The options to use when deleting the ACLs.public DescribeConfigsResult describeConfigs(java.util.Collection<ConfigResource> configResources, DescribeConfigsOptions options)
AdminClient
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.describeConfigs
in class AdminClient
configResources
- The resources (topic and broker resource types are currently supported)options
- The options to use when describing configspublic AlterConfigsResult alterConfigs(java.util.Map<ConfigResource,Config> configs, AlterConfigsOptions options)
AdminClient
alterConfigs
in class AdminClient
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 AlterReplicaLogDirsResult alterReplicaLogDirs(java.util.Map<TopicPartitionReplica,java.lang.String> replicaAssignment, AlterReplicaLogDirsOptions options)
AdminClient
alterReplicaLogDirs
in class AdminClient
replicaAssignment
- The replicas with their log directory absolute pathoptions
- The options to use when changing replica dirpublic DescribeLogDirsResult describeLogDirs(java.util.Collection<java.lang.Integer> brokers, DescribeLogDirsOptions options)
AdminClient
describeLogDirs
in class AdminClient
brokers
- A list of brokersoptions
- The options to use when querying log dir infopublic DescribeReplicaLogDirsResult describeReplicaLogDirs(java.util.Collection<TopicPartitionReplica> replicas, DescribeReplicaLogDirsOptions options)
AdminClient
describeReplicaLogDirs
in class AdminClient
replicas
- The replicas to queryoptions
- The options to use when querying replica log dir infopublic CreatePartitionsResult createPartitions(java.util.Map<java.lang.String,NewPartitions> newPartitions, CreatePartitionsOptions options)
AdminClient
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, AdminClient.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.createPartitions
in class AdminClient
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(java.util.Map<TopicPartition,RecordsToDelete> recordsToDelete, DeleteRecordsOptions options)
AdminClient
deleteRecords
in class AdminClient
recordsToDelete
- The topic partitions and related offsets from which records deletion starts.options
- The options to use when deleting records.public CreateDelegationTokenResult createDelegationToken(CreateDelegationTokenOptions options)
AdminClient
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()
.createDelegationToken
in class AdminClient
options
- The options to use when creating delegation token.public RenewDelegationTokenResult renewDelegationToken(byte[] hmac, RenewDelegationTokenOptions options)
AdminClient
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()
.renewDelegationToken
in class AdminClient
hmac
- HMAC of the Delegation tokenoptions
- The options to use when renewing delegation token.public ExpireDelegationTokenResult expireDelegationToken(byte[] hmac, ExpireDelegationTokenOptions options)
AdminClient
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()
.expireDelegationToken
in class AdminClient
hmac
- HMAC of the Delegation tokenoptions
- The options to use when expiring delegation token.public DescribeDelegationTokenResult describeDelegationToken(DescribeDelegationTokenOptions options)
AdminClient
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()
.describeDelegationToken
in class AdminClient
options
- The options to use when describing delegation tokens.public DescribeConsumerGroupsResult describeConsumerGroups(java.util.Collection<java.lang.String> groupIds, DescribeConsumerGroupsOptions options)
AdminClient
describeConsumerGroups
in class AdminClient
groupIds
- The IDs of the groups to describe.options
- The options to use when describing the groups.public ListConsumerGroupsResult listConsumerGroups(ListConsumerGroupsOptions options)
AdminClient
listConsumerGroups
in class AdminClient
options
- The options to use when listing the consumer groups.public ListConsumerGroupOffsetsResult listConsumerGroupOffsets(java.lang.String groupId, ListConsumerGroupOffsetsOptions options)
AdminClient
listConsumerGroupOffsets
in class AdminClient
options
- The options to use when listing the consumer group offsets.public DeleteConsumerGroupsResult deleteConsumerGroups(java.util.Collection<java.lang.String> groupIds, DeleteConsumerGroupsOptions options)
AdminClient
deleteConsumerGroups
in class AdminClient
options
- The options to use when deleting a consumer group.