KAFKA-14446: API forwarding support from zkBrokers to the Controller (#12961)
This PR enables brokers which are upgrading from ZK mode to KRaft mode to forward certain metadata
change requests to the controller instead of applying them directly through ZK. To faciliate this,
we now support EnvelopeRequest on zkBrokers (instead of only on KRaft nodes.)
In BrokerToControllerChannelManager, we can now reinitialize our NetworkClient. This is needed to
handle the case when we transition from forwarding requests to a ZK-based broker over the
inter-broker listener, to forwarding requests to a quorum node over the controller listener.
In MetadataCache.scala, distinguish between KRaft and ZK controller nodes with a new type,
CachedControllerId.
In LeaderAndIsrRequest, StopReplicaRequest, and UpdateMetadataRequest, switch from sending both a
zk and a KRaft controller ID to sending a single controller ID plus a boolean to express whether it
is KRaft. The previous scheme was ambiguous as to whether the system was in KRaft or ZK mode when
both IDs were -1 (although this case is unlikely to come up in practice). The new scheme avoids
this ambiguity and is simpler to understand.
Reviewers: dengziming <dengziming1993@gmail.com>, David Arthur <mumrah@gmail.com>, Colin P. McCabe <cmccabe@apache.org>
@ -51,7 +51,14 @@ public class LeaderAndIsrRequest extends AbstractControlRequest {
@@ -51,7 +51,14 @@ public class LeaderAndIsrRequest extends AbstractControlRequest {
@ -71,6 +78,10 @@ public class LeaderAndIsrRequest extends AbstractControlRequest {
@@ -71,6 +78,10 @@ public class LeaderAndIsrRequest extends AbstractControlRequest {
@ -168,6 +179,11 @@ public class LeaderAndIsrRequest extends AbstractControlRequest {
@@ -168,6 +179,11 @@ public class LeaderAndIsrRequest extends AbstractControlRequest {
@ -45,7 +45,14 @@ public class StopReplicaRequest extends AbstractControlRequest {
@@ -45,7 +45,14 @@ public class StopReplicaRequest extends AbstractControlRequest {
@ -56,6 +63,10 @@ public class StopReplicaRequest extends AbstractControlRequest {
@@ -56,6 +63,10 @@ public class StopReplicaRequest extends AbstractControlRequest {
.setControllerEpoch(controllerEpoch)
.setBrokerEpoch(brokerEpoch);
if(version>=4){
data.setIsKRaftController(kraftController);
}
if(version>=3){
data.setTopicStates(topicStates);
}elseif(version>=1){
@ -196,6 +207,11 @@ public class StopReplicaRequest extends AbstractControlRequest {
@@ -196,6 +207,11 @@ public class StopReplicaRequest extends AbstractControlRequest {
@ -51,7 +51,14 @@ public class UpdateMetadataRequest extends AbstractControlRequest {
@@ -51,7 +51,14 @@ public class UpdateMetadataRequest extends AbstractControlRequest {
@ -81,10 +88,14 @@ public class UpdateMetadataRequest extends AbstractControlRequest {
@@ -81,10 +88,14 @@ public class UpdateMetadataRequest extends AbstractControlRequest {
@ -180,6 +191,11 @@ public class UpdateMetadataRequest extends AbstractControlRequest {
@@ -180,6 +191,11 @@ public class UpdateMetadataRequest extends AbstractControlRequest {
@ -287,14 +287,19 @@ class KRaftMetadataCache(val brokerId: Int) extends MetadataCache with Logging w
@@ -287,14 +287,19 @@ class KRaftMetadataCache(val brokerId: Int) extends MetadataCache with Logging w