nizhikov commented on code in PR #15075:
URL: https://github.com/apache/kafka/pull/15075#discussion_r1540643481


##########
server/src/main/java/org/apache/kafka/server/config/ZkConfig.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.config;
+
+import org.apache.zookeeper.client.ZKClientConfig;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class ZkConfig {
+    /** ********* Zookeeper Configuration ***********/
+    public static final String ZK_CONNECT_PROP = "zookeeper.connect";
+    public static final String ZK_SESSION_TIMEOUT_MS_PROP = 
"zookeeper.session.timeout.ms";
+    public static final String ZK_CONNECTION_TIMEOUT_MS_PROP = 
"zookeeper.connection.timeout.ms";
+    public static final String ZK_ENABLE_SECURE_ACLS_PROP = 
"zookeeper.set.acl";
+    public static final String ZK_MAX_IN_FLIGHT_REQUESTS_PROP = 
"zookeeper.max.in.flight.requests";
+    public static final String ZK_SSL_CLIENT_ENABLE_PROP = 
"zookeeper.ssl.client.enable";
+    public static final String ZK_CLIENT_CNXN_SOCKET_PROP = 
"zookeeper.clientCnxnSocket";
+    public static final String ZK_SSL_KEY_STORE_LOCATION_PROP = 
"zookeeper.ssl.keystore.location";
+    public static final String ZK_SSL_KEY_STORE_PASSWORD_PROP = 
"zookeeper.ssl.keystore.password";
+    public static final String ZK_SSL_KEY_STORE_TYPE_PROP = 
"zookeeper.ssl.keystore.type";
+    public static final String ZK_SSL_TRUST_STORE_LOCATION_PROP = 
"zookeeper.ssl.truststore.location";
+    public static final String ZK_SSL_TRUST_STORE_PASSWORD_PROP = 
"zookeeper.ssl.truststore.password";
+    public static final String ZK_SSL_TRUST_STORE_TYPE_PROP = 
"zookeeper.ssl.truststore.type";
+    public static final String ZK_SSL_PROTOCOL_PROP = "zookeeper.ssl.protocol";
+    public static final String ZK_SSL_ENABLED_PROTOCOLS_PROP = 
"zookeeper.ssl.enabled.protocols";
+    public static final String ZK_SSL_CIPHER_SUITES_PROP = 
"zookeeper.ssl.cipher.suites";
+    public static final String ZK_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_PROP = 
"zookeeper.ssl.endpoint.identification.algorithm";
+    public static final String ZK_SSL_CRL_ENABLE_PROP = 
"zookeeper.ssl.crl.enable";
+    public static final String ZK_SSL_OCSP_ENABLE_PROP = 
"zookeeper.ssl.ocsp.enable";
+
+    // a map from the Kafka config to the corresponding ZooKeeper Java system 
property
+    public static final Map<String, String> 
ZK_SSL_CONFIG_TO_SYSTEM_PROPERTY_MAP;
+
+    public static final String ZK_CONNECT_DOC = "Specifies the ZooKeeper 
connection string in the form <code>hostname:port</code> where host and port 
are the " +
+            "host and port of a ZooKeeper server. To allow connecting through 
other ZooKeeper nodes when that ZooKeeper machine is " +
+            "down you can also specify multiple hosts in the form 
<code>hostname1:port1,hostname2:port2,hostname3:port3</code>.\n" +
+            "The server can also have a ZooKeeper chroot path as part of its 
ZooKeeper connection string which puts its data under some path in the global 
ZooKeeper namespace. " +
+            "For example to give a chroot path of <code>/chroot/path</code> 
you would give the connection string as 
<code>hostname1:port1,hostname2:port2,hostname3:port3/chroot/path</code>.";
+    public static final String ZK_SESSION_TIMEOUT_MS_DOC = "Zookeeper session 
timeout";
+    public static final String ZK_CONNECTION_TIMEOUT_MS_DOC = "The max time 
that the client waits to establish a connection to ZooKeeper. If not set, the 
value in " + ZK_SESSION_TIMEOUT_MS_PROP + " is used";
+    public static final String ZK_ENABLE_SECURE_ACLS_DOC = "Set client to use 
secure ACLs";
+    public static final String ZK_MAX_IN_FLIGHT_REQUESTS_DOC = "The maximum 
number of unacknowledged requests the client will send to ZooKeeper before 
blocking.";
+    public static final String ZK_SSL_CLIENT_ENABLE_DOC;
+    public static final String ZK_CLIENT_CNXN_SOCKET_DOC;
+    public static final String ZK_SSL_KEY_STORE_LOCATION_DOC;
+    public static final String ZK_SSL_KEY_STORE_PASSWORD_DOC;
+    public static final String ZK_SSL_KEY_STORE_TYPE_DOC;
+    public static final String ZK_SSL_TRUST_STORE_LOCATION_DOC;
+    public static final String ZK_SSL_TRUST_STORE_PASSWORD_DOC;
+    public static final String ZK_SSL_TRUST_STORE_TYPE_DOC;
+    public static final String ZK_SSL_PROTOCOL_DOC;
+    public static final String ZK_SSL_ENABLED_PROTOCOLS_DOC;
+    public static final String ZK_SSL_CIPHER_SUITES_DOC;
+    public static final String ZK_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_DOC;
+    public static final String ZK_SSL_CRL_ENABLE_DOC;
+    public static final String ZK_SSL_OCSP_ENABLE_DOC;
+
+    public static final int ZK_SESSION_TIMEOUT_MS = 18000;
+    public static final boolean ZK_ENABLE_SECURE_ACLS = false;
+    public static final int ZK_MAX_IN_FLIGHT_REQUESTS = 10;
+    public static final boolean ZK_SSL_CLIENT_ENABLE = false;
+    public static final String ZK_SSL_PROTOCOL = "TLSv1.2";
+    public static final String ZK_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM = 
"HTTPS";
+    public static final boolean ZK_SSL_CRL_ENABLE = false;
+    public static final boolean ZK_SSL_OCSP_ENABLE = false;
+
+    static {
+        Map<String, String> zkSslConfigToSystemPropertyMap = new HashMap<>();
+
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_CLIENT_ENABLE_PROP, 
ZKClientConfig.SECURE_CLIENT);
+        zkSslConfigToSystemPropertyMap.put(ZK_CLIENT_CNXN_SOCKET_PROP, 
ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET);
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_KEY_STORE_LOCATION_PROP, 
"zookeeper.ssl.keyStore.location");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_KEY_STORE_PASSWORD_PROP, 
"zookeeper.ssl.keyStore.password");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_KEY_STORE_TYPE_PROP, 
"zookeeper.ssl.keyStore.type");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_TRUST_STORE_LOCATION_PROP, 
"zookeeper.ssl.trustStore.location");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_TRUST_STORE_PASSWORD_PROP, 
"zookeeper.ssl.trustStore.password");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_TRUST_STORE_TYPE_PROP, 
"zookeeper.ssl.trustStore.type");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_PROTOCOL_PROP, 
"zookeeper.ssl.protocol");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_ENABLED_PROTOCOLS_PROP, 
"zookeeper.ssl.enabledProtocols");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_CIPHER_SUITES_PROP, 
"zookeeper.ssl.ciphersuites");
+        
zkSslConfigToSystemPropertyMap.put(ZK_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_PROP,
 "zookeeper.ssl.hostnameVerification");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_CRL_ENABLE_PROP, 
"zookeeper.ssl.crl");
+        zkSslConfigToSystemPropertyMap.put(ZK_SSL_OCSP_ENABLE_PROP, 
"zookeeper.ssl.ocsp");
+
+        ZK_SSL_CONFIG_TO_SYSTEM_PROPERTY_MAP = 
Collections.unmodifiableMap(zkSslConfigToSystemPropertyMap);
+
+        ZK_SSL_CLIENT_ENABLE_DOC = "Set client to use TLS when connecting to 
ZooKeeper." +

Review Comment:
   I reverted those changes and leave my first version.
   Because, java8 fails to load class if we use map values inside String 
constants definition.
   
   
https://ci-builds.apache.org/blue/organizations/jenkins/Kafka%2Fkafka-pr/detail/PR-15075/16/pipeline/9
 
   
   ```
   [2024-03-26T15:45:33.431Z] java.lang.StackOverflowError
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2296)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)
   [2024-03-26T15:45:33.431Z]   at 
com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
   ```



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to