merlimat closed pull request #1588: Don't format bookkeeper if /ledgers exist
URL: https://github.com/apache/incubator-pulsar/pull/1588
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataSetup.java 
b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataSetup.java
index 720372e2f..31bbdb7d2 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataSetup.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataSetup.java
@@ -102,18 +102,19 @@ public static void main(String[] args) throws Exception {
         log.info("Setting up cluster {} with zk={} global-zk={}", 
arguments.cluster, arguments.zookeeper,
                 arguments.globalZookeeper);
 
+        ZooKeeperClientFactory zkfactory = new ZookeeperClientFactoryImpl();
+        ZooKeeper localZk = zkfactory.create(arguments.zookeeper, 
SessionType.ReadWrite, 30000).get();
+        ZooKeeper globalZk = zkfactory.create(arguments.globalZookeeper, 
SessionType.ReadWrite, 30000).get();
+
         // Format BookKeeper metadata
         ServerConfiguration bkConf = new ServerConfiguration();
         
bkConf.setLedgerManagerFactoryClass(HierarchicalLedgerManagerFactory.class);
         bkConf.setZkServers(arguments.zookeeper);
-        if (!BookKeeperAdmin.format(bkConf, false /* interactive */, false /* 
force */)) {
+        if (localZk.exists("/ledgers", false) == null // only format if 
/ledgers doesn't exist
+                && !BookKeeperAdmin.format(bkConf, false /* interactive */, 
false /* force */)) {
             throw new IOException("Failed to initialize BookKeeper metadata");
         }
 
-        ZooKeeperClientFactory zkfactory = new ZookeeperClientFactoryImpl();
-        ZooKeeper localZk = zkfactory.create(arguments.zookeeper, 
SessionType.ReadWrite, 30000).get();
-        ZooKeeper globalZk = zkfactory.create(arguments.globalZookeeper, 
SessionType.ReadWrite, 30000).get();
-
         localZk.create("/managed-ledgers", new byte[0], 
ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
         localZk.create("/namespace", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, 
CreateMode.PERSISTENT);
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to