ControllerEventManager

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

ControllerEventManager allows for emitting ControllerEvents (with optional preempting the queue first).

ControllerEventManager is created exclusively for the KafkaController (when started up).

When started, ControllerEventManager simply requests the ControllerEventThread to start processing ControllerEvents.

ControllerEventManager is started when KafkaController is started up.

ControllerEventManager.png
Figure 1. ControllerEventManager is Created and Started With KafkaController

ControllerEventManager is in one of the possible ControllerStates.

Note
The state of ControllerEventManager is exactly the state of the owning KafkaController.

Creating ControllerEventManager Instance

ControllerEventManager takes the following to be created:

ControllerEventManager initializes the internal properties.

Performance Metrics

ControllerEventManager is a KafkaMetricsGroup with the following performance metrics.

Table 1. ControllerEventManager’s Performance Metrics
Metric Name Description

EventQueueTimeMs

EventQueueSize

Number of QueuedEvents in the event queue

The performance metrics are registered in kafka.controller:type=ControllerEventManager group.

ControllerEventManager jconsole.png
Figure 2. Partition in jconsole

Emitting (Enqueuing) Controller Event — put Method

put(event: ControllerEvent): QueuedEvent

put creates a new QueuedEvent with the ControllerEvent and adds it at the end of the event queue.

Note

put is used when:

  • ControllerBrokerRequestBatch is requested to sendEvent

  • ControllerEventManager is requested to clearAndPut

  • KafkaController is requested to do its operation and emits various events

Starting ControllerEventManager (and ControllerEventThread) — start Method

start(): Unit
Note
ControllerEventThread is a ShutdownableThread that triggers doWork() method when started.
Note
start is used exclusively when KafkaController is requested to start up (when KafkaServer is requested to start).

clearAndPut Method

clearAndPut(
  event: ControllerEvent): QueuedEvent

clearAndPut…​FIXME

Note

clearAndPut is used when:

  • ControllerEventManager is requested to close (and emit a ShutdownEventThread event)

  • KafkaController is requested to startup (and registers a StateChangeHandler that emits an Expire event when beforeInitializingSession)

Closing Up — close Method

close(): Unit

close simply clears the event queue and emits a ShutdownEventThread event.

In the end, close waits until the shutdown is complete. You should see the following INFO message in the logs:

Shutdown completed
Note
close is used exclusively when KafkaController is requested to shutdown.

Internal Properties

Name Description

queue

Event queue of QueuedEvents (LinkedBlockingQueue[QueuedEvent]) that is a Java java.util.concurrent.LinkedBlockingQueue (i.e. an optionally-bounded blocking queue based on linked nodes that orders elements in first-in-first-out fashion)

_state

thread

ControllerEventThread with controller-event-thread thread name

results matching ""

    No results matching ""