[fix][broker] Fix unable to start multiple bookies for BKCluster
@@ -201,13 +201,17 @@ public class BKCluster implements AutoCloseable {
private ServerConfiguration newServerConfiguration(int index) throws Exception {
File dataDir;
if (clusterConf.dataDir != null) {
+ 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);
}
