helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hu...@apache.org
Subject [helix] branch zooscalability updated: Instrument ConfigAccessor's constructors (#856)
Date Wed, 04 Mar 2020 20:24:42 GMT
This is an automated email from the ASF dual-hosted git repository.

hulee pushed a commit to branch zooscalability
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/zooscalability by this push:
     new 381c8d5  Instrument ConfigAccessor's constructors (#856)
381c8d5 is described below

commit 381c8d5de4a261f23a0211b596f26ff3903cd2ce
Author: Hunter Lee <hulee@linkedin.com>
AuthorDate: Wed Mar 4 12:24:34 2020 -0800

    Instrument ConfigAccessor's constructors (#856)
    
    This diff instruments ConfigAccessor's constructors to make it realm-aware. If ConfigAccessor
is unable to start on multi-realm mode, then it falls back to starting on single-realm mode.
---
 .../main/java/org/apache/helix/ConfigAccessor.java | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java b/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
index 51a2b95..7d969b6 100644
--- a/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
@@ -107,11 +107,11 @@ public class ConfigAccessor {
   /**
    * Initialize an accessor with a Zookeeper client
    * Note: it is recommended to use the other constructor instead to avoid having to create
a
-   * HelixZkClient.
+   * RealmAwareZkClient.
    * @param zkClient
    */
   @Deprecated
-  public ConfigAccessor(HelixZkClient zkClient) {
+  public ConfigAccessor(RealmAwareZkClient zkClient) {
     _zkClient = zkClient;
     _usesExternalZkClient = true;
   }
@@ -123,9 +123,22 @@ public class ConfigAccessor {
    * @param zkAddress
    */
   public ConfigAccessor(String zkAddress) {
-    _zkClient = SharedZkClientFactory.getInstance()
-        .buildZkClient(new HelixZkClient.ZkConnectionConfig(zkAddress),
-            new HelixZkClient.ZkClientConfig().setZkSerializer(new ZNRecordSerializer()));
+    // First, attempt to connect on multi-realm mode using FederatedZkClient
+    RealmAwareZkClient zkClient;
+    try {
+      zkClient = new FederatedZkClient(
+          new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder().build(),
+          new RealmAwareZkClient.RealmAwareZkClientConfig());
+    } catch (IOException | InvalidRoutingDataException | IllegalStateException e) {
+      // Connecting multi-realm failed - fall back to creating it on single-realm mode using
the given ZK address
+      LOG.info(
+          "ConfigAccessor: not able to connect on multi-realm mode; connecting single-realm
mode to ZK: {}",
+          zkAddress, e);
+      zkClient = SharedZkClientFactory.getInstance()
+          .buildZkClient(new HelixZkClient.ZkConnectionConfig(zkAddress),
+              new HelixZkClient.ZkClientConfig().setZkSerializer(new ZNRecordSerializer()));
+    }
+    _zkClient = zkClient;
     _usesExternalZkClient = false;
   }
 


Mime
View raw message