nicoloboschi commented on a change in pull request #11947:
URL: https://github.com/apache/pulsar/pull/11947#discussion_r704105273



##########
File path: 
pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZkBookieRackAffinityMapping.java
##########
@@ -123,18 +126,20 @@ private void updateRacksWithHost(BookiesRackConfiguration 
racks) {
         if (conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE) != null) {
             zkCache = (ZooKeeperCache) 
conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE);
         } else {
-            int zkTimeout;
-            String zkServers;
             if (conf instanceof ClientConfiguration) {
-                zkTimeout = ((ClientConfiguration) conf).getZkTimeout();
-                zkServers = ((ClientConfiguration) conf).getZkServers();
-                String zkLedgersRootPath = ((ClientConfiguration) 
conf).getZkLedgersRootPath();
+                int zkTimeout = ((ClientConfiguration) conf).getZkTimeout();
                 try {
-                    int zkLedgerRootIndex = zkLedgersRootPath.contains("/") ?
-                            zkLedgersRootPath.lastIndexOf("/") : 0;
-                    String zkChangeRoot = zkLedgersRootPath.substring(0, 
zkLedgerRootIndex);
-                    zkChangeRoot = zkChangeRoot.startsWith("/") ? zkChangeRoot 
: "/" + zkChangeRoot;
-                    ZooKeeper zkClient = 
ZooKeeperClient.newBuilder().connectString(zkServers + zkChangeRoot)
+                    final String metadataServiceUriStr = 
((ClientConfiguration) conf).getMetadataServiceUri();
+                    URI metadataServiceUri = URI.create(metadataServiceUriStr);
+                    String zkServers;
+                    String ledgersRootPath = metadataServiceUri.getPath();
+                    if (ZK_LEDGERS_DEFAULT_ROOT_PATH.equals(ledgersRootPath)) {
+                        zkServers = 
getZKServersFromServiceUri(metadataServiceUri);

Review comment:
       do we need to add /ledgers as uri path? 

##########
File path: 
pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZkBookieRackAffinityMapping.java
##########
@@ -56,6 +58,7 @@
 
     public static final String BOOKIE_INFO_ROOT_PATH = "/bookies";
     public static final String ZK_DATA_CACHE_BK_RACK_CONF_INSTANCE = 
"zk_data_cache_bk_rack_conf_instance";
+    public static final String ZK_LEDGERS_DEFAULT_ROOT_PATH = "/ledgers";

Review comment:
       private?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to