@@ -26,7 +26,6 @@ import kafka.log.{LogCleaner, LogManager}
26
26
import kafka .network .{DataPlaneAcceptor , SocketServer }
27
27
import kafka .server .DynamicBrokerConfig ._
28
28
import kafka .utils .{CoreUtils , Logging }
29
- import kafka .zk .{AdminZkClient , KafkaZkClient }
30
29
import org .apache .kafka .common .Reconfigurable
31
30
import org .apache .kafka .common .config .internals .BrokerSecurityConfigs
32
31
import org .apache .kafka .common .config .{AbstractConfig , ConfigDef , ConfigException , SaslConfigs , SslConfigs }
@@ -39,7 +38,7 @@ import org.apache.kafka.coordinator.transaction.TransactionLogConfig
39
38
import org .apache .kafka .network .SocketServerConfigs
40
39
import org .apache .kafka .security .PasswordEncoder
41
40
import org .apache .kafka .server .ProcessRole
42
- import org .apache .kafka .server .config .{ConfigType , ReplicationConfigs , ServerConfigs , ServerLogConfigs , ServerTopicConfigSynonyms , ZooKeeperInternals }
41
+ import org .apache .kafka .server .config .{ReplicationConfigs , ServerConfigs , ServerLogConfigs , ServerTopicConfigSynonyms }
43
42
import org .apache .kafka .server .log .remote .storage .RemoteLogManagerConfig
44
43
import org .apache .kafka .server .metrics .{ClientMetricsReceiverPlugin , MetricConfigs }
45
44
import org .apache .kafka .server .telemetry .ClientTelemetry
@@ -58,8 +57,6 @@ import scala.jdk.CollectionConverters._
58
57
* </ul>
59
58
* The order of precedence for broker configs is:
60
59
* <ol>
61
- * <li>DYNAMIC_BROKER_CONFIG: stored in ZK at /configs/brokers/{brokerId}</li>
62
- * <li>DYNAMIC_DEFAULT_BROKER_CONFIG: stored in ZK at /configs/brokers/<default></li>
63
60
* <li>STATIC_BROKER_CONFIG: properties that broker is started up with, typically from server.properties file</li>
64
61
* <li>DEFAULT_CONFIG: Default configs defined in KafkaConfig</li>
65
62
* </ol>
@@ -215,17 +212,9 @@ class DynamicBrokerConfig(private val kafkaConfig: KafkaConfig) extends Logging
215
212
private var currentConfig : KafkaConfig = _
216
213
private val dynamicConfigPasswordEncoder = Some (PasswordEncoder .NOOP )
217
214
218
- private [server] def initialize (zkClientOpt : Option [ KafkaZkClient ], clientMetricsReceiverPluginOpt : Option [ClientMetricsReceiverPlugin ]): Unit = {
215
+ private [server] def initialize (clientMetricsReceiverPluginOpt : Option [ClientMetricsReceiverPlugin ]): Unit = {
219
216
currentConfig = new KafkaConfig (kafkaConfig.props, false )
220
217
metricsReceiverPluginOpt = clientMetricsReceiverPluginOpt
221
-
222
- zkClientOpt.foreach { zkClient =>
223
- val adminZkClient = new AdminZkClient (zkClient)
224
- updateDefaultConfig(adminZkClient.fetchEntityConfig(ConfigType .BROKER , ZooKeeperInternals .DEFAULT_STRING ), false )
225
- val props = adminZkClient.fetchEntityConfig(ConfigType .BROKER , kafkaConfig.brokerId.toString)
226
- val brokerConfig = maybeReEncodePasswords(props, adminZkClient)
227
- updateBrokerConfig(kafkaConfig.brokerId, brokerConfig)
228
- }
229
218
}
230
219
231
220
/**
@@ -427,14 +416,6 @@ class DynamicBrokerConfig(private val kafkaConfig: KafkaConfig) extends Logging
427
416
props
428
417
}
429
418
430
- // If the secret has changed, password.encoder.old.secret contains the old secret that was used
431
- // to encode the configs in ZK. Decode passwords using the old secret and update ZK with values
432
- // encoded using the current secret. Ignore any errors during decoding since old secret may not
433
- // have been removed during broker restart.
434
- private def maybeReEncodePasswords (persistentProps : Properties , adminZkClient : AdminZkClient ): Properties = {
435
- persistentProps.clone().asInstanceOf [Properties ]
436
- }
437
-
438
419
/**
439
420
* Validate the provided configs `propsOverride` and return the full Kafka configs with
440
421
* the configured defaults and these overrides.
@@ -900,7 +881,6 @@ object DynamicListenerConfig {
900
881
*/
901
882
val ReconfigurableConfigs = Set (
902
883
// Listener configs
903
- SocketServerConfigs .ADVERTISED_LISTENERS_CONFIG ,
904
884
SocketServerConfigs .LISTENERS_CONFIG ,
905
885
SocketServerConfigs .LISTENER_SECURITY_PROTOCOL_MAP_CONFIG ,
906
886
@@ -986,40 +966,16 @@ class DynamicListenerConfig(server: KafkaBroker) extends BrokerReconfigurable wi
986
966
DynamicListenerConfig .ReconfigurableConfigs
987
967
}
988
968
989
- private def listenerRegistrationsAltered (
990
- oldAdvertisedListeners : Map [ListenerName , EndPoint ],
991
- newAdvertisedListeners : Map [ListenerName , EndPoint ]
992
- ): Boolean = {
993
- if (oldAdvertisedListeners.size != newAdvertisedListeners.size) return true
994
- oldAdvertisedListeners.foreachEntry {
995
- case (oldListenerName, oldEndpoint) =>
996
- newAdvertisedListeners.get(oldListenerName) match {
997
- case None => return true
998
- case Some (newEndpoint) => if (! newEndpoint.equals(oldEndpoint)) {
999
- return true
1000
- }
1001
- }
1002
- }
1003
- false
1004
- }
1005
-
1006
- private def verifyListenerRegistrationAlterationSupported (): Unit = {
1007
- if (! server.config.requiresZookeeper) {
1008
- throw new ConfigException (" Advertised listeners cannot be altered when using a " +
1009
- " Raft-based metadata quorum." )
1010
- }
1011
- }
1012
-
1013
969
def validateReconfiguration (newConfig : KafkaConfig ): Unit = {
1014
970
val oldConfig = server.config
1015
- val newListeners = listenersToMap( newConfig.listeners)
1016
- val newAdvertisedListeners = listenersToMap(newConfig .effectiveAdvertisedBrokerListeners)
1017
- val oldListeners = listenersToMap( oldConfig.listeners)
1018
- if (! newAdvertisedListeners.keySet. subsetOf(newListeners.keySet ))
1019
- throw new ConfigException (s " Advertised listeners ' $newAdvertisedListeners ' must be a subset of listeners ' $newListeners' " )
1020
- if (! newListeners.keySet. subsetOf(newConfig.effectiveListenerSecurityProtocolMap.keySet))
971
+ val newListeners = newConfig.listeners.map(_.listenerName).toSet
972
+ val oldAdvertisedListeners = oldConfig .effectiveAdvertisedBrokerListeners.map(_.listenerName).toSet
973
+ val oldListeners = oldConfig.listeners.map(_.listenerName).toSet
974
+ if (! oldAdvertisedListeners. subsetOf(newListeners))
975
+ throw new ConfigException (s " Advertised listeners ' $oldAdvertisedListeners ' must be a subset of listeners ' $newListeners' " )
976
+ if (! newListeners.subsetOf(newConfig.effectiveListenerSecurityProtocolMap.keySet))
1021
977
throw new ConfigException (s " Listeners ' $newListeners' must be subset of listener map ' ${newConfig.effectiveListenerSecurityProtocolMap}' " )
1022
- newListeners.keySet. intersect(oldListeners.keySet ).foreach { listenerName =>
978
+ newListeners.intersect(oldListeners).foreach { listenerName =>
1023
979
def immutableListenerConfigs (kafkaConfig : KafkaConfig , prefix : String ): Map [String , AnyRef ] = {
1024
980
kafkaConfig.originalsWithPrefix(prefix, true ).asScala.filter { case (key, _) =>
1025
981
// skip the reconfigurable configs
@@ -1032,15 +988,6 @@ class DynamicListenerConfig(server: KafkaBroker) extends BrokerReconfigurable wi
1032
988
if (oldConfig.effectiveListenerSecurityProtocolMap(listenerName) != newConfig.effectiveListenerSecurityProtocolMap(listenerName))
1033
989
throw new ConfigException (s " Security protocol cannot be updated for existing listener $listenerName" )
1034
990
}
1035
- if (! newAdvertisedListeners.contains(newConfig.interBrokerListenerName))
1036
- throw new ConfigException (s " Advertised listener must be specified for inter-broker listener ${newConfig.interBrokerListenerName}" )
1037
-
1038
- // Currently, we do not support adding or removing listeners when in KRaft mode.
1039
- // However, we support changing other listener configurations (max connections, etc.)
1040
- if (listenerRegistrationsAltered(listenersToMap(oldConfig.effectiveAdvertisedBrokerListeners),
1041
- listenersToMap(newConfig.effectiveAdvertisedBrokerListeners))) {
1042
- verifyListenerRegistrationAlterationSupported()
1043
- }
1044
991
}
1045
992
1046
993
def reconfigure (oldConfig : KafkaConfig , newConfig : KafkaConfig ): Unit = {
@@ -1055,13 +1002,6 @@ class DynamicListenerConfig(server: KafkaBroker) extends BrokerReconfigurable wi
1055
1002
if (listenersRemoved.nonEmpty) server.socketServer.removeListeners(listenersRemoved)
1056
1003
if (listenersAdded.nonEmpty) server.socketServer.addListeners(listenersAdded)
1057
1004
}
1058
- if (listenerRegistrationsAltered(listenersToMap(oldConfig.effectiveAdvertisedBrokerListeners),
1059
- listenersToMap(newConfig.effectiveAdvertisedBrokerListeners))) {
1060
- verifyListenerRegistrationAlterationSupported()
1061
- server match {
1062
- case _ => throw new RuntimeException (" Unable to handle reconfigure" )
1063
- }
1064
- }
1065
1005
}
1066
1006
1067
1007
private def listenersToMap (listeners : Seq [EndPoint ]): Map [ListenerName , EndPoint ] =
0 commit comments