Bird
0
0

You are implementing a Kafka monitoring tool that must detect and log whenever the controller broker changes. Which method correctly achieves this using Kafka's AdminClient?

hard📝 Application Q8 of 15
Kafka - Cluster Architecture

You are implementing a Kafka monitoring tool that must detect and log whenever the controller broker changes. Which method correctly achieves this using Kafka's AdminClient?

ARestart the AdminClient periodically to refresh controller information
BSubscribe to a Kafka topic that emits controller change events automatically
CUse ZooKeeper watchers to listen for controller changes without AdminClient
DContinuously poll <code>adminClient.describeCluster().controller()</code> and compare the controller ID to detect changes
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to detect controller changes

    Kafka AdminClient's describeCluster().controller() returns the current controller broker node.
  2. Step 2: Implement monitoring logic

    By polling this method periodically and comparing the returned controller ID with the previous one, changes can be detected and logged.
  3. Step 3: Evaluate other options

    Subscribe to a Kafka topic that emits controller change events automatically is invalid as Kafka does not emit controller change events to topics by default. Use ZooKeeper watchers to listen for controller changes without AdminClient uses ZooKeeper, which is deprecated in newer Kafka versions. Restart the AdminClient periodically to refresh controller information is inefficient and does not detect changes promptly.
  4. Final Answer:

    Continuously poll adminClient.describeCluster().controller() and compare the controller ID to detect changes -> Option D
  5. Quick Check:

    Polling controller info detects changes reliably [OK]
Quick Trick: Poll controller info repeatedly to detect changes [OK]
Common Mistakes:
  • Expecting Kafka to publish controller changes to a topic
  • Relying solely on ZooKeeper in newer Kafka versions
  • Restarting AdminClient instead of polling

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes