Pulsar standalone does not read zk port form conf/standalone.conf
### Motivation
Fixes
### Modifications
Add codes make it read zk port from standalone.conf. And it follow the Priority: args > conf > default
@@ -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
+ // 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);
