junrao commented on code in PR #14903:
URL: https://github.com/apache/kafka/pull/14903#discussion_r1414708239
##########
core/src/main/scala/kafka/server/BrokerLifecycleManager.scala:
##########
@@ -366,8 +379,27 @@ class BrokerLifecycleManager(
new BrokerRegistrationResponseHandler())
}
+ // the response handler is not invoked from the event handler thread,
+ // so it is not safe to update state here, instead, schedule an event
+ // to continue handling the response on the event handler thread
private class BrokerRegistrationResponseHandler extends
ControllerRequestCompletionHandler {
override def onComplete(response: ClientResponse): Unit = {
+ eventQueue.prepend(new BrokerRegistrationResponseEvent(response, false))
+ }
+
+ override def onTimeout(): Unit = {
+ info(s"Unable to register the broker because the RPC got timed out
before it could be sent.")
+ eventQueue.prepend(new BrokerRegistrationResponseEvent(null, true))
+ }
+ }
+
+ private class BrokerRegistrationResponseEvent(response: ClientResponse,
timedOut: Boolean) extends EventQueue.Event {
+ override def run(): Unit = {
+ communicationInFlight = false
Review Comment:
Since `NodeToControllerChannelManagerImpl` uses 1 for
`maxInFlightRequestsPerConnection`, we could also add a `sendRequest` api in
`NodeToControllerChannelManager`, instead
networkClient.ready(node, now)
##########
core/src/main/scala/kafka/server/BrokerLifecycleManager.scala:
##########
@@ -366,8 +379,27 @@ class BrokerLifecycleManager(
new BrokerRegistrationResponseHandler())
}
+ // the response handler is not invoked from the event handler thread,
+ // so it is not safe to update state here, instead, schedule an event
+ // to continue handling the response on the event handler thread
private class BrokerRegistrationResponseHandler extends
ControllerRequestCompletionHandler {
override def onComplete(response: ClientResponse): Unit = {
+ eventQueue.prepend(new BrokerRegistrationResponseEvent(response, false))
+ }
+
+ override def onTimeout(): Unit = {
+ info(s"Unable to register the broker because the RPC got timed out
before it could be sent.")
+ eventQueue.prepend(new BrokerRegistrationResponseEvent(null, true))
+ }
+ }
+
+ private class BrokerRegistrationResponseEvent(response: ClientResponse,
timedOut: Boolean) extends EventQueue.Event {
+ override def run(): Unit = {
+ communicationInFlight = false
Review Comment:
Since `NodeToControllerChannelManagerImpl` uses 1 for
`maxInFlightRequestsPerConnection`, we could also add a `sendRequest` api in
`NodeToControllerChannelManager`, instead
networkClient.ready(node, now)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]