Class KafkaAdminClient
- java.lang.Object
-
- org.apache.kafka.clients.admin.AdminClient
-
- org.apache.kafka.clients.admin.KafkaAdminClient
-
- All Implemented Interfaces:
java.lang.AutoCloseable
@Evolving public class KafkaAdminClient extends AdminClient
The default implementation ofAdminClient. An instance of this class is created by invoking one of thecreate()methods inAdminClient. Users should not refer to this class directly. The API of this class is evolving, seeAdminClientfor details.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AlterConfigsResultalterConfigs(java.util.Map<ConfigResource,Config> configs, AlterConfigsOptions options)This API is not supported.AlterReplicaLogDirsResultalterReplicaLogDirs(java.util.Map<TopicPartitionReplica,java.lang.String> replicaAssignment, AlterReplicaLogDirsOptions options)This API is not supported.voidclose(long duration, java.util.concurrent.TimeUnit unit)Close the AdminClient and release all associated resources.CreateAclsResultcreateAcls(java.util.Collection<AclBinding> acls, CreateAclsOptions options)This API is not supported.CreateDelegationTokenResultcreateDelegationToken(CreateDelegationTokenOptions options)Create a Delegation Token.CreatePartitionsResultcreatePartitions(java.util.Map<java.lang.String,NewPartitions> newPartitions, CreatePartitionsOptions options)Increase the number of partitions of the topics given as the keys ofnewPartitionsaccording to the corresponding values.CreateTopicsResultcreateTopics(java.util.Collection<NewTopic> newTopics, CreateTopicsOptions options)Create a batch of new topics.DeleteAclsResultdeleteAcls(java.util.Collection<AclBindingFilter> filters, DeleteAclsOptions options)This API is not supported.DeleteConsumerGroupsResultdeleteConsumerGroups(java.util.Collection<java.lang.String> groupIds, DeleteConsumerGroupsOptions options)Delete consumer groups from the cluster.DeleteRecordsResultdeleteRecords(java.util.Map<TopicPartition,RecordsToDelete> recordsToDelete, DeleteRecordsOptions options)This API is not supported.DeleteTopicsResultdeleteTopics(java.util.Collection<java.lang.String> topicNames, DeleteTopicsOptions options)Delete a batch of topics.DescribeAclsResultdescribeAcls(AclBindingFilter filter, DescribeAclsOptions options)This API is not supported.DescribeClusterResultdescribeCluster(DescribeClusterOptions options)Get information about the nodes in the cluster.DescribeConfigsResultdescribeConfigs(java.util.Collection<ConfigResource> configResources, DescribeConfigsOptions options)This API is not supported.DescribeConsumerGroupsResultdescribeConsumerGroups(java.util.Collection<java.lang.String> groupIds, DescribeConsumerGroupsOptions options)Describe some group IDs in the cluster.DescribeDelegationTokenResultdescribeDelegationToken(DescribeDelegationTokenOptions options)Describe the Delegation Tokens.DescribeLogDirsResultdescribeLogDirs(java.util.Collection<java.lang.Integer> brokers, DescribeLogDirsOptions options)This API is not supported.DescribeReplicaLogDirsResultdescribeReplicaLogDirs(java.util.Collection<TopicPartitionReplica> replicas, DescribeReplicaLogDirsOptions options)This API is not supported.DescribeTopicsResultdescribeTopics(java.util.Collection<java.lang.String> topicNames, DescribeTopicsOptions options)Describe some topics in the cluster.ExpireDelegationTokenResultexpireDelegationToken(byte[] hmac, ExpireDelegationTokenOptions options)Expire a Delegation Token.ListConsumerGroupOffsetsResultlistConsumerGroupOffsets(java.lang.String groupId, ListConsumerGroupOffsetsOptions options)List the consumer group offsets available in the cluster.ListConsumerGroupsResultlistConsumerGroups(ListConsumerGroupsOptions options)List the consumer groups available in the cluster.ListTopicsResultlistTopics(java.lang.String streamPath, ListTopicsOptions options)List the topics available in the specified stream.ListTopicsResultlistTopics(ListTopicsOptions options)List the topics available in the default stream.java.util.Map<MetricName,? extends Metric>metrics()Get the metrics kept by the adminClientRenewDelegationTokenResultrenewDelegationToken(byte[] hmac, RenewDelegationTokenOptions options)Renew a Delegation Token.-
Methods inherited from class org.apache.kafka.clients.admin.AdminClient
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, listTopics, renewDelegationToken
-
-
-
-
Method Detail
-
close
public void close(long duration, java.util.concurrent.TimeUnit unit)Description copied from class:AdminClientClose the AdminClient and release all associated resources. The close operation has a grace period during which current operations will be allowed to complete, specified by the given duration and time unit. New operations will not be accepted during the grace period. Once the grace period is over, all operations that have not yet been completed will be aborted with a TimeoutException.- Specified by:
closein classAdminClient- Parameters:
duration- The duration to use for the wait time.unit- The time unit to use for the wait time.
-
createTopics
public CreateTopicsResult createTopics(java.util.Collection<NewTopic> newTopics, CreateTopicsOptions options)
Description copied from class:AdminClientCreate a batch of new topics. This operation is not transactional so it may succeed for some topics while fail for others. It may take several seconds afterCreateTopicsResultreturns success for all the brokers to become aware that the topics have been created. During this time,AdminClient.listTopics()andAdminClient.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.- Specified by:
createTopicsin classAdminClient- Parameters:
newTopics- The new topics to create.options- The options to use when creating the new topics.- Returns:
- The CreateTopicsResult.
-
deleteTopics
public DeleteTopicsResult deleteTopics(java.util.Collection<java.lang.String> topicNames, DeleteTopicsOptions options)
Description copied from class:AdminClientDelete a batch of topics. This operation is not transactional so it may succeed for some topics while fail for others. It may take several seconds after theDeleteTopicsResultreturns 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.- Specified by:
deleteTopicsin classAdminClient- Parameters:
topicNames- The topic names to delete.options- The options to use when deleting the topics.- Returns:
- The DeleteTopicsResult.
-
listTopics
public ListTopicsResult listTopics(ListTopicsOptions options)
Description copied from class:AdminClientList the topics available in the default stream.- Specified by:
listTopicsin classAdminClient- Parameters:
options- The options to use when listing the topics.- Returns:
- The ListTopicsResult.
-
listTopics
public ListTopicsResult listTopics(java.lang.String streamPath, ListTopicsOptions options)
Description copied from class:AdminClientList the topics available in the specified stream.- Specified by:
listTopicsin classAdminClient- Parameters:
streamPath- The name of the stream for which the topics should be listedoptions- The options to use when listing the topics.- Returns:
- The ListTopicsResult.
-
describeTopics
public DescribeTopicsResult describeTopics(java.util.Collection<java.lang.String> topicNames, DescribeTopicsOptions options)
Description copied from class:AdminClientDescribe some topics in the cluster.- Specified by:
describeTopicsin classAdminClient- Parameters:
topicNames- The names of the topics to describe.options- The options to use when describing the topic.- Returns:
- The DescribeTopicsResult.
-
describeCluster
public DescribeClusterResult describeCluster(DescribeClusterOptions options)
Description copied from class:AdminClientGet information about the nodes in the cluster.- Specified by:
describeClusterin classAdminClient- Parameters:
options- The options to use when getting information about the cluster.- Returns:
- The DescribeClusterResult.
-
describeAcls
public DescribeAclsResult describeAcls(AclBindingFilter filter, DescribeAclsOptions options)
Description copied from class:AdminClientThis API is not supported. Lists access control lists (ACLs) according to the supplied filter. Note: it may take some time for changes made by createAcls or deleteAcls to be reflected in the output of describeAcls. This operation is supported by brokers with version 0.11.0.0 or higher.- Specified by:
describeAclsin classAdminClient- Parameters:
filter- The filter to use.options- The options to use when listing the ACLs.- Returns:
- The DeleteAclsResult.
-
createAcls
public CreateAclsResult createAcls(java.util.Collection<AclBinding> acls, CreateAclsOptions options)
Description copied from class:AdminClientThis API is not supported. Creates access control lists (ACLs) which are bound to specific resources. This operation is not transactional so it may succeed for some ACLs while fail for others. If you attempt to add an ACL that duplicates an existing ACL, no error will be raised, but no changes will be made. This operation is supported by brokers with version 0.11.0.0 or higher.- Specified by:
createAclsin classAdminClient- Parameters:
acls- The ACLs to createoptions- The options to use when creating the ACLs.- Returns:
- The CreateAclsResult.
-
deleteAcls
public DeleteAclsResult deleteAcls(java.util.Collection<AclBindingFilter> filters, DeleteAclsOptions options)
Description copied from class:AdminClientThis API is not supported. Deletes access control lists (ACLs) according to the supplied filters. This operation is not transactional so it may succeed for some ACLs while fail for others. This operation is supported by brokers with version 0.11.0.0 or higher.- Specified by:
deleteAclsin classAdminClient- Parameters:
filters- The filters to use.options- The options to use when deleting the ACLs.- Returns:
- The DeleteAclsResult.
-
describeConfigs
public DescribeConfigsResult describeConfigs(java.util.Collection<ConfigResource> configResources, DescribeConfigsOptions options)
Description copied from class:AdminClientThis API is not supported. Get the configuration for the specified resources. The returned configuration includes default values and the isDefault() method can be used to distinguish them from user supplied values. The value of config entries where isSensitive() is true is alwaysnullso 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.- Specified by:
describeConfigsin classAdminClient- Parameters:
configResources- The resources (topic and broker resource types are currently supported)options- The options to use when describing configs- Returns:
- The DescribeConfigsResult
-
alterConfigs
public AlterConfigsResult alterConfigs(java.util.Map<ConfigResource,Config> configs, AlterConfigsOptions options)
Description copied from class:AdminClientThis API is not supported. Update the configuration for the specified resources with the default options. Updates are not transactional so they may succeed for some resources while fail for others. The configs for a particular resource are updated atomically. This operation is supported by brokers with version 0.11.0.0 or higher.- Specified by:
alterConfigsin classAdminClient- Parameters:
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 configs- Returns:
- The AlterConfigsResult
-
alterReplicaLogDirs
public AlterReplicaLogDirsResult alterReplicaLogDirs(java.util.Map<TopicPartitionReplica,java.lang.String> replicaAssignment, AlterReplicaLogDirsOptions options)
Description copied from class:AdminClientThis API is not supported. Change the log directory for the specified replicas. This API is currently only useful if it is used before the replica has been created on the broker. It will support moving replicas that have already been created after KIP-113 is fully implemented. This operation is not transactional so it may succeed for some replicas while fail for others. This operation is supported by brokers with version 1.0.0 or higher.- Specified by:
alterReplicaLogDirsin classAdminClient- Parameters:
replicaAssignment- The replicas with their log directory absolute pathoptions- The options to use when changing replica dir- Returns:
- The AlterReplicaLogDirsResult
-
describeLogDirs
public DescribeLogDirsResult describeLogDirs(java.util.Collection<java.lang.Integer> brokers, DescribeLogDirsOptions options)
Description copied from class:AdminClientThis API is not supported. 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.- Specified by:
describeLogDirsin classAdminClient- Parameters:
brokers- A list of brokersoptions- The options to use when querying log dir info- Returns:
- The DescribeLogDirsResult
-
describeReplicaLogDirs
public DescribeReplicaLogDirsResult describeReplicaLogDirs(java.util.Collection<TopicPartitionReplica> replicas, DescribeReplicaLogDirsOptions options)
Description copied from class:AdminClientThis API is not supported. Query the replica log directory information for the specified replicas. This operation is supported by brokers with version 1.0.0 or higher.- Specified by:
describeReplicaLogDirsin classAdminClient- Parameters:
replicas- The replicas to queryoptions- The options to use when querying replica log dir info- Returns:
- The DescribeReplicaLogDirsResult
-
createPartitions
public CreatePartitionsResult createPartitions(java.util.Map<java.lang.String,NewPartitions> newPartitions, CreatePartitionsOptions options)
Description copied from class:AdminClientIncrease the number of partitions of the topics given as the keys of
newPartitionsaccording 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 thevalues()method of the returnedCreatePartitionsResultAuthorizationExceptionif the authenticated user is not authorized to alter the topicTimeoutExceptionif the request was not completed in within the givenAbstractOptions.timeoutMs().ReassignmentInProgressExceptionif a partition reassignment is currently in progressBrokerNotAvailableExceptionif the requestedNewPartitions.assignments()contain a broker that is currently unavailable.InvalidReplicationFactorExceptionif noNewPartitions.assignments()are given and it is impossible for the broker to assign replicas with the topics replication factor.- Subclasses of
KafkaExceptionif the request is invalid in some way.
- Specified by:
createPartitionsin classAdminClient- Parameters:
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.- Returns:
- The CreatePartitionsResult.
-
deleteRecords
public DeleteRecordsResult deleteRecords(java.util.Map<TopicPartition,RecordsToDelete> recordsToDelete, DeleteRecordsOptions options)
Description copied from class:AdminClientThis API is not supported. Delete records whose offset is smaller than the given offset of the corresponding partition. This operation is supported by brokers with version 0.11.0.0 or higher.- Specified by:
deleteRecordsin classAdminClient- Parameters:
recordsToDelete- The topic partitions and related offsets from which records deletion starts.options- The options to use when deleting records.- Returns:
- The DeleteRecordsResult.
-
createDelegationToken
public CreateDelegationTokenResult createDelegationToken(CreateDelegationTokenOptions options)
Description copied from class:AdminClientCreate 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 thedelegationToken()method of the returnedCreateDelegationTokenResultUnsupportedByAuthenticationExceptionIf the request sent on PLAINTEXT/1-way SSL channels or delegation token authenticated channels.InvalidPrincipalTypeExceptionif the renewers principal type is not supported.DelegationTokenDisabledExceptionif the delegation token feature is disabled.TimeoutExceptionif the request was not completed in within the givenAbstractOptions.timeoutMs().
- Specified by:
createDelegationTokenin classAdminClient- Parameters:
options- The options to use when creating delegation token.- Returns:
- The DeleteRecordsResult.
-
renewDelegationToken
public RenewDelegationTokenResult renewDelegationToken(byte[] hmac, RenewDelegationTokenOptions options)
Description copied from class:AdminClientRenew 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 theexpiryTimestamp()method of the returnedRenewDelegationTokenResultUnsupportedByAuthenticationExceptionIf the request sent on PLAINTEXT/1-way SSL channels or delegation token authenticated channels.DelegationTokenDisabledExceptionif the delegation token feature is disabled.DelegationTokenNotFoundExceptionif the delegation token is not found on server.DelegationTokenOwnerMismatchExceptionif the authenticated user is not owner/renewer of the token.DelegationTokenExpiredExceptionif the delegation token is expired.TimeoutExceptionif the request was not completed in within the givenAbstractOptions.timeoutMs().
- Specified by:
renewDelegationTokenin classAdminClient- Parameters:
hmac- HMAC of the Delegation tokenoptions- The options to use when renewing delegation token.- Returns:
- The RenewDelegationTokenResult.
-
expireDelegationToken
public ExpireDelegationTokenResult expireDelegationToken(byte[] hmac, ExpireDelegationTokenOptions options)
Description copied from class:AdminClientExpire 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 theexpiryTimestamp()method of the returnedExpireDelegationTokenResultUnsupportedByAuthenticationExceptionIf the request sent on PLAINTEXT/1-way SSL channels or delegation token authenticated channels.DelegationTokenDisabledExceptionif the delegation token feature is disabled.DelegationTokenNotFoundExceptionif the delegation token is not found on server.DelegationTokenOwnerMismatchExceptionif the authenticated user is not owner/renewer of the requested token.DelegationTokenExpiredExceptionif the delegation token is expired.TimeoutExceptionif the request was not completed in within the givenAbstractOptions.timeoutMs().
- Specified by:
expireDelegationTokenin classAdminClient- Parameters:
hmac- HMAC of the Delegation tokenoptions- The options to use when expiring delegation token.- Returns:
- The ExpireDelegationTokenResult.
-
describeDelegationToken
public DescribeDelegationTokenResult describeDelegationToken(DescribeDelegationTokenOptions options)
Description copied from class:AdminClientDescribe 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 thedelegationTokens()method of the returnedDescribeDelegationTokenResultUnsupportedByAuthenticationExceptionIf the request sent on PLAINTEXT/1-way SSL channels or delegation token authenticated channels.DelegationTokenDisabledExceptionif the delegation token feature is disabled.TimeoutExceptionif the request was not completed in within the givenAbstractOptions.timeoutMs().
- Specified by:
describeDelegationTokenin classAdminClient- Parameters:
options- The options to use when describing delegation tokens.- Returns:
- The DescribeDelegationTokenResult.
-
describeConsumerGroups
public DescribeConsumerGroupsResult describeConsumerGroups(java.util.Collection<java.lang.String> groupIds, DescribeConsumerGroupsOptions options)
Description copied from class:AdminClientDescribe some group IDs in the cluster.- Specified by:
describeConsumerGroupsin classAdminClient- Parameters:
groupIds- The IDs of the groups to describe.options- The options to use when describing the groups.- Returns:
- The DescribeConsumerGroupResult.
-
listConsumerGroups
public ListConsumerGroupsResult listConsumerGroups(ListConsumerGroupsOptions options)
Description copied from class:AdminClientList the consumer groups available in the cluster.- Specified by:
listConsumerGroupsin classAdminClient- Parameters:
options- The options to use when listing the consumer groups.- Returns:
- The ListGroupsResult.
-
listConsumerGroupOffsets
public ListConsumerGroupOffsetsResult listConsumerGroupOffsets(java.lang.String groupId, ListConsumerGroupOffsetsOptions options)
Description copied from class:AdminClientList the consumer group offsets available in the cluster.- Specified by:
listConsumerGroupOffsetsin classAdminClientoptions- The options to use when listing the consumer group offsets.- Returns:
- The ListGroupOffsetsResult
-
deleteConsumerGroups
public DeleteConsumerGroupsResult deleteConsumerGroups(java.util.Collection<java.lang.String> groupIds, DeleteConsumerGroupsOptions options)
Description copied from class:AdminClientDelete consumer groups from the cluster.- Specified by:
deleteConsumerGroupsin classAdminClientoptions- The options to use when deleting a consumer group.- Returns:
- The DeletConsumerGroupResult.
-
metrics
public java.util.Map<MetricName,? extends Metric> metrics()
Description copied from class:AdminClientGet the metrics kept by the adminClient- Specified by:
metricsin classAdminClient
-
-