@ -254,7 +254,7 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
@@ -254,7 +254,7 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
// they can process the LeaderAndIsrRequests that are generated by replicaStateMachine . startup ( ) and
// partitionStateMachine . startup ( ) .
info ( "Sending update metadata request" )
sendUpdateMetadataRequest ( controllerContext . liveOrShuttingDownBrokerIds . toSeq )
sendUpdateMetadataRequest ( controllerContext . liveOrShuttingDownBrokerIds . toSeq , Set . empty )
replicaStateMachine . startup ( )
partitionStateMachine . startup ( )
@ -357,11 +357,14 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
@@ -357,11 +357,14 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
info ( s" New broker startup callback for ${ newBrokers . mkString ( "," ) } " )
newBrokers . foreach ( controllerContext . replicasOnOfflineDirs . remove )
val newBrokersSet = newBrokers . toSet
// send update metadata request to all live and shutting down brokers . Old brokers will get to know of the new
// broker via this update .
val existingBrokers = controllerContext . liveOrShuttingDownBrokerIds -- newBrokers
// Send update metadata request to all the existing brokers in the cluster so that they know about the new brokers
// via this update . No need to include any partition states in the request since there are no partition state changes .
sendUpdateMetadataRequest ( existingBrokers . toSeq , Set . empty )
// Send update metadata request to all the new brokers in the cluster with a full set of partition states for initialization .
// In cases of controlled shutdown leaders will not be elected when a new broker comes up . So at least in the
// common controlled shutdown case , the metadata will reach the new brokers faster
sendUpdateMetadataRequest ( controllerContext . liveOrShuttingDownBrokerIds . toSeq )
// common controlled shutdown case , the metadata will reach the new brokers faster .
sendUpdateMetadataRequest ( newBrokers , controllerContext . partitionLeadershipInfo . keySet )
// the very first thing to do when a new broker comes up is send it the entire list of partitions that it is
// supposed to host . Based on that the broker starts the high watermark threads for the input list of partitions
val allReplicasOnNewBrokers = controllerContext . replicasOnBrokers ( newBrokersSet )
@ -421,7 +424,7 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
@@ -421,7 +424,7 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
private def onBrokerUpdate ( updatedBrokerId : Int ) {
info ( s" Broker info update callback for $updatedBrokerId " )
sendUpdateMetadataRequest ( controllerContext . liveOrShuttingDownBrokerIds . toSeq )
sendUpdateMetadataRequest ( controllerContext . liveOrShuttingDownBrokerIds . toSeq , Set . empty )
}
/* *
@ -458,10 +461,10 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
@@ -458,10 +461,10 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
topicDeletionManager . failReplicaDeletion ( newOfflineReplicasForDeletion )
}
// If replica failure did not require leader re - election , inform brokers of the offline replica
// If replica failure did not require leader re - election , inform brokers of the offline brokers
// Note that during leader re - election , brokers update their metadata
if ( partitionsWithoutLeader . isEmpty ) {
sendUpdateMetadataRequest ( controllerContext . liveOrShuttingDownBrokerIds . toSeq )
sendUpdateMetadataRequest ( controllerContext . liveOrShuttingDownBrokerIds . toSeq , Set . empty )
}
}
@ -887,7 +890,7 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
@@ -887,7 +890,7 @@ class KafkaController(val config: KafkaConfig, zkClient: KafkaZkClient, time: Ti
*
* @param brokers The brokers that the update metadata request should be sent to
*/
private [ controller ] def sendUpdateMetadataRequest ( brokers : Seq [ Int ] , partitions : Set [ TopicPartition ] = Set . empty [ TopicPartition ] ) {
private [ controller ] def sendUpdateMetadataRequest ( brokers : Seq [ Int ] , partitions : Set [ TopicPartition ] ) {
try {
brokerRequestBatch . newBatch ( )
brokerRequestBatch . addUpdateMetadataRequestForBrokers ( brokers , partitions )