This is an automated email from the ASF dual-hosted git repository.

technoboy pushed a commit to branch branch-2.11
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.11 by this push:
     new a251b0b000a [fix][broker] Fix unable to start multiple bookies for 
BKCluster (#18072)
a251b0b000a is described below

commit a251b0b000aae83c7a1fbc4bebc75236755757a1
Author: Cong Zhao <[email protected]>
AuthorDate: Thu Oct 20 10:24:41 2022 +0800

    [fix][broker] Fix unable to start multiple bookies for BKCluster (#18072)
---
 .../java/org/apache/pulsar/metadata/bookkeeper/BKCluster.java     | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/BKCluster.java
 
b/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/BKCluster.java
index 36b0be112e2..d7be00ab259 100644
--- 
a/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/BKCluster.java
+++ 
b/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/BKCluster.java
@@ -200,13 +200,17 @@ public class BKCluster implements AutoCloseable {
     private ServerConfiguration newServerConfiguration(int index) throws 
Exception {
         File dataDir;
         if (clusterConf.dataDir != null) {
-            dataDir = new File(clusterConf.dataDir);
+            if (index == 0) {
+                dataDir = new File(clusterConf.dataDir);
+            } else {
+                dataDir = new File(clusterConf.dataDir + "/" + index);
+            }
         } else {
             // Use temp dir and clean it up later
             dataDir = createTempDir("bookie",  "test-" + index);
         }
 
-        if (clusterConf.clearOldData) {
+        if (clusterConf.clearOldData && dataDir.exists()) {
             cleanDirectory(dataDir);
         }
 

Reply via email to