Skip to content
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 @@ -115,6 +115,15 @@ private static class Arguments {
description = "The metadata service URI of the existing BookKeeper cluster that you want to use")
private String existingBkMetadataServiceUri;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This annotation is not really meaningful here by itself, can we add a comment?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which annotation? Do you mean @Deprecated?

// Hide and marked as deprecated this flag because we use the new name '--existing-bk-metadata-service-uri' to
// pass the service url. For compatibility of the command, we should keep both to avoid the exceptions.
@Deprecated
@Parameter(names = {
"--bookkeeper-metadata-service-uri"},
description = "The metadata service URI of the existing BookKeeper cluster that you want to use",
hidden = true)
private String bookieMetadataServiceUri;

@Parameter(names = { "-h", "--help" }, description = "Show this help message")
private boolean help = false;
}
Expand Down Expand Up @@ -178,19 +187,23 @@ public static void main(String[] args) throws Exception {

// Format BookKeeper ledger storage metadata
ServerConfiguration bkConf = new ServerConfiguration();
if (arguments.existingBkMetadataServiceUri == null) {
if (arguments.existingBkMetadataServiceUri == null && arguments.bookieMetadataServiceUri == null) {
bkConf.setZkServers(arguments.zookeeper);
bkConf.setZkTimeout(arguments.zkSessionTimeoutMillis);
if (localZk.exists("/ledgers", false) == null // only format if /ledgers doesn't exist
&& !BookKeeperAdmin.format(bkConf, false /* interactive */, false /* force */)) {
&& !BookKeeperAdmin.format(bkConf, false /* interactive */, false /* force */)) {
throw new IOException("Failed to initialize BookKeeper metadata");
}
}

// Format BookKeeper stream storage metadata
if (arguments.numStreamStorageContainers > 0) {
String uriStr = arguments.existingBkMetadataServiceUri == null
? bkConf.getMetadataServiceUri() : arguments.existingBkMetadataServiceUri;
String uriStr = bkConf.getMetadataServiceUri();
if (arguments.existingBkMetadataServiceUri != null) {
uriStr = arguments.existingBkMetadataServiceUri;
} else if (arguments.bookieMetadataServiceUri != null) {
uriStr = arguments.bookieMetadataServiceUri;
}
ServiceURI bkMetadataServiceUri = ServiceURI.create(uriStr);
ClusterInitializer initializer = new ZkClusterInitializer(arguments.zookeeper);
initializer.initializeCluster(bkMetadataServiceUri.getUri(), arguments.numStreamStorageContainers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ public void testSetupWithBkMetadataServiceUri() throws Exception {
// expected not exist
assertNull(localZk.exists("/ledgers", false));

String[] bookkeeperMetadataServiceUriArgs = {
"--cluster", "testReSetupClusterMetadata-cluster",
"--zookeeper", zkConnection,
"--configuration-store", zkConnection,
"--bookkeeper-metadata-service-uri", "zk+null://" + zkConnection + "/chroot/ledgers",
"--web-service-url", "http://127.0.0.1:8080",
"--web-service-url-tls", "https://127.0.0.1:8443",
"--broker-service-url", "pulsar://127.0.0.1:6650",
"--broker-service-url-tls","pulsar+ssl://127.0.0.1:6651"
};

PulsarClusterMetadataSetup.main(bookkeeperMetadataServiceUriArgs);
ZooKeeper bookkeeperMetadataServiceUriZk = PulsarClusterMetadataSetup.initZk(zkConnection, 30000);
// expected not exist
assertNull(bookkeeperMetadataServiceUriZk.exists("/ledgers", false));

String[] args1 = {
"--cluster", "testReSetupClusterMetadata-cluster",
"--zookeeper", zkConnection,
Expand Down