This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.
Status
Current state: Under Discussion
Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]
JIRA: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
Describe the problems you are trying to solve.
Similarly to KIP-179, the kafka-preferred-replica-election.sh
tool takes a --zookeeper
option which means users of the tool must have access to the ZooKeeper cluster backing the Kafka cluster. There is no AdminClient API via which the preferred leader can be elected, so it is only this tool which can be used to do this job. This KIP will provide an AdminClient API for electing the preferred leader, add an option to the kafka-preferred-replica-election.sh
tool to use this new API and deprecate the --zookeeper
option.
Public Interfaces
Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that will come along with this feature.
A public interface is any change to the following:
Binary log format
The network protocol and api behavior
Any class in the public packages under clientsConfiguration, especially client configuration
org/apache/kafka/common/serialization
org/apache/kafka/common
org/apache/kafka/common/errors
org/apache/kafka/clients/producer
org/apache/kafka/clients/consumer (eventually, once stable)
Monitoring
Command line tools and arguments
- Anything else that will likely break existing users in some way when they upgrade
The kafka-preferred-replica-election.sh
tool will gain a --bootstrap-server
option and the existing --zookeeper
option will be deprecated.
The AdminClient will gain a new method:
electPreferredReplicaLeader(Collection<TopicPartition> partitions)
A new network protocol will be added:
ElectPreferredReplicaLeaderRequest and ElectPreferredReplicaLeaderResponse
Proposed Changes
Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.
kafka-preferred-replica-election.sh
The --zookeeper
option will be retained and will:
- Cause a deprecation warning to be printed to standard error. The message will say that the
--zookeeper
option will be removed in a future version and that--bootstrap-server
is the replacement option. - Perform the election via ZooKeeper, as currently.
A new --bootstrap-server
option will be added and will:
- Perform the election via the given broker.
Using both options in the same command line will produce an error message and the tool will exit without doing the intended operation.
It is anticipated that a future version of Kafka would remove support for the --zookeeper
option.
The --help
output of the tool will be updated to explain what the preferred replica *is*, because this is currently not discoverable from the command line tool help, only from the documentation on the Kafka website.
The --help
output for the tool will be updated to note that the command is not necessary if the broker is configured with auto.leader.rebalance.enable=true
.
AdminClient: electPreferredReplicaLeader
()
The following methods will be added to AdminClient:
ElectPreferredReplicaLeaderResult electPreferredReplicaLeader(Collection<TopicPartition> partitions, ElectPreferredReplicaLeaderOptions options) ElectPreferredReplicaLeaderResult electPreferredReplicaLeader(Collection<TopicPartition> partitions)
Where
class ElectPreferredReplicaLeaderOptions { long timeout() ElectPreferredReplicaLeaderOptions timeout(long timeout) } class ElectPreferredReplicaLeaderResult { Map<TopicPartition, KafkaFuture<Void>> values(); }
NetworkProtocol: ElectPreferredReplicaLeaderRequest and ElectPreferredReplicaLeaderResponse
ElectPreferredReplicaLeaderRequest => [topcPartition] timeout topicPartition => topic partition_id topic => STRING partition_id => INT32 timeout => INT32
Where
Field | Description |
---|---|
topic | a topic name |
partition_id | a partition of the topic |
timeout | the time to wait for the election to complete |
The request will require ClusterAction
operation on the Cluster
resource.
ElectPreferredReplicaLeaderResponse => throttle_time_ms [replica_election_result] throttle_time_ms => INT32 replica_election_result => topic partition_id error_code error_message topic => STRING partition_id => INT32 error_code => INT16 error_message => NULLABLE_STRING
Where
Field | Description |
---|---|
throttle_time_ms | duration in milliseconds for which the request was throttled |
topic | a topic name from the request |
partition_id | a partition id for the topic |
error_code | an error code for that partition |
error_message | more detailed information about any error for that topic |
Anticipated errors:
INVALID_TOPIC_EXCEPTION
(17) If the topic doesn't existINVALID_REQUEST
(42) If duplicate topics appeared in the request.NONE
(0) The topic partition count was changed successfully.
Compatibility, Deprecation, and Migration Plan
- What impact (if any) will there be on existing users?
- If we are changing behavior how will we phase out the older behavior?
- If we need special migration tools, describe them here.
- When will we remove the existing behavior?
Existing users of the kafka-preferred-replica-election.sh
will receive a deprecation warning when they use the --zookeeper
option. The option will be removed in a future version of Kafka. If this KIP is introduced in version 1.0.0 the removal could happen in 2.0.0.
Rejected Alternatives
If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.
One alternative is to do nothing: Let the tool continue to communicate with ZooKeeper directly.
Another alternative is to do exactly this KIP, but without the deprecation of --zookeeper
. That would have a higher long term maintenance burden, and would prevent any future plans to, for example, provide alternative cluster technologies than ZooKeeper.