0
0
Kafkadevops~10 mins

Controller broker in Kafka - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Kafka controller broker ID.

Kafka
controller_id = [1]
Drag options to blanks, or click blank then click option'
A-1
Bbroker_id
CNone
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as the initial controller ID
Using None instead of an integer
Using broker_id directly without election
2fill in blank
medium

Complete the code to check if the current broker is the controller.

Kafka
is_controller = (broker_id [1] controller_id)
Drag options to blanks, or click blank then click option'
A!=
B>
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using != instead of ==
Using < or > which are not correct for equality check
3fill in blank
hard

Fix the error in the code to elect a new controller broker.

Kafka
new_controller = min([1])
Drag options to blanks, or click blank then click option'
Abroker_id
Bcontroller_id
Cbroker_ids
Dbrokers
Attempts:
3 left
💡 Hint
Common Mistakes
Using controller_id which is a single value
Using broker_id which is a single ID
Using brokers which may be a dict or object, not a list
4fill in blank
hard

Fill both blanks to create a dictionary of brokers with their controller status.

Kafka
controller_status = {broker: (broker [1] controller_id) for broker in [2]
Drag options to blanks, or click blank then click option'
A==
B!=
Cbrokers
Dbroker_ids
Attempts:
3 left
💡 Hint
Common Mistakes
Using != instead of ==
Iterating over brokers object instead of broker_ids list
5fill in blank
hard

Fill all three blanks to update the controller broker and notify all brokers.

Kafka
controller_id = [1]
for broker in [2]:
    notify(broker, [3])
Drag options to blanks, or click blank then click option'
Anew_controller
Bbroker_ids
C'controller_changed'
Dcontroller_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using controller_id instead of new_controller for assignment
Iterating over wrong variable instead of broker_ids
Sending wrong notification message