ControllerEventThread is a ShutdownableThread that is created for ControllerEventManager (with the name being controller-event-thread).

// jstack [brokerPid]
"controller-event-thread" #42 prio=5 os_prio=31 cpu=387,10ms elapsed=82679,68s tid=0x00007f920e489800 nid=0x14703 waiting on condition  [0x000070000fcea000]
   java.lang.Thread.State: WAITING (parking)
	at jdk.internal.misc.Unsafe.park([email protected]/Native Method)
	- parking to wait for  <0x00000007c07f0298> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
	at java.util.concurrent.locks.LockSupport.park([email protected]/
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await([email protected]/
	at java.util.concurrent.LinkedBlockingQueue.take([email protected]/
	at kafka.controller.ControllerEventManager$ControllerEventThread.doWork(ControllerEventManager.scala:127)

ControllerEventThread is started with ControllerEventManager.

ControllerEventThread doWork.png
Figure 1. ControllerEventThread is Started Alongside ControllerEventManager

ControllerEventThread takes the name of the thread to be created.

ControllerEventThread uses [ControllerEventThread controllerId=[controllerId]] as the logging prefix (aka logIdent).

Processing Controller Events — doWork Method

doWork(): Unit

doWork takes (and removes) a QueuedEvent from the head of the event queue (waiting for a QueuedEvent to be available if the queue is empty).

The very first event in the event queue is Startup that KafkaController puts when it is started.

doWork sets _state (of ControllerEventManager) to be the state of the controller event.

doWork requests the EventQueueTimeMs histogram to update (with the time between the current time and the enqueue time of the event).

doWork finds the KafkaTimer for the current controller state (in rateAndTimeMetrics lookup table) to measure and record the time to requests the event to process using the ControllerEventProcessor.

In the end, doWork sets the _state (of ControllerEventManager) as Idle.

In case of any error (Throwable), doWork simply prints out the following ERROR message to the logs:

Uncaught error processing event [controllerEvent]

results matching ""

    No results matching ""