Skip to content

Commit

Permalink
Pulsar standalone does not read zk port form conf/standalone.conf (ap…
Browse files Browse the repository at this point in the history
…ache#3790)

### Motivation
Fixes apache#3788

### Modifications
Add codes make it read zk port from standalone.conf. And it follow the Priority: args > conf > default
  • Loading branch information
tal705 authored and sijie committed Mar 11, 2019
1 parent 5fe446e commit a48f1d1
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -71,8 +72,20 @@ public PulsarStandaloneStarter(String[] args) throws Exception {
}

// 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() {
Expand All @@ -96,6 +109,10 @@ public void run() {
});
}

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);
Expand Down

0 comments on commit a48f1d1

Please sign in to comment.