You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by si...@apache.org on 2019/03/11 05:09:37 UTC
[pulsar] branch master updated: Pulsar standalone does not read zk
port form conf/standalone.conf (#3790)
This is an automated email from the ASF dual-hosted git repository.
sijie 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 a48f1d1 Pulsar standalone does not read zk port form conf/standalone.conf (#3790)
a48f1d1 is described below
commit a48f1d1cead4dc9c2683aee2f7536f809b610b94
Author: lsy180829 <42...@users.noreply.github.com>
AuthorDate: Mon Mar 11 13:09:32 2019 +0800
Pulsar standalone does not read zk port form conf/standalone.conf (#3790)
### Motivation
Fixes #3788
### Modifications
Add codes make it read zk port from standalone.conf. And it follow the Priority: args > conf > default
---
.../org/apache/pulsar/PulsarStandaloneStarter.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
index be645a6..c9aefa1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
@@ -21,6 +21,7 @@ package org.apache.pulsar;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.io.FileInputStream;
+import java.util.Arrays;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.ServiceConfigurationUtils;
@@ -71,8 +72,20 @@ public class PulsarStandaloneStarter extends PulsarStandalone {
}
// Set ZK server's host to localhost
- config.setZookeeperServers(zkServers + ":" + this.getZkPort());
- config.setConfigurationStoreServers(zkServers + ":" + this.getZkPort());
+ // Priority: args > conf > default
+ if (argsContains(args,"--zookeeper-port")) {
+ config.setZookeeperServers(zkServers + ":" + this.getZkPort());
+ } else {
+ if (config.getZookeeperServers() != null) {
+ this.setZkPort(Integer.parseInt(config.getZookeeperServers().split(":")[1]));
+ }
+ config.setZookeeperServers(zkServers + ":" + this.getZkPort());
+ }
+
+ if (config.getConfigurationStoreServers() == null) {
+ config.setConfigurationStoreServers(zkServers + ":" + this.getZkPort());
+ }
+
config.setRunningStandalone(true);
Runtime.getRuntime().addShutdownHook(new Thread() {
@@ -96,6 +109,10 @@ public class PulsarStandaloneStarter extends PulsarStandalone {
});
}
+ private static boolean argsContains(String[] args, String arg) {
+ return Arrays.asList(args).contains(arg);
+ }
+
public static void main(String args[]) throws Exception {
// Start standalone
PulsarStandaloneStarter standalone = new PulsarStandaloneStarter(args);