This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new a78a931ce00 KAFKA-18854 remove `DynamicConfig` inner class (#19487)
a78a931ce00 is described below
commit a78a931ce0056f774c4a3e6995bec24582c67478
Author: Xuan-Zhang Gong <[email protected]>
AuthorDate: Sun Apr 20 23:37:18 2025 +0800
KAFKA-18854 remove `DynamicConfig` inner class (#19487)
This PR is a umbrella of [KAFKA-18854.
](https://issues.apache.org/jira/browse/KAFKA-18854)
The previous PR encountered some compatibility issues, so we decided to
split it and proceed with the migration step by step.
see https://github.com/apache/kafka/pull/19019
Reviewers: PoAn Yang <[email protected]>, Chia-Ping Tsai
<[email protected]>
---
.../src/main/scala/kafka/admin/ConfigCommand.scala | 22 ++++++------
.../main/scala/kafka/server/DynamicConfig.scala | 42 ----------------------
2 files changed, 12 insertions(+), 52 deletions(-)
diff --git a/core/src/main/scala/kafka/admin/ConfigCommand.scala
b/core/src/main/scala/kafka/admin/ConfigCommand.scala
index 034f99f868c..0f6b71d8092 100644
--- a/core/src/main/scala/kafka/admin/ConfigCommand.scala
+++ b/core/src/main/scala/kafka/admin/ConfigCommand.scala
@@ -17,9 +17,6 @@
package kafka.admin
-import java.nio.charset.StandardCharsets
-import java.util.concurrent.{ExecutionException, TimeUnit}
-import java.util.{Collections, Properties}
import joptsimple._
import kafka.server.DynamicConfig
import kafka.utils.Implicits._
@@ -32,13 +29,18 @@ import org.apache.kafka.common.protocol.ApiKeys
import org.apache.kafka.common.quota.{ClientQuotaAlteration,
ClientQuotaEntity, ClientQuotaFilter, ClientQuotaFilterComponent}
import org.apache.kafka.common.security.scram.internals.ScramMechanism
import org.apache.kafka.common.utils.{Exit, Utils}
+import org.apache.kafka.coordinator.group.GroupConfig
import org.apache.kafka.server.config.{ConfigType, QuotaConfig}
+import org.apache.kafka.server.metrics.ClientMetricsConfigs
import org.apache.kafka.server.util.{CommandDefaultOptions, CommandLineUtils}
import org.apache.kafka.storage.internals.log.LogConfig
import java.net.{InetAddress, UnknownHostException}
-import scala.jdk.CollectionConverters._
+import java.nio.charset.StandardCharsets
+import java.util.concurrent.{ExecutionException, TimeUnit}
+import java.util.{Collections, Properties}
import scala.collection._
+import scala.jdk.CollectionConverters._
/**
* This script can be used to change configs for
topics/clients/users/brokers/ips/client-metrics/groups dynamically
@@ -250,7 +252,7 @@ object ConfigCommand extends Logging {
}
case IpType =>
- val unknownConfigs = (configsToBeAdded.keys ++
configsToBeDeleted).filterNot(key => DynamicConfig.Ip.names.contains(key))
+ val unknownConfigs = (configsToBeAdded.keys ++
configsToBeDeleted).filterNot(key => QuotaConfig.ipConfigs.names.contains(key))
if (unknownConfigs.nonEmpty)
throw new IllegalArgumentException(s"Only connection quota configs
can be added for '$IpType' using --bootstrap-server. Unexpected config names:
${unknownConfigs.mkString(",")}")
alterQuotaConfigs(adminClient, entityTypes, entityNames,
configsToBeAddedMap, configsToBeDeleted)
@@ -529,11 +531,11 @@ object ConfigCommand extends Logging {
val addConfig: OptionSpec[String] = parser.accepts("add-config", "Key
Value pairs of configs to add. Square brackets can be used to group values
which contain commas: 'k1=v1,k2=[v1,v2,v2],k3=v3'. The following is a list of
valid configurations: " +
"For entity-type '" + TopicType + "': " +
LogConfig.configNames.asScala.map("\t" + _).mkString(nl, nl, nl) +
"For entity-type '" + BrokerType + "': " +
DynamicConfig.Broker.names.asScala.toSeq.sorted.map("\t" + _).mkString(nl, nl,
nl) +
- "For entity-type '" + UserType + "': " +
DynamicConfig.User.names.asScala.toSeq.sorted.map("\t" + _).mkString(nl, nl,
nl) +
- "For entity-type '" + ClientType + "': " +
DynamicConfig.Client.names.asScala.toSeq.sorted.map("\t" + _).mkString(nl, nl,
nl) +
- "For entity-type '" + IpType + "': " +
DynamicConfig.Ip.names.asScala.toSeq.sorted.map("\t" + _).mkString(nl, nl, nl) +
- "For entity-type '" + ClientMetricsType + "': " +
DynamicConfig.ClientMetrics.names.asScala.toSeq.sorted.map("\t" +
_).mkString(nl, nl, nl) +
- "For entity-type '" + GroupType + "': " +
DynamicConfig.Group.names.asScala.toSeq.sorted.map("\t" + _).mkString(nl, nl,
nl) +
+ "For entity-type '" + UserType + "': " +
QuotaConfig.scramMechanismsPlusUserAndClientQuotaConfigs().names.asScala.toSeq.sorted.map("\t"
+ _).mkString(nl, nl, nl) +
+ "For entity-type '" + ClientType + "': " +
QuotaConfig.userAndClientQuotaConfigs().names.asScala.toSeq.sorted.map("\t" +
_).mkString(nl, nl, nl) +
+ "For entity-type '" + IpType + "': " +
QuotaConfig.ipConfigs.names.asScala.toSeq.sorted.map("\t" + _).mkString(nl, nl,
nl) +
+ "For entity-type '" + ClientMetricsType + "': " +
ClientMetricsConfigs.configDef().names.asScala.toSeq.sorted.map("\t" +
_).mkString(nl, nl, nl) +
+ "For entity-type '" + GroupType + "': " +
GroupConfig.configDef().names.asScala.toSeq.sorted.map("\t" + _).mkString(nl,
nl, nl) +
s"Entity types '$UserType' and '$ClientType' may be specified together
to update config for clients of a specific user.")
.withRequiredArg
.ofType(classOf[String])
diff --git a/core/src/main/scala/kafka/server/DynamicConfig.scala
b/core/src/main/scala/kafka/server/DynamicConfig.scala
index 7a401ec1eb4..ad48b904c13 100644
--- a/core/src/main/scala/kafka/server/DynamicConfig.scala
+++ b/core/src/main/scala/kafka/server/DynamicConfig.scala
@@ -21,7 +21,6 @@ import kafka.server.DynamicBrokerConfig.AllDynamicConfigs
import java.util.Properties
import org.apache.kafka.common.config.ConfigDef
-import org.apache.kafka.coordinator.group.GroupConfig
import org.apache.kafka.server.config.QuotaConfig
import java.util
@@ -54,47 +53,6 @@ object DynamicConfig {
def validate(props: Properties): util.Map[String, AnyRef] =
DynamicConfig.validate(brokerConfigs, props, customPropsAllowed = true)
}
- object Client {
- private val clientConfigs = QuotaConfig.userAndClientQuotaConfigs()
-
- def configKeys: util.Map[String, ConfigDef.ConfigKey] =
clientConfigs.configKeys
-
- def names: util.Set[String] = clientConfigs.names
-
- def validate(props: Properties): util.Map[String, AnyRef] =
DynamicConfig.validate(clientConfigs, props, customPropsAllowed = false)
- }
-
- object User {
- private val userConfigs =
QuotaConfig.scramMechanismsPlusUserAndClientQuotaConfigs()
-
- def configKeys: util.Map[String, ConfigDef.ConfigKey] =
userConfigs.configKeys
-
- def names: util.Set[String] = userConfigs.names
-
- def validate(props: Properties): util.Map[String, AnyRef] =
DynamicConfig.validate(userConfigs, props, customPropsAllowed = false)
- }
-
- object Ip {
- private val ipConfigs = QuotaConfig.ipConfigs
-
- def configKeys: util.Map[String, ConfigDef.ConfigKey] =
ipConfigs.configKeys
-
- def names: util.Set[String] = ipConfigs.names
-
- def validate(props: Properties): util.Map[String, AnyRef] =
DynamicConfig.validate(ipConfigs, props, customPropsAllowed = false)
- }
-
- object ClientMetrics {
- private val clientConfigs =
org.apache.kafka.server.metrics.ClientMetricsConfigs.configDef()
-
- def names: util.Set[String] = clientConfigs.names
- }
-
- object Group {
- private val groupConfigs = GroupConfig.configDef()
-
- def names: util.Set[String] = groupConfigs.names
- }
private def validate(configDef: ConfigDef, props: Properties,
customPropsAllowed: Boolean) = {
// Validate Names