You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/08 07:44:32 UTC

[GitHub] [pulsar] gaozhangmin commented on a change in pull request #11947: fix-npe-ZkBookieRackAffinityMapping

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



##########
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:
       from the previous logic, it was no.




-- 
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: commits-unsubscribe@pulsar.apache.org

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