Skip to content

ControllerEventManager

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

ControllerEventManager is Created and Started With KafkaController

Creating Instance

ControllerEventManager takes the following to be created:

ControllerEventManager is created when:

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.

Partition in jconsole

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:

Starting ControllerEventThread

start(): Unit

start requests the ControllerEventThread to start processing ControllerEvents.

start is used when:

  • KafkaController is 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:

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:

  • ControllerEventThread is requested to doWork