Complete the code to set the leader election strategy in Kafka configuration.
props.put("leader.election.strategy", "[1]");
The correct leader election strategy class in Kafka is KafkaLeaderElectionStrategy.
Complete the code to configure the leader election timeout in milliseconds.
props.put("leader.election.timeout.ms", "[1]");
The leader election timeout is commonly set to 30000 milliseconds (30 seconds) to allow stable leader election.
Fix the error in the code to correctly start leader election on the controller.
controller.[1]LeaderElection();The correct method to start leader election on the controller is startLeaderElection().
Fill both blanks to create a map of partition to leader with condition on leader id.
Map<Integer, String> leaderMap = partitions.stream() .filter(p -> p.leader().id() [1] 0) .collect(Collectors.toMap(p -> p.partition(), p -> p.[2]()));
The filter checks for leader id greater than 0 using '>'. The leader method returns the leader info.
Fill all three blanks to create a map of topic to leader id for partitions with leader id greater than 0.
Map<String, Integer> topicLeaderMap = partitions.stream() .filter(p -> p.[1]().id() [2] 0) .collect(Collectors.toMap(p -> p.[3](), p -> p.leader().id()));
Filter uses 'leader()' method and '>' operator to check leader id. The map key is the topic name.