You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2022/06/02 23:25:38 UTC

[GitHub] [helix] junkaixue commented on a diff in pull request #2137: [WIP]Add backward compatibility support for constructing ZKHelixManager

junkaixue commented on code in PR #2137:
URL: https://github.com/apache/helix/pull/2137#discussion_r888473784


##########
helix-core/src/test/java/org/apache/helix/manager/zk/TestHelixManagerFactory.java:
##########
@@ -0,0 +1,10 @@
+package org.apache.helix.manager.zk;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestHelixManagerFactory {
+  private static Logger LOG = LoggerFactory.getLogger(TestHelixManagerFactory.class);
+

Review Comment:
   Where are the test?



##########
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java:
##########
@@ -1560,30 +1560,47 @@ private RealmAwareZkClient resolveZkClient(HelixZkClientFactory zkClientFactory,
   }
 
   /**
-   * Check that not both zkAddress and ZkConnectionConfig are set.
-   * If zkAddress is not given and ZkConnectionConfig is given, check that ZkConnectionConfig has
-   * a ZK path sharding key set because HelixManager must work on single-realm mode.
+   * Check that one and only one among zkAddress, ZkConnectionConfig and RealmAwareZkConnectionConfig are set.
+   * If zkAddress is not given directly or through ZkConnectionConfig and RealmAwareZkConnectionConfig
+   * is given, check that RealmAwareZkConnectionConfig has a ZK path sharding key set because
+   * HelixManager must work on single-realm mode.
    * @param zkAddress
    * @param helixManagerProperty
    */
   private void validateZkConnectionSettings(String zkAddress,
       HelixManagerProperty helixManagerProperty) {
-    if (helixManagerProperty != null && helixManagerProperty.getZkConnectionConfig() != null) {
-      if (zkAddress != null) {
-        throw new HelixException(
-            "ZKHelixManager: cannot have both ZkAddress and ZkConnectionConfig set!");
-      }
+    boolean hasRealmAwareZkConnectionConfig = helixManagerProperty != null
+        && helixManagerProperty.getRealmAwareZkConnectionConfig() != null;
+    boolean hasZkConnectionConfig =
+        helixManagerProperty != null && helixManagerProperty.getZkConnectionConfig() != null;
+    if (Stream.of(zkAddress != null, hasRealmAwareZkConnectionConfig, hasZkConnectionConfig)
+        .filter(condition -> condition).count() != 1) {
+      throw new HelixException(
+          "ZKHelixManager: One and only one of ZkAddress, RealmAwareZkConnectionConfig and "
+              + "ZkConnectionConfig should be set!");
+    }
+
+    if (hasRealmAwareZkConnectionConfig) {
       RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
-          helixManagerProperty.getZkConnectionConfig();
+          helixManagerProperty.getRealmAwareZkConnectionConfig();
       if (connectionConfig.getZkRealmShardingKey() == null || connectionConfig
           .getZkRealmShardingKey().isEmpty()) {
         throw new HelixException(
             "ZKHelixManager::ZK path sharding key must be set for ZKHelixManager! ZKHelixManager "
                 + "is only available on single-realm mode.");
       }
       _realmAwareZkConnectionConfig = connectionConfig;
+    } else if (hasZkConnectionConfig) {

Review Comment:
   Can these two be coexist? Or it is either or relationship.



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org