AdminClient
- AdminClient is a tool for managing and interacting with Apache Kafka clusters
- Useful for both application developers and operators/SREs
- Allows programmatic management of Kafka resources
- Can perform operations like topic management, configuration management, and consumer group management
- Provides methods for advanced operations like leader election and replica reassignment
Specific Capabilities
Topic Management
- Create, delete, and modify Kafka topics
- List existing topics
- Describe topic details (partitions, replicas, etc.)
- Expand topics by adding partitions
Configuration Management
- Alter configurations for topics, brokers, and users
- Describe current configurations
- Incrementally modify configurations
Consumer Group Management
- List and describe consumer groups
- Delete consumer groups
Advanced Operations
- Leader election (preferred and unclean)
- Replica reassignment
- Delete records from a topic
Testing
- MockAdminClient class available for unit testing
- Allows testing without running an actual Kafka cluster
References
Flashcards
AdminClient is useful for::both application developers and operators/SREs
What are three main areas of Kafka management that AdminClient can handle?::Topic management, configuration management, and consumer group management
AdminClient can be thought of as::a Swiss Army knife for Kafka operations
Two advanced operations that AdminClient can perform are::leader election and replica reassignment
AdminClient allows for::programmatic management of Kafka resources
When expanding topics with AdminClient, you need to specify::the total number of partitions after addition, not just the new partitions
The deleteRecords method in AdminClient::marks records as deleted and makes them inaccessible to consumers, but full cleanup from disk happens asynchronously
What are the two types of leader election that AdminClient can trigger?::Preferred leader election and unclean leader election
How can AdminClient be used to comply with privacy laws?::By using the deleteRecords method to implement specific data retention policies
What class does Kafka provide for testing AdminClient operations without a real cluster?::MockAdminClient
In the context of replica reassignment, what should you be mindful of?::Available network bandwidth, as reassigning replicas may involve copying large amounts of data between brokers
What is the purpose of the incrementalAlterConfigs method?::To modify configurations for topics, brokers, or users without replacing the entire configuration
How is the AdminClient typically instantiated?::By providing it with a list of broker addresses and other configuration properties
What does the bootstrap.servers configuration do in AdminClient?::Specifies a list of host/port pairs to use for establishing the initial connection to the Kafka cluster
What is the purpose of client.dns.lookup in AdminClient configuration?::Controls how the client resolves server hostnames to IP addresses. Can be 'default' for standard DNS lookup or 'use_all_dns_ips' to try all IPs for a hostname
What does metadata.max.age.ms control in AdminClient?::The period of time in milliseconds after which we force a refresh of metadata even if we haven't seen any partition leadership changes
What is the function of send.buffer.bytes in AdminClient configuration?::The size of the TCP send buffer (SO_SNDBUF) to use when sending data. If the value is -1, the OS default will be used
What does receive.buffer.bytes control in AdminClient?::The size of the TCP receive buffer (SO_RCVBUF) to use when reading data. If the value is -1, the OS default will be used
What is the purpose of client.id in AdminClient configuration?::An id string to pass to the server when making requests. Used for server-side logging and metrics
What does reconnect.backoff.ms control in AdminClient?::The base amount of time to wait before attempting to reconnect to a given host
What is the function of reconnect.backoff.max.ms in AdminClient configuration?::The maximum amount of time in milliseconds to wait when reconnecting to a broker that has repeatedly failed to connect
What does retries control in AdminClient?::Setting a value greater than zero will cause the client to resend any request that fails with a potentially transient error
What is the purpose of retry.backoff.ms in AdminClient configuration?::The amount of time to wait before attempting to retry a failed request to a given topic partition
What does connections.max.idle.ms control in AdminClient?::Close idle connections after the number of milliseconds specified by this config
What is the function of request.timeout.ms in AdminClient configuration?::The configuration controls the maximum amount of time the client will wait for the response of a request
What does default.api.timeout.ms control in AdminClient?::Specifies the timeout (in milliseconds) for client APIs. This configuration is used as the default timeout for all client operations that do not specify a timeout parameter
What is the purpose of security.protocol in AdminClient configuration?::Protocol used to communicate with brokers. Valid values are: PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL
What does ssl.key.password control in AdminClient?::The password of the private key in the key store file. This is optional for client
What is the function of ssl.keystore.location in AdminClient configuration?::The location of the key store file. This is optional for client and can be used for two-way authentication for client
What does ssl.keystore.password control in AdminClient?::The store password for the key store file. This is optional for client and only needed if ssl.keystore.location is configured
What is the purpose of ssl.truststore.location in AdminClient configuration?::The location of the trust store file
What does ssl.truststore.password control in AdminClient?::The password for the trust store file. If a password is not set, trust store file will be reloaded on every SSL connection
What is the function of sasl.kerberos.service.name in AdminClient configuration?::The Kerberos principal name that Kafka runs as. This can be defined either in Kafka's JAAS config or in Kafka's config