public static String buildConnectionString(String zkHosts, int port) { String zkPort = Integer.toString(port); // parse the hosts String[] hostlist = zkHosts.split(",", 0); String quorum = SliderUtils.join(hostlist, ":" + zkPort + ",", false); return quorum; }
/** * Build a quorum list, injecting a ":defaultPort" ref if needed on any entry without one * * @param hostAndPorts * @param defaultPort * @return */ public static String buildQuorum(List<HostAndPort> hostAndPorts, int defaultPort) { List<String> entries = new ArrayList<String>(hostAndPorts.size()); for (HostAndPort hostAndPort : hostAndPorts) { entries.add(buildQuorumEntry(hostAndPort, defaultPort)); } return SliderUtils.join(entries, ",", false); }