ControllerEventManager¶
ControllerEventManager manages the event queue and the controller-event-thread (for event processing) for KafkaController.

Creating Instance¶
ControllerEventManager takes the following to be created:
- Controller ID (i.e. the broker.id of the broker)
- ControllerEventProcessor
-
Time - rateAndTimeMetrics
-
eventQueueTimeTimeoutMs(default: 300000)
ControllerEventManager is created when:
KafkaControlleris created
rateAndTimeMetrics¶
rateAndTimeMetrics: Map[ControllerState, KafkaTimer]
ControllerEventManager is given rateAndTimeMetrics that are KafkaTimers per ControllerState.
Performance Metrics¶
ControllerEventManager is a KafkaMetricsGroup and registers the following performance metrics in kafka.controller:type=ControllerEventManager group.

EventQueueSize¶
Number of QueuedEvents in the event queue
EventQueueTimeMs¶
Event Queue¶
ControllerEventManager creates a LinkedBlockingQueue (Java) of QueuedEvents.
LinkedBlockingQueue
LinkedBlockingQueue is an optionally-bounded blocking queue based on linked nodes that orders elements in first-in-first-out fashion.
Use EventQueueSize metric to monitor the depth of the queue.
The LinkedBlockingQueue is used to:
Emitting (Enqueuing) Controller Event¶
put(
event: ControllerEvent): QueuedEvent
put creates a QueuedEvent with the input ControllerEvent and adds it to the end of the event queue.
put is used when:
ControllerBrokerRequestBatchis requested to sendEventControllerEventManageris requested to clearAndPut- KafkaController is doing its operation (and emits events)
Starting ControllerEventThread¶
start(): Unit
start requests the ControllerEventThread to start processing ControllerEvents.
start is used when:
KafkaControlleris requested to start up
controller-event-thread¶
ControllerEventManager creates a ControllerEventThread when created.
The name of ControllerEventThread is controller-event-thread.
The ControllerEventThread is requested to start when start and runs until close.
ControllerState¶
ControllerEventManager is in one of the possible ControllerStates:
-
Idle when
ControllerEventManageris created and right afterControllerEventThreadhas finished processing a controller event -
State transitions happen per the requested state of the
ControllerEventbeing processed (whileControllerEventThreadis processing controller events)
Note
The state of ControllerEventManager is exactly the state of the parent KafkaController.
pollFromEventQueue¶
pollFromEventQueue(): QueuedEvent
pollFromEventQueue takes a QueuedEvent off the queue.
pollFromEventQueue is used when:
ControllerEventThreadis requested to doWork