helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hu...@apache.org
Subject [helix] 41/43: Update listClusters() in ZkHelixAdmin (#895)
Date Tue, 17 Mar 2020 00:04:12 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

commit 054e107e9d8d3095980cf684048d838ed71ce647
Author: Hunter Lee <hulee@linkedin.com>
AuthorDate: Fri Mar 13 17:28:01 2020 -0700

    Update listClusters() in ZkHelixAdmin (#895)
    
    This PR updates getClusters() in ZkHelixAdmin in realm-aware mode. It is difficult to
reason about getting all clusters - and this method, on single-realm mode, is also broken
anyways because in the case users create nested clusters, this method will end up returning
nothing. This update is backward-compatible for single-realm users.
    
    Ideally, users should use Metadata Store Directory Service to get the list of all clusters.
---
 .../main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
index ea9b55a..5804dd9 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
@@ -954,6 +954,12 @@ public class ZKHelixAdmin implements HelixAdmin {
 
   @Override
   public List<String> getClusters() {
+    if (Boolean.getBoolean(SystemPropertyKeys.MULTI_ZK_ENABLED)
+        || _zkClient instanceof FederatedZkClient) {
+      throw new UnsupportedOperationException(
+          "getClusters() is not supported in multi-realm mode! Use Metadata Store Directory
Service instead!");
+    }
+
     List<String> zkToplevelPathes = _zkClient.getChildren("/");
     List<String> result = new ArrayList<String>();
     for (String pathName : zkToplevelPathes) {
@@ -1925,7 +1931,10 @@ public class ZKHelixAdmin implements HelixAdmin {
 
       // Resolve RealmAwareZkClientConfig
       if (realmAwareZkClientConfig == null) {
-        realmAwareZkClientConfig = new RealmAwareZkClient.RealmAwareZkClientConfig();
+        // ZkHelixAdmin should have ZNRecordSerializer set by default
+        realmAwareZkClientConfig = new RealmAwareZkClient.RealmAwareZkClientConfig()
+            .setZkSerializer(
+                new org.apache.helix.zookeeper.datamodel.serializer.ZNRecordSerializer());
       }
 
       // Resolve RealmAwareZkConnectionConfig


Mime
View raw message