You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2022/08/03 03:01:52 UTC
[pulsar] branch master updated: [improve][broker] Support start multiple bookies for BKCluster (#16847)
This is an automated email from the ASF dual-hosted git repository.
technoboy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new d004cf44c77 [improve][broker] Support start multiple bookies for BKCluster (#16847)
d004cf44c77 is described below
commit d004cf44c7754c0584200fbce9a735dc222a0ee7
Author: Cong Zhao <zh...@apache.org>
AuthorDate: Wed Aug 3 11:01:45 2022 +0800
[improve][broker] Support start multiple bookies for BKCluster (#16847)
---
.../java/org/apache/pulsar/broker/EndToEndMetadataTest.java | 2 +-
.../org/apache/pulsar/metadata/bookkeeper/BKCluster.java | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/EndToEndMetadataTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/EndToEndMetadataTest.java
index 3ea3aa3d9fb..0090ea08b1e 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/EndToEndMetadataTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/EndToEndMetadataTest.java
@@ -60,7 +60,7 @@ public class EndToEndMetadataTest extends BaseMetadataStoreTest {
@Cleanup
EmbeddedPulsarCluster epc = EmbeddedPulsarCluster.builder()
.numBrokers(1)
- .numBookies(1)
+ .numBookies(2)
.metadataStoreUrl(urlSupplier.get())
.dataDir(tempDir.getAbsolutePath())
.clearOldData(true)
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 e902b34e881..36b0be112e2 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
@@ -172,7 +172,7 @@ public class BKCluster implements AutoCloseable {
// Create Bookie Servers (B1, B2, B3)
for (int i = 0; i < numBookies; i++) {
- startNewBookie();
+ startNewBookie(i);
}
}
@@ -197,13 +197,13 @@ public class BKCluster implements AutoCloseable {
}
}
- private ServerConfiguration newServerConfiguration() throws Exception {
+ private ServerConfiguration newServerConfiguration(int index) throws Exception {
File dataDir;
if (clusterConf.dataDir != null) {
dataDir = new File(clusterConf.dataDir);
} else {
// Use temp dir and clean it up later
- dataDir = createTempDir("bookie", "test");
+ dataDir = createTempDir("bookie", "test-" + index);
}
if (clusterConf.clearOldData) {
@@ -259,12 +259,12 @@ public class BKCluster implements AutoCloseable {
* Helper method to startup a new bookie server with the indicated port
* number. Also, starts the auto recovery process, if the
* isAutoRecoveryEnabled is set true.
- *
+ * @param index Bookie index
* @throws IOException
*/
- public int startNewBookie()
+ public int startNewBookie(int index)
throws Exception {
- ServerConfiguration conf = newServerConfiguration();
+ ServerConfiguration conf = newServerConfiguration(index);
bsConfs.add(conf);
log.info("Starting new bookie on port: {}", conf.getBookiePort());
LifecycleComponentStack server = startBookie(conf);