Skip to content

Commit

Permalink
[fix][cli] Fix Pulsar standalone "--wipe-data" (#22885)
Browse files Browse the repository at this point in the history
(cherry picked from commit f6eceed)
  • Loading branch information
lhotari committed Jun 10, 2024
1 parent 278a968 commit 4bc4171
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
*/
package org.apache.pulsar;

import static org.apache.commons.io.FileUtils.cleanDirectory;
import static org.apache.pulsar.common.naming.NamespaceName.SYSTEM_NAMESPACE;
import static org.apache.pulsar.common.naming.SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Sets;
import io.netty.util.internal.PlatformDependent;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
Expand Down Expand Up @@ -446,7 +448,12 @@ public void close() {
void startBookieWithMetadataStore() throws Exception {
if (StringUtils.isBlank(metadataStoreUrl)){
log.info("Starting BK with RocksDb metadata store");
metadataStoreUrl = "rocksdb://" + Paths.get(metadataDir).toAbsolutePath();
Path metadataDirPath = Paths.get(metadataDir);
metadataStoreUrl = "rocksdb://" + metadataDirPath.toAbsolutePath();
if (wipeData && Files.exists(metadataDirPath)) {
log.info("Wiping RocksDb metadata store at {}", metadataStoreUrl);
cleanDirectory(metadataDirPath.toFile());
}
} else {
log.info("Starting BK with metadata store: {}", metadataStoreUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ private void runZookeeper(int maxCC) throws IOException {
: createTempDirectory("zktest");

if (this.clearOldData) {
LOG.info("Wiping Zookeeper data directory at {}", zkDataDir.getAbsolutePath());
cleanDirectory(zkDataDir);
}

Expand Down Expand Up @@ -291,6 +292,7 @@ private void runBookies(ServerConfiguration baseConf) throws Exception {
: createTempDirectory("bk" + i + "test");

if (this.clearOldData) {
LOG.info("Wiping Bookie data directory at {}", bkDataDir.getAbsolutePath());
cleanDirectory(bkDataDir);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ private ServerConfiguration newServerConfiguration(int index) throws Exception {
}

if (clusterConf.clearOldData && dataDir.exists()) {
log.info("Wiping Bookie data directory at {}", dataDir.getAbsolutePath());
cleanDirectory(dataDir);
}

Expand Down

0 comments on commit 4bc4171

Please sign in to comment.