THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||
---|---|---|
| ||
{ "apiKey": 43, "type": "request", "name": "ElectLeadersRequest", "validVersions": "0-1", "fields": [ { "name": "TopicPartitionsElectionType", "type": "[]TopicPartitionsint8", "versions": "0+", "nullableVersions": "01+", "about": "TheType topicof partitionselections to elect leaders.", "fields": [ conduct for the partition. A value of '0' elects the preferred replica. A value of '1' elects the first live replica if there are no in-sync replica." }, { "name": "TopicTopicPartitions", "type": "string[]TopicPartitions", "versions": "0+", "nullableVersions": "0+", "about": "The topic namepartitions ofto aelect topicleaders." },, "fields": [ { "name": "PartitionsTopic", "type": "[]Partitionsstring", "versions": "0+", "about": "The partitionsname of thisa topic whose leader should be elected." }, { "name": "PartitionId", "fieldstype": [ { "name": "PartitionId", "type": "int32", "versions": "0+", "about": "The partition id." }, { "name": "ElectionType", "type": "int8", "versions": "1+", "about": "Type of elections to conduct for the partition. A value of '0' elects the preferred replica. A value of '1' elects the first live replica if there are no in-sync replica." } "[]int32", "versions": "0+", "about": "The ] partitions of this topic whose leader should be elected." } ] }, { "name": "TimeoutMs", "type": "int32", "versions": "0+", "default": "60000", "about": "The time in ms to wait for the election to complete." } ] } |
...
Code Block | ||
---|---|---|
| ||
package org.apache.kafka.clients.admin; public abstract class AdminClient ... { ... /** * ... * @deprecated Since TBD. Use {@link #electLeaders}. */ @Deprecated public abstract ElectPreferredLeadersResult electPreferredLeaders(Collection<TopicPartition> partitions, ElectPreferredLeadersOptions options); /** * Attempt to elect a new leader for each of the topic partition in {@code partitions} using the {@code partitionElectionselectionType} election. The type of elections supported* are The type of elections supported *are document in the {@link TopicPartitionElectionElectionType} type. * * If {@code partitionElectionspartitions} is null, then attempt to electperform the preferred replicaelection for all of the topic partitions. * * @param electionType The type of election. * @param partitions * @param partitionElections The partitions andfor thewhich typeto ofconduct elections to conduct. * @param options The options to use when electing the leaders. * @return The ElectLeadersResult. */ public abstract ElectLeadersResult electLeaders( ElectionType electionType, Collection<TopicPartitionElection>Collection<TopicPartition> partitionElectionspartitions, ElectLeadersOptions options); } |
...
ElectionType Enumeration
Code Block | ||
---|---|---|
| ||
package org.apache.kafka.common; public final class TopicPartitionElection { public static enum ElectionType { { PREFERRED((byte) 0), UNCLEANEDUNCLEAN((byte) 1); public final byte value; ElectionType(byte value) { this.value = value; } } public final TopicPartition topicPartition; public finalthis.value ElectionType= electionTypevalue; ...} } |
Admin Command
The command kafka-preferred-replica-election.{sh,bat} will be deprecated and the following command will be added.
Code Block | ||
---|---|---|
| ||
$ bin/kafka-leader-election.sh --help This tool attempts to elect a new leader for a set of topic partitions. The type of elections supported are preferred replicas and unclean replica. Option Description ------ ----------- --admin.config <String: config file> Admin client config properties file to pass to the admin client when -- client when --bootstrap-server is given. --bootstrapall-topic-serverpartitions <String: host:port> A host name and port for the broker to Perform election on all of the topic partitions. Not allowed if connect to, in the form host:port. --topic, --partition or --path-to-json-file is specified. --bootstrap-server <String: host:port> A Multiplehost comma-separatedname URLsand canport be for the broker to given. REQUIRED unless --zookeeper connect to, in the form host:port. is given. --election-type <String: election> Multiple comma-separated URLs can Typebe of election to attempt. Possible values are 0 given. REQUIRED unless --zookeeper (or "preferred") for preferred election or 1 (or is given. --election-type <String: election> Type of election "uncleaned") for uncleaned election. The default value to attempt. Possible values are 0 is 0 (or "preferred"), if --topic or --partition is for preferred election or 1 (or "unclean") for specifiedunclean election. The Notdefault allowedvalue if --path-to-json-file is is 0 specified(or "preferred"). --topic <String: topic> Name of topic for which to perform an election. REQUIRED if --partition is specified. Not allowed if --path-to-json-file-json-file or --all-topic-partitions is specified. --partition <Integer: partition id> Partition id for which to perform an election. REQUIRED if --topic is specified. Not allowed if --path-to-json-file or --all-topic-partitions is specified. --help Print usage information. --path-to-json-file <String: list of The JSON file with the list of partitions for which replica partitions for which leader election leader election needs to be should be done. Supported elections triggered> are 0 for preferred and 1 for uncleanedunclean. If an election is not specified, preferred is the default. This is an example format. {"partitions": [{"topic": "foo", "partition": 1}, {"topic": "foobar", "partition": 2, "election": 1}] } Defaults to preferredNot electionallowed toif --all existing partitions if -topic-partitions, --topic or --partition --topic and --partition flags are not specified. |
Proposed Changes
...