Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions core/src/main/scala/kafka/server/DynamicBrokerConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,11 @@ class DynamicBrokerConfig(private val kafkaConfig: KafkaConfig) extends Logging
newProps ++= staticBrokerConfigs
overrideProps(newProps, dynamicDefaultConfigs)
overrideProps(newProps, dynamicBrokerConfigs)
val oldConfig = currentConfig

// We need a copy of the current config since `currentConfig` is initialized with `kafkaConfig`
// which means the call to `updateCurrentConfig` would end up mutating `oldConfig`.
val oldConfig = KafkaConfig(currentConfig.values, doLog = false)

val (newConfig, brokerReconfigurablesToUpdate) = processReconfiguration(newProps, validateOnly = false)
if (newConfig ne currentConfig) {
currentConfig = newConfig
Expand Down Expand Up @@ -955,6 +959,3 @@ class DynamicListenerConfig(server: KafkaBroker) extends BrokerReconfigurable wi
listeners.map(e => (e.listenerName, e)).toMap

}



2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/server/KafkaConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ object KafkaConfig {
fromProps(props, doLog)
}

def apply(props: java.util.Map[_, _]): KafkaConfig = new KafkaConfig(props, true)
def apply(props: java.util.Map[_, _], doLog: Boolean = true): KafkaConfig = new KafkaConfig(props, true)
Comment thread
hachikuji marked this conversation as resolved.
Outdated

private def typeOf(name: String): Option[ConfigDef.Type] = Option(configDef.configKeys.get(name)).map(_.`type`)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package kafka.server
import java.{lang, util}
import java.util.Properties
import java.util.concurrent.CompletionStage

import kafka.utils.TestUtils
import kafka.zk.KafkaZkClient
import org.apache.kafka.common.{Endpoint, Reconfigurable}
Expand All @@ -30,6 +31,7 @@ import org.apache.kafka.server.authorizer._
import org.easymock.EasyMock
import org.junit.jupiter.api.Assertions._
import org.junit.jupiter.api.Test
import org.mockito.Mockito

import scala.annotation.nowarn
import scala.jdk.CollectionConverters._
Expand Down Expand Up @@ -80,6 +82,27 @@ class DynamicBrokerConfigTest {
}
}

@Test
def testUpdateThreadPool(): Unit = {
val origProps = TestUtils.createBrokerConfig(0, TestUtils.MockZkConnect, port = 8181)
origProps.put(KafkaConfig.NumIoThreadsProp, "4")

val config = KafkaConfig(origProps)
val serverMock = Mockito.mock(classOf[KafkaBroker])
val handlerPoolMock = Mockito.mock(classOf[KafkaRequestHandlerPool])
Mockito.when(serverMock.config).thenReturn(config)
Mockito.when(serverMock.dataPlaneRequestHandlerPool).thenReturn(handlerPoolMock)

config.dynamicConfig.addBrokerReconfigurable(new DynamicThreadPool(serverMock))

val updateProps = new Properties()
updateProps.put(KafkaConfig.NumIoThreadsProp, "8")

config.dynamicConfig.updateDefaultConfig(updateProps)
assertEquals(8, config.numIoThreads)
Mockito.verify(handlerPoolMock).resizeThreadPool(8)
}

@nowarn("cat=deprecation")
@Test
def testConfigUpdateWithSomeInvalidConfigs(): Unit = {
Expand Down