pkuwm commented on a change in pull request #855: Make ZkBaseDataAccessor 
realm-aware
URL: https://github.com/apache/helix/pull/855#discussion_r391327397
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/ZkBaseDataAccessor.java
 ##########
 @@ -102,28 +118,85 @@ public AccessResult() {
 
   private static Logger LOG = 
LoggerFactory.getLogger(ZkBaseDataAccessor.class);
 
-  private final HelixZkClient _zkClient;
-  // true if ZkBaseDataAccessor was instantiated with a HelixZkClient, false 
otherwise
+  private final RealmAwareZkClient _zkClient;
+  // true if ZkBaseDataAccessor was instantiated with a RealmAwareZkClient, 
false otherwise
   // This is used for close() to determine how ZkBaseDataAccessor should close 
the underlying
   // ZkClient
   private final boolean _usesExternalZkClient;
 
+  /**
+   * @deprecated it is recommended to use the builder constructor {@link 
Builder}
+   * instead to avoid having to manually create and maintain a 
RealmAwareZkClient
+   * outside of ZkBaseDataAccessor.
+   *
+   * @param zkClient A created RealmAwareZkClient
+   */
   @Deprecated
-  public ZkBaseDataAccessor(HelixZkClient zkClient) {
+  public ZkBaseDataAccessor(RealmAwareZkClient zkClient) {
     if (zkClient == null) {
       throw new NullPointerException("zkclient is null");
     }
     _zkClient = zkClient;
     _usesExternalZkClient = true;
   }
 
+  private ZkBaseDataAccessor(Builder builder) {
+    switch (builder.realmMode) {
+      case MULTI_REALM:
+        try {
+          if (builder.zkClientType == ZkClientType.DEDICATED) {
+            // Use a realm-aware dedicated zk client
+            _zkClient = DedicatedZkClientFactory.getInstance()
+                .buildZkClient(builder.realmAwareZkConnectionConfig,
+                    builder.realmAwareZkClientConfig);
+          } else if (builder.zkClientType == ZkClientType.SHARED) {
+            // Use a realm-aware shared zk client
+            _zkClient = SharedZkClientFactory.getInstance()
+                .buildZkClient(builder.realmAwareZkConnectionConfig,
+                    builder.realmAwareZkClientConfig);
+          } else {
 
 Review comment:
   @dasahcc This is a realm-aware shared ZkClient. Users could construct the 
client with the sharding key on multi-realm mode.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to