@@ -25,7 +25,7 @@ import kafka.network.DataPlaneAcceptor
2525import kafka .raft .KafkaRaftManager
2626import kafka .server .DynamicBrokerConfig ._
2727import kafka .utils .Logging
28- import org .apache .kafka .common .{Endpoint , Reconfigurable , Uuid }
28+ import org .apache .kafka .common .{Endpoint , Reconfigurable }
2929import org .apache .kafka .common .config .{ConfigDef , ConfigException , ConfigResource , SslConfigs }
3030import org .apache .kafka .common .metadata .{ConfigRecord , MetadataRecordType }
3131import org .apache .kafka .common .metrics .{Metrics , MetricsReporter }
@@ -39,16 +39,14 @@ import org.apache.kafka.config
3939import org .apache .kafka .network .SocketServer
4040import org .apache .kafka .raft .KafkaRaftClient
4141import org .apache .kafka .server .{DynamicThreadPool , ProcessRole }
42- import org .apache .kafka .server .common .{ ApiMessageAndVersion , DirectoryEventHandler }
43- import org .apache .kafka .server .config .{DynamicConfig , DynamicProducerStateManagerConfig , ServerConfigs , ServerLogConfigs , DynamicBrokerConfig => JDynamicBrokerConfig }
42+ import org .apache .kafka .server .common .ApiMessageAndVersion
43+ import org .apache .kafka .server .config .{DynamicConfig , DynamicLogConfig , DynamicProducerStateManagerConfig , ServerConfigs , DynamicBrokerConfig => JDynamicBrokerConfig }
4444import org .apache .kafka .server .log .remote .storage .RemoteLogManagerConfig
4545import org .apache .kafka .server .metrics .{ClientTelemetryExporterPlugin , MetricConfigs }
4646import org .apache .kafka .server .telemetry .{ClientTelemetry , ClientTelemetryExporterProvider }
4747import org .apache .kafka .server .util .LockUtils .{inReadLock , inWriteLock }
4848import org .apache .kafka .snapshot .RecordsSnapshotReader
49- import org .apache .kafka .storage .internals .log .{LogConfig , LogManager }
5049
51- import java .util .stream .Collectors
5250import scala .util .Using
5351import scala .collection ._
5452import scala .jdk .CollectionConverters ._
@@ -538,113 +536,6 @@ trait BrokerReconfigurable {
538536 def reconfigure (oldConfig : KafkaConfig , newConfig : KafkaConfig ): Unit
539537}
540538
541- class DynamicLogConfig (logManager : LogManager , directoryEventHandler : DirectoryEventHandler ) extends BrokerReconfigurable with Logging {
542-
543- override def reconfigurableConfigs : util.Set [String ] = {
544- JDynamicBrokerConfig .DynamicLogConfig .RECONFIGURABLE_CONFIGS
545- }
546-
547- override def validateReconfiguration (newConfig : KafkaConfig ): Unit = {
548- // For update of topic config overrides, only config names and types are validated
549- // Names and types have already been validated. For consistency with topic config
550- // validation, no additional validation is performed.
551-
552- def validateLogLocalRetentionMs (): Unit = {
553- val logRetentionMs = newConfig.logRetentionTimeMillis
554- val logLocalRetentionMs : java.lang.Long = newConfig.remoteLogManagerConfig.logLocalRetentionMs
555- if (logRetentionMs != - 1L && logLocalRetentionMs != - 2L ) {
556- if (logLocalRetentionMs == - 1L ) {
557- throw new ConfigException (RemoteLogManagerConfig .LOG_LOCAL_RETENTION_MS_PROP , logLocalRetentionMs,
558- s " Value must not be -1 as ${ServerLogConfigs .LOG_RETENTION_TIME_MILLIS_CONFIG } value is set as $logRetentionMs. " )
559- }
560- if (logLocalRetentionMs > logRetentionMs) {
561- throw new ConfigException (RemoteLogManagerConfig .LOG_LOCAL_RETENTION_MS_PROP , logLocalRetentionMs,
562- s " Value must not be more than ${ServerLogConfigs .LOG_RETENTION_TIME_MILLIS_CONFIG } property value: $logRetentionMs" )
563- }
564- }
565- }
566-
567- def validateLogLocalRetentionBytes (): Unit = {
568- val logRetentionBytes = newConfig.logRetentionBytes
569- val logLocalRetentionBytes : java.lang.Long = newConfig.remoteLogManagerConfig.logLocalRetentionBytes
570- if (logRetentionBytes > - 1 && logLocalRetentionBytes != - 2 ) {
571- if (logLocalRetentionBytes == - 1 ) {
572- throw new ConfigException (RemoteLogManagerConfig .LOG_LOCAL_RETENTION_BYTES_PROP , logLocalRetentionBytes,
573- s " Value must not be -1 as ${ServerLogConfigs .LOG_RETENTION_BYTES_CONFIG } value is set as $logRetentionBytes. " )
574- }
575- if (logLocalRetentionBytes > logRetentionBytes) {
576- throw new ConfigException (RemoteLogManagerConfig .LOG_LOCAL_RETENTION_BYTES_PROP , logLocalRetentionBytes,
577- s " Value must not be more than ${ServerLogConfigs .LOG_RETENTION_BYTES_CONFIG } property value: $logRetentionBytes" )
578- }
579- }
580- }
581-
582- def validateLogRemoteCopyLagMs (): Unit = {
583- val logRetentionMs : Long = newConfig.logRetentionTimeMillis
584- val logLocalRetentionMs = newConfig.remoteLogManagerConfig.logLocalRetentionMs
585- val effectiveLocalRetentionMs = if (logLocalRetentionMs == - 2L ) logRetentionMs else logLocalRetentionMs
586- val logRemoteCopyLagMs = newConfig.remoteLogManagerConfig.logRemoteCopyLagMs
587- if (logRemoteCopyLagMs > 0L && effectiveLocalRetentionMs >= 0L && logRemoteCopyLagMs > effectiveLocalRetentionMs) {
588- throw new ConfigException (RemoteLogManagerConfig .LOG_REMOTE_COPY_LAG_MS_PROP , logRemoteCopyLagMs,
589- s " Value must not exceed ${RemoteLogManagerConfig .LOG_LOCAL_RETENTION_MS_PROP } (effective value: $effectiveLocalRetentionMs) " )
590- }
591- }
592-
593- def validateLogRemoteCopyLagBytes (): Unit = {
594- val logRetentionBytes : Long = newConfig.logRetentionBytes
595- val logLocalRetentionBytes = newConfig.remoteLogManagerConfig.logLocalRetentionBytes
596- val effectiveLocalRetentionBytes = if (logLocalRetentionBytes == - 2L ) logRetentionBytes else logLocalRetentionBytes
597- val logRemoteCopyLagBytes = newConfig.remoteLogManagerConfig.logRemoteCopyLagBytes
598- if (logRemoteCopyLagBytes > 0L && effectiveLocalRetentionBytes >= 0L && logRemoteCopyLagBytes > effectiveLocalRetentionBytes) {
599- throw new ConfigException (RemoteLogManagerConfig .LOG_REMOTE_COPY_LAG_BYTES_PROP , logRemoteCopyLagBytes,
600- s " Value must not exceed ${RemoteLogManagerConfig .LOG_LOCAL_RETENTION_BYTES_PROP } (effective value: $effectiveLocalRetentionBytes) " )
601- }
602- }
603-
604- def validateCordonedLogDirs (): Unit = {
605- val logDirs = newConfig.logDirs()
606- val cordonedLogDirs = newConfig.cordonedLogDirs()
607- cordonedLogDirs.asScala.foreach(dir =>
608- if (! logDirs.contains(dir)) {
609- throw new ConfigException (ServerLogConfigs .CORDONED_LOG_DIRS_CONFIG , cordonedLogDirs, s " Invalid entry in ${ServerLogConfigs .CORDONED_LOG_DIRS_CONFIG }: $dir. " +
610- s " All cordoned log dirs must be entries of ${ServerLogConfigs .LOG_DIRS_CONFIG } or ${ServerLogConfigs .LOG_DIR_CONFIG }. " )
611- }
612- )
613- }
614-
615- validateLogLocalRetentionMs()
616- validateLogLocalRetentionBytes()
617- validateLogRemoteCopyLagMs()
618- validateLogRemoteCopyLagBytes()
619- validateCordonedLogDirs()
620- }
621-
622- private def updateLogsConfig (newBrokerDefaults : Map [String , Object ]): Unit = {
623- logManager.brokerConfigUpdated()
624- logManager.allLogs.forEach { log =>
625- val props = mutable.Map .empty[Any , Any ]
626- props ++= newBrokerDefaults
627- props ++= log.config.originals.asScala.filter { case (k, _) =>
628- log.config.overriddenConfigs.contains(k)
629- }
630-
631- val logConfig = new LogConfig (props.asJava, log.config.overriddenConfigs)
632- log.updateConfig(logConfig)
633- }
634- }
635-
636- override def reconfigure (oldConfig : KafkaConfig , newConfig : KafkaConfig ): Unit = {
637- val newBrokerDefaults = new util.HashMap [String , Object ](newConfig.extractLogConfigMap)
638- logManager.reconfigureDefaultLogConfig(new LogConfig (newBrokerDefaults))
639- updateLogsConfig(newBrokerDefaults.asScala)
640-
641- logManager.updateCordonedLogDirs(util.Set .copyOf(newConfig.cordonedLogDirs))
642- directoryEventHandler.handleCordoned(newConfig.cordonedLogDirs.stream
643- .flatMap[Uuid ](dir => logManager.directoryId(dir).stream)
644- .collect(Collectors .toSet[Uuid ]))
645- }
646- }
647-
648539class ControllerDynamicThreadPool (controller : ControllerServer ) extends BrokerReconfigurable {
649540
650541 override def reconfigurableConfigs : util.Set [String ] = {
0 commit comments