Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][cli] Fix Pulsar standalone "--wipe-data" #22885

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading