showuon commented on code in PR #23843:
URL: https://github.com/apache/kafka/pull/23843#discussion_r4310146400


##########
server-common/src/main/java/org/apache/kafka/server/util/MirrorUtils.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.server.util;
+
+import com.google.re2j.Pattern;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public final class MirrorUtils {

Review Comment:
   Please add tests.



##########
mirror-coordinator/src/main/java/org/apache/kafka/coordinator/mirror/ClusterMirrorConfig.java:
##########
@@ -0,0 +1,705 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.mirror;
+
+import org.apache.kafka.clients.CommonClientConfigs;
+import org.apache.kafka.common.acl.AclBinding;
+import org.apache.kafka.common.acl.AclOperation;
+import org.apache.kafka.common.acl.AclPermissionType;
+import org.apache.kafka.common.config.AbstractConfig;
+import org.apache.kafka.common.config.ConfigDef;
+import org.apache.kafka.common.config.SaslConfigs;
+import org.apache.kafka.common.config.SecurityConfig;
+import org.apache.kafka.common.config.SslConfigs;
+import org.apache.kafka.common.resource.ResourceType;
+import org.apache.kafka.common.security.auth.SecurityProtocol;
+
+import com.google.re2j.Pattern;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+
+import static org.apache.kafka.common.config.ConfigDef.Importance.HIGH;
+import static org.apache.kafka.common.config.ConfigDef.Importance.LOW;
+import static org.apache.kafka.common.config.ConfigDef.Importance.MEDIUM;
+import static org.apache.kafka.common.config.ConfigDef.Range.atLeast;
+import static org.apache.kafka.common.config.ConfigDef.Range.between;
+import static org.apache.kafka.common.config.ConfigDef.Type.INT;
+import static org.apache.kafka.common.config.ConfigDef.Type.LIST;
+import static org.apache.kafka.common.config.ConfigDef.Type.LONG;
+import static org.apache.kafka.common.config.ConfigDef.Type.PASSWORD;
+import static org.apache.kafka.common.config.ConfigDef.Type.SHORT;
+import static org.apache.kafka.common.config.ConfigDef.Type.STRING;
+import static org.apache.kafka.server.util.MirrorUtils.compilePattern;
+import static org.apache.kafka.server.util.MirrorUtils.compilePatternList;
+
+/**
+ * This class provides proper validation, defaults, and documentation
+ * for all configurations supported by the Cluster Mirroring feature.
+ */
+public final class ClusterMirrorConfig extends AbstractConfig {
+    // ---------------------------------------------------------------
+    // Broker level configs. Set when starting/rebooting the broker. Stored in 
server.properties or dynamic broker config.
+    // ---------------------------------------------------------------
+
+    public static final String MIRROR_COORDINATOR_THREADS_CONFIG = 
"mirror.coordinator.threads";
+    private static final int MIRROR_COORDINATOR_THREADS_DEFAULT = 1;
+    private static final String MIRROR_COORDINATOR_THREADS_DOC = "The number 
of threads used to process coordinator events for cluster mirroring.";
+
+    public static final String MIRROR_COORDINATOR_WRITE_TIMEOUT_MS_CONFIG = 
"mirror.coordinator.write.timeout.ms";
+    private static final long MIRROR_COORDINATOR_WRITE_TIMEOUT_MS_DEFAULT = 
5000L;
+    private static final String MIRROR_COORDINATOR_WRITE_TIMEOUT_MS_DOC = "The 
timeout in milliseconds for write operations on the mirror state coordinator.";
+
+    public static final String MIRROR_COORDINATOR_APPEND_LINGER_MS_CONFIG = 
"mirror.coordinator.append.linger.ms";
+    private static final int MIRROR_COORDINATOR_APPEND_LINGER_MS_DEFAULT = 10;
+    private static final String MIRROR_COORDINATOR_APPEND_LINGER_MS_DOC = "The 
linger time in milliseconds for batching records before flushing to the mirror 
state topic.";
+
+    public static final String MIRROR_COORDINATOR_LOAD_BUFFER_SIZE_CONFIG = 
"mirror.coordinator.load.buffer.size";
+    private static final int MIRROR_COORDINATOR_LOAD_BUFFER_SIZE_DEFAULT = 5 * 
1024 * 1024;
+    private static final String MIRROR_COORDINATOR_LOAD_BUFFER_SIZE_DOC = "The 
buffer size in bytes for loading mirror state records during coordinator 
startup.";
+
+    public static final String MIRROR_STATE_TOPIC_NUM_PARTITIONS_CONFIG = 
"mirror.state.topic.num.partitions";
+    private static final int MIRROR_STATE_TOPIC_NUM_PARTITIONS_DEFAULT = 50;
+    private static final String MIRROR_STATE_TOPIC_NUM_PARTITIONS_DOC = "The 
number of partitions for the internal topic (should not change after 
deployment).";
+
+    public static final String MIRROR_STATE_TOPIC_REPLICATION_FACTOR_CONFIG = 
"mirror.state.topic.replication.factor";
+    private static final short MIRROR_STATE_TOPIC_REPLICATION_FACTOR_DEFAULT = 
3;
+    private static final String MIRROR_STATE_TOPIC_REPLICATION_FACTOR_DOC = 
"The replication factor for the internal topic. " +
+            "Topic creation will fail until the cluster size meets this 
replication factor requirement.";
+
+    public static final String MIRROR_NUM_REPLICA_FETCHERS_CONFIG = 
"mirror.num.replica.fetchers";
+    private static final int MIRROR_NUM_REPLICA_FETCHERS_DEFAULT = 1;
+    private static final String MIRROR_NUM_REPLICA_FETCHERS_DOC = "Number of 
fetcher threads used to replicate records from each source broker in a cluster 
mirror. " +
+            "The total number of mirror fetcher threads on a broker equals 
this value multiplied by the number of distinct source brokers and the number 
of cluster mirrors. " +
+            "A higher value increases I/O parallelism for cross cluster 
replication at the cost of higher CPU and memory utilization.";
+
+    public static final String MIRROR_METADATA_REFRESH_INTERVAL_MS_CONFIG = 
"mirror.metadata.refresh.interval.ms";
+    private static final long MIRROR_METADATA_REFRESH_INTERVAL_MS_DEFAULT = 
60000L;
+    private static final String MIRROR_METADATA_REFRESH_INTERVAL_MS_DOC = "The 
interval in milliseconds at which the coordinator refreshes metadata from 
source clusters. " +
+            "This controls how frequently the coordinator polls source 
clusters to detect new topics and metadata changes.";
+
+    public static final String MIRROR_FAILED_RETRY_INITIAL_BACKOFF_MS_CONFIG = 
"mirror.failed.retry.initial.backoff.ms";
+    private static final long MIRROR_FAILED_RETRY_INITIAL_BACKOFF_MS_DEFAULT = 
100L;
+    private static final String MIRROR_FAILED_RETRY_INITIAL_BACKOFF_MS_DOC = 
"The initial backoff time in milliseconds before retrying a mirror partition " +
+            "in FAILED state. The actual delay uses full jitter: a uniform 
random value in [0, backoff].";
+
+    public static final String MIRROR_FAILED_RETRY_MAX_BACKOFF_MS_CONFIG = 
"mirror.failed.retry.max.backoff.ms";
+    private static final long MIRROR_FAILED_RETRY_MAX_BACKOFF_MS_DEFAULT = 
300000L;
+    private static final String MIRROR_FAILED_RETRY_MAX_BACKOFF_MS_DOC = "The 
maximum backoff time in milliseconds for retrying a mirror partition in FAILED 
state.";
+
+    public static final String MIRROR_FAILED_RETRY_MAX_ATTEMPTS_CONFIG = 
"mirror.failed.retry.max.attempts";
+    private static final int MIRROR_FAILED_RETRY_MAX_ATTEMPTS_DEFAULT = 20;
+    private static final String MIRROR_FAILED_RETRY_MAX_ATTEMPTS_DOC = "The 
maximum number of automatic retry attempts for a mirror partition in FAILED 
state. " +
+            "After this limit is reached, manual intervention is required via 
the start-mirror-topics command. " +
+            "Set to 0 to disable automatic retries.";
+
+    // ---------------------------------------------------------------
+    // Mirror level configs. Set when creating/altering a specific mirror. 
Stored in cluster metadata.
+    // ---------------------------------------------------------------
+
+    // Connection configuration
+    public static final String BOOTSTRAP_SERVERS_CONFIG = 
CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG;
+    private static final String BOOTSTRAP_SERVERS_DOC = "A list of host/port 
pairs to use for establishing the initial connection to the source cluster. " +
+            "This is a required configuration when creating a cluster mirror.";
+
+    public static final String SOURCE_CLUSTER_ID_CONFIG = 
CommonClientConfigs.SOURCE_CLUSTER_ID_CONFIG;
+    private static final String SOURCE_CLUSTER_ID_DOC = 
CommonClientConfigs.SOURCE_CLUSTER_ID_DOC;
+
+    public static final String REQUEST_TIMEOUT_MS_CONFIG = 
CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG;
+    private static final int REQUEST_TIMEOUT_MS_DEFAULT = 30 * 1000;
+    private static final String REQUEST_TIMEOUT_MS_DOC = 
CommonClientConfigs.REQUEST_TIMEOUT_MS_DOC;
+
+    public static final String CONNECTION_SETUP_TIMEOUT_MS_CONFIG = 
CommonClientConfigs.SOCKET_CONNECTION_SETUP_TIMEOUT_MS_CONFIG;
+    private static final long CONNECTION_SETUP_TIMEOUT_MS_DEFAULT = 
CommonClientConfigs.DEFAULT_SOCKET_CONNECTION_SETUP_TIMEOUT_MS;
+    private static final String CONNECTION_SETUP_TIMEOUT_MS_DOC = 
CommonClientConfigs.SOCKET_CONNECTION_SETUP_TIMEOUT_MS_DOC;
+
+    public static final String CONNECTION_SETUP_TIMEOUT_MAX_MS_CONFIG = 
CommonClientConfigs.SOCKET_CONNECTION_SETUP_TIMEOUT_MAX_MS_CONFIG;
+    private static final long CONNECTION_SETUP_TIMEOUT_MAX_MS_DEFAULT = 
CommonClientConfigs.DEFAULT_SOCKET_CONNECTION_SETUP_TIMEOUT_MAX_MS;
+    private static final String CONNECTION_SETUP_TIMEOUT_MAX_MS_DOC = 
CommonClientConfigs.SOCKET_CONNECTION_SETUP_TIMEOUT_MAX_MS_DOC;
+
+    public static final String CONNECTIONS_MAX_IDLE_MS_CONFIG = 
"connections.max.idle.ms";
+    private static final long CONNECTIONS_MAX_IDLE_MS_DEFAULT = 10 * 60 * 
1000L;
+    private static final String CONNECTIONS_MAX_IDLE_MS_DOC = "Idle 
connections timeout: the server socket processor threads close the connections 
that idle more than this";
+
+    // Fetch and network configuration.
+    // The replica.* equivalents use a mirror.* prefix to avoid ambiguity with 
broker-level configs.
+    // The others reuse the existing key names since they have no replica.* 
prefix.
+    public static final String FETCH_WAIT_MAX_MS_CONFIG = "fetch.wait.max.ms";
+    private static final int FETCH_WAIT_MAX_MS_DEFAULT = 1000;
+    private static final String FETCH_WAIT_MAX_MS_DOC = "The maximum wait time 
for each fetcher request issued by mirror replicas.";
+
+    public static final String FETCH_BACKOFF_MS_CONFIG = "fetch.backoff.ms";
+    private static final long FETCH_BACKOFF_MS_DEFAULT = 1000;
+    private static final String FETCH_BACKOFF_MS_DOC = "The amount of time to 
wait before retrying mirror fetch requests after a failure. " +
+            "This controls the backoff for mirror fetcher threads on 
connection errors or other exceptions from the source cluster.";
+
+    public static final String FETCH_MIN_BYTES_CONFIG = "fetch.min.bytes";
+    private static final int FETCH_MIN_BYTES_DEFAULT = 1;
+    private static final String FETCH_MIN_BYTES_DOC = "Minimum bytes expected 
for each fetch response.";
+
+    public static final String FETCH_RESPONSE_MAX_BYTES_CONFIG = 
"fetch.response.max.bytes";
+    private static final int FETCH_RESPONSE_MAX_BYTES_DEFAULT = 10 * 1024 * 
1024;
+    private static final String FETCH_RESPONSE_MAX_BYTES_DOC = "Maximum bytes 
expected for the entire fetch response. Records are fetched in batches, " +
+            "and if the first record batch in the first non-empty partition is 
larger than this value, the record batch will still be returned.";
+
+    public static final String FETCH_MAX_BYTES_CONFIG = "fetch.max.bytes";
+    private static final int FETCH_MAX_BYTES_DEFAULT = 1024 * 1024;
+    private static final String FETCH_MAX_BYTES_DOC = "The number of bytes of 
messages to attempt to fetch for each partition.";
+
+    public static final String SOCKET_TIMEOUT_MS_CONFIG = "socket.timeout.ms";
+    private static final int SOCKET_TIMEOUT_MS_DEFAULT = 30 * 1000;
+    private static final String SOCKET_TIMEOUT_MS_DOC = "The socket timeout 
for network requests.";
+
+    public static final String SOCKET_RECEIVE_BUFFER_BYTES_CONFIG = 
"socket.receive.buffer.bytes";
+    private static final int SOCKET_RECEIVE_BUFFER_BYTES_DEFAULT = 64 * 1024;
+    private static final String SOCKET_RECEIVE_BUFFER_BYTES_DOC = "The socket 
receive buffer for network requests to the leader for replicating data.";
+
+    // Filter configuration
+    public static final String TOPIC_PROPERTIES_EXCLUDE_CONFIG = 
"topic.properties.exclude";
+    private static final String TOPIC_PROPERTIES_EXCLUDE_DEFAULT =
+            "follower.replication.throttled.replicas,"
+                    + "leader.replication.throttled.replicas,"
+                    + "message.timestamp.difference.max.ms,"
+                    + "log.message.timestamp.before.max.ms,"
+                    + "log.message.timestamp.after.max.ms,"
+                    + "message.timestamp.type,"
+                    + "unclean.leader.election.enable,"
+                    + "min.insync.replicas,"
+                    + "mirror.replication.throttled.replicas,"
+                    + "mirror.unclean.leader.election.enable";
+    private static final String TOPIC_PROPERTIES_EXCLUDE_DOC = "A 
comma-separated list of topic config property names to exclude from 
synchronization. "
+            + "Properties in this list will not be replicated from the source 
cluster. "
+            + "The mirror.name property is always excluded regardless of this 
setting.";
+
+    public static final String TOPICS_INCLUDE_CONFIG = "topics.include";
+    private static final String TOPICS_INCLUDE_DEFAULT = ".*";
+    private static final String TOPICS_INCLUDE_DOC = "A comma-separated list 
of regex patterns for topic names to include in mirroring. "
+            + "Topics on the source cluster whose names match at least one of 
the patterns will be automatically discovered and mirrored. ";
+
+    public static final String TOPICS_EXCLUDE_CONFIG = "topics.exclude";
+    private static final String TOPICS_EXCLUDE_DEFAULT = "__.*";
+    private static final String TOPICS_EXCLUDE_DOC = "A comma-separated list 
of regex patterns for topic names to exclude from mirroring "
+            + "Internal topics are excluded by default. Exclusions take 
precedence over inclusions.";
+
+    public static final String GROUPS_INCLUDE_CONFIG = "groups.include";
+    private static final String GROUPS_INCLUDE_DEFAULT = ".*";
+    private static final String GROUPS_INCLUDE_DOC = "A comma-separated list 
of regex patterns for consumer group IDs to include in offset synchronization. "
+            + "Only consumer groups whose IDs match at least one of the 
patterns will have their offsets replicated from the source cluster.";
+
+    public static final String GROUPS_EXCLUDE_CONFIG = "groups.exclude";
+    private static final String GROUPS_EXCLUDE_DEFAULT = "";
+    private static final String GROUPS_EXCLUDE_DOC = "A comma-separated list 
of regex patterns for consumer group IDs to exclude from offset 
synchronization. " +
+            "Exclusions take precedence over inclusions.";
+
+    public static final String ACLS_INCLUDE_CONFIG = "acls.include";
+    private static final String ACLS_INCLUDE_DEFAULT = ".*";
+    private static final String ACLS_INCLUDE_DOC = "A comma-separated list of 
ACL include rules. " + MirrorAclRule.DOC
+            + "Examples: .* (match all ACLs), TOPIC;orders.* (all ACLs for 
topics matching orders.*), "
+            + "TOPIC;.*;READ;ALLOW,TOPIC;.*;WRITE;ALLOW (all topic READ and 
WRITE ALLOW ACLs), "
+            + "ANY;.*;ANY;ANY;User:alice (all ACLs for principal User:alice).";
+
+    public static final String ACLS_EXCLUDE_CONFIG = "acls.exclude";
+    private static final String ACLS_EXCLUDE_DEFAULT = "";
+    private static final String ACLS_EXCLUDE_DOC = "A comma-separated list of 
ACL exclude rules. " + MirrorAclRule.DOC
+            + "Exclusions take precedence over inclusions. "
+            + "Examples: .* (exclude all ACLs), ANY;.*;WRITE (exclude all 
WRITE ACLs), "
+            + "ANY;.*;ANY;ANY;User:bob (exclude all ACLs for User:bob).";
+
+    // Security configuration
+    public static final String SECURITY_PROTOCOL_CONFIG = 
CommonClientConfigs.SECURITY_PROTOCOL_CONFIG;
+    private static final String SECURITY_PROTOCOL_DEFAULT = 
SecurityProtocol.PLAINTEXT.name;
+    private static final String SECURITY_PROTOCOL_DOC = 
CommonClientConfigs.SECURITY_PROTOCOL_DOC;
+
+    public static final String SECURITY_PROVIDERS_CONFIG = 
SecurityConfig.SECURITY_PROVIDERS_CONFIG;
+    private static final String SECURITY_PROVIDERS_DOC = 
SecurityConfig.SECURITY_PROVIDERS_DOC;
+
+    public static final String SASL_MECHANISM_CONFIG = 
SaslConfigs.SASL_MECHANISM;
+    private static final String SASL_MECHANISM_DEFAULT = "PLAIN";
+    private static final String SASL_MECHANISM_DOC = 
SaslConfigs.SASL_MECHANISM_DOC;
+
+    public static final String SASL_JAAS_CONFIG = SaslConfigs.SASL_JAAS_CONFIG;
+    private static final String SASL_JAAS_CONFIG_DOC = 
SaslConfigs.SASL_JAAS_CONFIG_DOC;
+
+    public static final String SASL_CLIENT_CALLBACK_HANDLER_CLASS = 
SaslConfigs.SASL_CLIENT_CALLBACK_HANDLER_CLASS;
+    private static final String SASL_CLIENT_CALLBACK_HANDLER_CLASS_DOC = 
SaslConfigs.SASL_CLIENT_CALLBACK_HANDLER_CLASS_DOC;
+
+    public static final String SASL_LOGIN_CALLBACK_HANDLER_CLASS = 
SaslConfigs.SASL_LOGIN_CALLBACK_HANDLER_CLASS;
+    private static final String SASL_LOGIN_CALLBACK_HANDLER_CLASS_DOC = 
SaslConfigs.SASL_LOGIN_CALLBACK_HANDLER_CLASS_DOC;
+
+    public static final String SASL_LOGIN_CLASS = SaslConfigs.SASL_LOGIN_CLASS;
+    private static final String SASL_LOGIN_CLASS_DOC = 
SaslConfigs.SASL_LOGIN_CLASS_DOC;
+
+    public static final String SASL_KERBEROS_SERVICE_NAME = 
SaslConfigs.SASL_KERBEROS_SERVICE_NAME;
+    private static final String SASL_KERBEROS_SERVICE_NAME_DOC = 
SaslConfigs.SASL_KERBEROS_SERVICE_NAME_DOC;
+
+    public static final String SSL_PROTOCOL_CONFIG = 
SslConfigs.SSL_PROTOCOL_CONFIG;
+    private static final String SSL_PROTOCOL_DEFAULT = 
SslConfigs.DEFAULT_SSL_PROTOCOL;
+    private static final String SSL_PROTOCOL_DOC = SslConfigs.SSL_PROTOCOL_DOC;
+
+    public static final String SSL_PROVIDER_CONFIG = 
SslConfigs.SSL_PROVIDER_CONFIG;
+    private static final String SSL_PROVIDER_DOC = SslConfigs.SSL_PROVIDER_DOC;
+
+    public static final String SSL_CIPHER_SUITES_CONFIG = 
SslConfigs.SSL_CIPHER_SUITES_CONFIG;
+    private static final String SSL_CIPHER_SUITES_DOC = 
SslConfigs.SSL_CIPHER_SUITES_DOC;
+
+    public static final String SSL_ENABLED_PROTOCOLS_CONFIG = 
SslConfigs.SSL_ENABLED_PROTOCOLS_CONFIG;
+    private static final String SSL_ENABLED_PROTOCOLS_DOC = 
SslConfigs.SSL_ENABLED_PROTOCOLS_DOC;
+
+    public static final String SSL_KEYSTORE_TYPE_CONFIG = 
SslConfigs.SSL_KEYSTORE_TYPE_CONFIG;
+    private static final String SSL_KEYSTORE_TYPE_DEFAULT = 
SslConfigs.DEFAULT_SSL_KEYSTORE_TYPE;
+    private static final String SSL_KEYSTORE_TYPE_DOC = 
SslConfigs.SSL_KEYSTORE_TYPE_DOC;
+
+    public static final String SSL_KEYSTORE_LOCATION_CONFIG = 
SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG;
+    private static final String SSL_KEYSTORE_LOCATION_DOC = 
SslConfigs.SSL_KEYSTORE_LOCATION_DOC;
+
+    public static final String SSL_KEYSTORE_PASSWORD_CONFIG = 
SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG;
+    private static final String SSL_KEYSTORE_PASSWORD_DOC = 
SslConfigs.SSL_KEYSTORE_PASSWORD_DOC;
+
+    public static final String SSL_KEY_PASSWORD_CONFIG = 
SslConfigs.SSL_KEY_PASSWORD_CONFIG;
+    private static final String SSL_KEY_PASSWORD_DOC = 
SslConfigs.SSL_KEY_PASSWORD_DOC;
+
+    public static final String SSL_KEYSTORE_KEY_CONFIG = 
SslConfigs.SSL_KEYSTORE_KEY_CONFIG;
+    private static final String SSL_KEYSTORE_KEY_DOC = 
SslConfigs.SSL_KEYSTORE_KEY_DOC;
+
+    public static final String SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG = 
SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG;
+    private static final String SSL_KEYSTORE_CERTIFICATE_CHAIN_DOC = 
SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_DOC;
+
+    public static final String SSL_TRUSTSTORE_TYPE_CONFIG = 
SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG;
+    private static final String SSL_TRUSTSTORE_TYPE_DEFAULT = 
SslConfigs.DEFAULT_SSL_TRUSTSTORE_TYPE;
+    private static final String SSL_TRUSTSTORE_TYPE_DOC = 
SslConfigs.SSL_TRUSTSTORE_TYPE_DOC;
+
+    public static final String SSL_TRUSTSTORE_LOCATION_CONFIG = 
SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG;
+    private static final String SSL_TRUSTSTORE_LOCATION_DOC = 
SslConfigs.SSL_TRUSTSTORE_LOCATION_DOC;
+
+    public static final String SSL_TRUSTSTORE_PASSWORD_CONFIG = 
SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG;
+    private static final String SSL_TRUSTSTORE_PASSWORD_DOC = 
SslConfigs.SSL_TRUSTSTORE_PASSWORD_DOC;
+
+    public static final String SSL_TRUSTSTORE_CERTIFICATES_CONFIG = 
SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_CONFIG;
+    private static final String SSL_TRUSTSTORE_CERTIFICATES_DOC = 
SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_DOC;
+
+    public static final String SSL_KEYMANAGER_ALGORITHM_CONFIG = 
SslConfigs.SSL_KEYMANAGER_ALGORITHM_CONFIG;
+    private static final String SSL_KEYMANAGER_ALGORITHM_DEFAULT = 
SslConfigs.DEFAULT_SSL_KEYMANGER_ALGORITHM;
+    private static final String SSL_KEYMANAGER_ALGORITHM_DOC = 
SslConfigs.SSL_KEYMANAGER_ALGORITHM_DOC;
+
+    public static final String SSL_TRUSTMANAGER_ALGORITHM_CONFIG = 
SslConfigs.SSL_TRUSTMANAGER_ALGORITHM_CONFIG;
+    private static final String SSL_TRUSTMANAGER_ALGORITHM_DEFAULT = 
SslConfigs.DEFAULT_SSL_TRUSTMANAGER_ALGORITHM;
+    private static final String SSL_TRUSTMANAGER_ALGORITHM_DOC = 
SslConfigs.SSL_TRUSTMANAGER_ALGORITHM_DOC;
+
+    public static final String SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG = 
SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG;
+    private static final String SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_DEFAULT 
= SslConfigs.DEFAULT_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM;
+    private static final String SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_DOC = 
SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_DOC;
+
+    public static final String SSL_SECURE_RANDOM_IMPLEMENTATION_CONFIG = 
SslConfigs.SSL_SECURE_RANDOM_IMPLEMENTATION_CONFIG;
+    private static final String SSL_SECURE_RANDOM_IMPLEMENTATION_DOC = 
SslConfigs.SSL_SECURE_RANDOM_IMPLEMENTATION_DOC;
+
+    public static final String SSL_ENGINE_FACTORY_CLASS_CONFIG = 
SslConfigs.SSL_ENGINE_FACTORY_CLASS_CONFIG;
+    private static final String SSL_ENGINE_FACTORY_CLASS_DOC = 
SslConfigs.SSL_ENGINE_FACTORY_CLASS_DOC;
+
+    private static final ConfigDef CONFIG_DEF = new ConfigDef()
+            .define(BOOTSTRAP_SERVERS_CONFIG, LIST, null, HIGH, 
BOOTSTRAP_SERVERS_DOC)
+            .define(SOURCE_CLUSTER_ID_CONFIG, STRING, null, HIGH, 
SOURCE_CLUSTER_ID_DOC)
+            .define(REQUEST_TIMEOUT_MS_CONFIG, INT, 
REQUEST_TIMEOUT_MS_DEFAULT, atLeast(0), MEDIUM, REQUEST_TIMEOUT_MS_DOC)
+            .define(CONNECTION_SETUP_TIMEOUT_MS_CONFIG, LONG, 
CONNECTION_SETUP_TIMEOUT_MS_DEFAULT, atLeast(0L), MEDIUM, 
CONNECTION_SETUP_TIMEOUT_MS_DOC)
+            .define(CONNECTION_SETUP_TIMEOUT_MAX_MS_CONFIG, LONG, 
CONNECTION_SETUP_TIMEOUT_MAX_MS_DEFAULT, atLeast(0L), MEDIUM, 
CONNECTION_SETUP_TIMEOUT_MAX_MS_DOC)
+            .define(CONNECTIONS_MAX_IDLE_MS_CONFIG, LONG, 
CONNECTIONS_MAX_IDLE_MS_DEFAULT, MEDIUM, CONNECTIONS_MAX_IDLE_MS_DOC)
+            .define(FETCH_WAIT_MAX_MS_CONFIG, INT, FETCH_WAIT_MAX_MS_DEFAULT, 
atLeast(0), MEDIUM, FETCH_WAIT_MAX_MS_DOC)
+            .define(FETCH_BACKOFF_MS_CONFIG, LONG, FETCH_BACKOFF_MS_DEFAULT, 
atLeast(0L), MEDIUM, FETCH_BACKOFF_MS_DOC)
+            .define(FETCH_MIN_BYTES_CONFIG, INT, FETCH_MIN_BYTES_DEFAULT, 
atLeast(0), MEDIUM, FETCH_MIN_BYTES_DOC)
+            .define(FETCH_RESPONSE_MAX_BYTES_CONFIG, INT, 
FETCH_RESPONSE_MAX_BYTES_DEFAULT, atLeast(0), MEDIUM, 
FETCH_RESPONSE_MAX_BYTES_DOC)
+            .define(FETCH_MAX_BYTES_CONFIG, INT, FETCH_MAX_BYTES_DEFAULT, 
atLeast(0), MEDIUM, FETCH_MAX_BYTES_DOC)
+            .define(SOCKET_TIMEOUT_MS_CONFIG, INT, SOCKET_TIMEOUT_MS_DEFAULT, 
atLeast(0), MEDIUM, SOCKET_TIMEOUT_MS_DOC)
+            .define(SOCKET_RECEIVE_BUFFER_BYTES_CONFIG, INT, 
SOCKET_RECEIVE_BUFFER_BYTES_DEFAULT, atLeast(0), MEDIUM, 
SOCKET_RECEIVE_BUFFER_BYTES_DOC)
+            .define(TOPIC_PROPERTIES_EXCLUDE_CONFIG, LIST, 
TOPIC_PROPERTIES_EXCLUDE_DEFAULT, LOW, TOPIC_PROPERTIES_EXCLUDE_DOC)
+            .define(TOPICS_INCLUDE_CONFIG, LIST, TOPICS_INCLUDE_DEFAULT, LOW, 
TOPICS_INCLUDE_DOC)
+            .define(TOPICS_EXCLUDE_CONFIG, LIST, TOPICS_EXCLUDE_DEFAULT, LOW, 
TOPICS_EXCLUDE_DOC)
+            .define(GROUPS_INCLUDE_CONFIG, LIST, GROUPS_INCLUDE_DEFAULT, LOW, 
GROUPS_INCLUDE_DOC)
+            .define(GROUPS_EXCLUDE_CONFIG, LIST, GROUPS_EXCLUDE_DEFAULT, LOW, 
GROUPS_EXCLUDE_DOC)
+            .define(ACLS_INCLUDE_CONFIG, LIST, ACLS_INCLUDE_DEFAULT, LOW, 
ACLS_INCLUDE_DOC)
+            .define(ACLS_EXCLUDE_CONFIG, LIST, ACLS_EXCLUDE_DEFAULT, LOW, 
ACLS_EXCLUDE_DOC)
+            .define(SECURITY_PROTOCOL_CONFIG, STRING, 
SECURITY_PROTOCOL_DEFAULT, 
ConfigDef.ValidString.in(SecurityProtocol.PLAINTEXT.name, 
SecurityProtocol.SSL.name,
+                    SecurityProtocol.SASL_PLAINTEXT.name, 
SecurityProtocol.SASL_SSL.name), MEDIUM, SECURITY_PROTOCOL_DOC)
+            .define(SECURITY_PROVIDERS_CONFIG, STRING, null, LOW, 
SECURITY_PROVIDERS_DOC)
+            .define(SASL_MECHANISM_CONFIG, STRING, SASL_MECHANISM_DEFAULT, 
MEDIUM, SASL_MECHANISM_DOC)
+            .define(SASL_JAAS_CONFIG, PASSWORD, null, MEDIUM, 
SASL_JAAS_CONFIG_DOC)
+            .define(SASL_CLIENT_CALLBACK_HANDLER_CLASS, STRING, null, LOW, 
SASL_CLIENT_CALLBACK_HANDLER_CLASS_DOC)
+            .define(SASL_LOGIN_CALLBACK_HANDLER_CLASS, STRING, null, LOW, 
SASL_LOGIN_CALLBACK_HANDLER_CLASS_DOC)
+            .define(SASL_LOGIN_CLASS, STRING, null, LOW, SASL_LOGIN_CLASS_DOC)
+            .define(SASL_KERBEROS_SERVICE_NAME, STRING, null, MEDIUM, 
SASL_KERBEROS_SERVICE_NAME_DOC)
+            .define(SSL_PROTOCOL_CONFIG, STRING, SSL_PROTOCOL_DEFAULT, MEDIUM, 
SSL_PROTOCOL_DOC)
+            .define(SSL_PROVIDER_CONFIG, STRING, null, LOW, SSL_PROVIDER_DOC)
+            .define(SSL_CIPHER_SUITES_CONFIG, LIST, null, LOW, 
SSL_CIPHER_SUITES_DOC)
+            .define(SSL_ENABLED_PROTOCOLS_CONFIG, LIST, null, MEDIUM, 
SSL_ENABLED_PROTOCOLS_DOC)
+            .define(SSL_KEYSTORE_TYPE_CONFIG, STRING, 
SSL_KEYSTORE_TYPE_DEFAULT, MEDIUM, SSL_KEYSTORE_TYPE_DOC)
+            .define(SSL_KEYSTORE_LOCATION_CONFIG, STRING, null, MEDIUM, 
SSL_KEYSTORE_LOCATION_DOC)
+            .define(SSL_KEYSTORE_PASSWORD_CONFIG, PASSWORD, null, MEDIUM, 
SSL_KEYSTORE_PASSWORD_DOC)
+            .define(SSL_KEY_PASSWORD_CONFIG, PASSWORD, null, MEDIUM, 
SSL_KEY_PASSWORD_DOC)
+            .define(SSL_KEYSTORE_KEY_CONFIG, PASSWORD, null, MEDIUM, 
SSL_KEYSTORE_KEY_DOC)
+            .define(SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG, PASSWORD, null, 
MEDIUM, SSL_KEYSTORE_CERTIFICATE_CHAIN_DOC)
+            .define(SSL_TRUSTSTORE_TYPE_CONFIG, STRING, 
SSL_TRUSTSTORE_TYPE_DEFAULT, MEDIUM, SSL_TRUSTSTORE_TYPE_DOC)
+            .define(SSL_TRUSTSTORE_LOCATION_CONFIG, STRING, null, MEDIUM, 
SSL_TRUSTSTORE_LOCATION_DOC)
+            .define(SSL_TRUSTSTORE_PASSWORD_CONFIG, PASSWORD, null, MEDIUM, 
SSL_TRUSTSTORE_PASSWORD_DOC)
+            .define(SSL_TRUSTSTORE_CERTIFICATES_CONFIG, PASSWORD, null, 
MEDIUM, SSL_TRUSTSTORE_CERTIFICATES_DOC)
+            .define(SSL_KEYMANAGER_ALGORITHM_CONFIG, STRING, 
SSL_KEYMANAGER_ALGORITHM_DEFAULT, LOW, SSL_KEYMANAGER_ALGORITHM_DOC)
+            .define(SSL_TRUSTMANAGER_ALGORITHM_CONFIG, STRING, 
SSL_TRUSTMANAGER_ALGORITHM_DEFAULT, LOW, SSL_TRUSTMANAGER_ALGORITHM_DOC)
+            .define(SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, STRING, 
SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_DEFAULT, LOW, 
SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_DOC)
+            .define(SSL_SECURE_RANDOM_IMPLEMENTATION_CONFIG, STRING, null, 
LOW, SSL_SECURE_RANDOM_IMPLEMENTATION_DOC)
+            .define(SSL_ENGINE_FACTORY_CLASS_CONFIG, STRING, null, LOW, 
SSL_ENGINE_FACTORY_CLASS_DOC);
+
+    private static final ConfigDef BROKER_CONFIG_DEF = new ConfigDef()
+            .define(MIRROR_COORDINATOR_THREADS_CONFIG, INT, 
MIRROR_COORDINATOR_THREADS_DEFAULT, atLeast(1), LOW, 
MIRROR_COORDINATOR_THREADS_DOC)
+            .define(MIRROR_COORDINATOR_WRITE_TIMEOUT_MS_CONFIG, LONG, 
MIRROR_COORDINATOR_WRITE_TIMEOUT_MS_DEFAULT, atLeast(1L), LOW, 
MIRROR_COORDINATOR_WRITE_TIMEOUT_MS_DOC)
+            .define(MIRROR_COORDINATOR_APPEND_LINGER_MS_CONFIG, INT, 
MIRROR_COORDINATOR_APPEND_LINGER_MS_DEFAULT, atLeast(0), LOW, 
MIRROR_COORDINATOR_APPEND_LINGER_MS_DOC)
+            .define(MIRROR_COORDINATOR_LOAD_BUFFER_SIZE_CONFIG, INT, 
MIRROR_COORDINATOR_LOAD_BUFFER_SIZE_DEFAULT, atLeast(1), LOW, 
MIRROR_COORDINATOR_LOAD_BUFFER_SIZE_DOC)
+            .define(MIRROR_STATE_TOPIC_NUM_PARTITIONS_CONFIG, INT, 
MIRROR_STATE_TOPIC_NUM_PARTITIONS_DEFAULT, atLeast(1), HIGH, 
MIRROR_STATE_TOPIC_NUM_PARTITIONS_DOC)
+            .define(MIRROR_STATE_TOPIC_REPLICATION_FACTOR_CONFIG, SHORT, 
MIRROR_STATE_TOPIC_REPLICATION_FACTOR_DEFAULT, atLeast(1), HIGH, 
MIRROR_STATE_TOPIC_REPLICATION_FACTOR_DOC)
+            .define(MIRROR_NUM_REPLICA_FETCHERS_CONFIG, INT, 
MIRROR_NUM_REPLICA_FETCHERS_DEFAULT, atLeast(1), HIGH, 
MIRROR_NUM_REPLICA_FETCHERS_DOC)
+            .define(MIRROR_METADATA_REFRESH_INTERVAL_MS_CONFIG, LONG, 
MIRROR_METADATA_REFRESH_INTERVAL_MS_DEFAULT, atLeast(0L), MEDIUM, 
MIRROR_METADATA_REFRESH_INTERVAL_MS_DOC)
+            .define(MIRROR_FAILED_RETRY_INITIAL_BACKOFF_MS_CONFIG, LONG, 
MIRROR_FAILED_RETRY_INITIAL_BACKOFF_MS_DEFAULT, atLeast(1L), MEDIUM, 
MIRROR_FAILED_RETRY_INITIAL_BACKOFF_MS_DOC)
+            .define(MIRROR_FAILED_RETRY_MAX_BACKOFF_MS_CONFIG, LONG, 
MIRROR_FAILED_RETRY_MAX_BACKOFF_MS_DEFAULT, atLeast(1L), MEDIUM, 
MIRROR_FAILED_RETRY_MAX_BACKOFF_MS_DOC)
+            .define(MIRROR_FAILED_RETRY_MAX_ATTEMPTS_CONFIG, INT, 
MIRROR_FAILED_RETRY_MAX_ATTEMPTS_DEFAULT, between(0, Short.MAX_VALUE), MEDIUM, 
MIRROR_FAILED_RETRY_MAX_ATTEMPTS_DOC);
+
+    private final Pattern topicPropertiesExcludePattern;
+    private final Pattern topicsIncludePattern;
+    private final Pattern topicsExcludePattern;
+    private final Pattern groupsIncludePattern;
+    private final Pattern groupsExcludePattern;
+    private final List<MirrorAclRule> aclIncludeRules;
+    private final List<MirrorAclRule> aclExcludeRules;
+    private final String securityProtocol;
+    private final String saslMechanism;
+
+    /**
+     * Creates a ClusterMirrorConfig from mirror metadata properties stored in 
the cluster metadata.
+     * Filter configs are loaded from the metadata, with defaults applied for 
any missing values.
+     *
+     * @param properties the mirror metadata properties
+     * @return a new ClusterMirrorConfig instance
+     */
+    public static ClusterMirrorConfig fromProperties(Properties properties) {
+        return fromProperties(properties, false);
+    }
+
+    /**
+     * Creates a ClusterMirrorConfig from mirror metadata properties stored in 
the cluster metadata.
+     * Filter configs are loaded from the metadata, with defaults applied for 
any missing values.
+     *
+     * @param properties the mirror metadata properties
+     * @param doLog whether to log all configuration values
+     * @return a new ClusterMirrorConfig instance
+     */
+    public static ClusterMirrorConfig fromProperties(Properties properties, 
boolean doLog) {
+        return new ClusterMirrorConfig(CONFIG_DEF, properties, doLog);
+    }
+
+    private ClusterMirrorConfig(ConfigDef configDef, Properties properties, 
boolean doLog) {

Review Comment:
   Please add tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to