public List<HostPort> getHostListAndStringList() { // some simple log valadatin' sinc we can't || the @NotNulls // make mini protected functions sans logging for Ganglia if (getHosts() == null && getHostsString() == null) { log.warn("No hosts specified as a list or delimited string"); return null; } if (getHosts() != null && getHostsString() != null) { log.warn("Did you really mean to have hosts as a list and delimited string?"); } ArrayList<HostPort> combinedHosts = new ArrayList<HostPort>(); if (getHosts() != null) { combinedHosts.addAll(getHosts()); } if (getHostsString() != null) { combinedHosts.addAll(parseHostString()); } return combinedHosts; }
this.resolvedPrefix = resolvePrefix(prefix);
public List<HostPort> parseHostString() { // Done manually to avoid a guava dep List<HostPort> hosts = new ArrayList<HostPort>(); String[] hostPairs = getHostsString().split(","); for (int i = 0; i < hostPairs.length; i++) { String[] pair = hostPairs[i].split(":"); hosts.add(new HostPort(pair[0], Integer.valueOf(pair[1]))); } return hosts; }
String resolvePrefix(String prefixTemplate) { Map<String, String> valueMap = new HashMap<String, String>(); if (localhost != null) { String hostname = localhost.getHostName(); valueMap.put(MACRO_HOST_NAME, sanitizeName(hostname)); if (!StringUtils.isEmpty(hostname)) { valueMap.put(MACRO_HOST_NAME_SHORT, sanitizeName(StringUtils.split(hostname, '.')[0])); } valueMap.put(MACRO_HOST_ADDRESS, sanitizeName(localhost.getHostAddress())); valueMap.put(MACRO_HOST_FQDN, sanitizeName(localhost.getCanonicalHostName())); } return StrSubstitutor.replace(prefixTemplate, valueMap); }
public List<HostPort> parseHostString() { // Done manually to avoid a guava dep List<HostPort> hosts = new ArrayList<HostPort>(); String[] hostPairs = getHostsString().split(","); for (int i = 0; i < hostPairs.length; i++) { String[] pair = hostPairs[i].split(":"); hosts.add(new HostPort(pair[0], Integer.valueOf(pair[1]))); } return hosts; }
String resolvePrefix(String prefixTemplate) { Map<String, String> valueMap = new HashMap<String, String>(); if (localhost != null) { String hostname = localhost.getHostName(); valueMap.put(MACRO_HOST_NAME, sanitizeName(hostname)); if (!StringUtils.isEmpty(hostname)) { valueMap.put(MACRO_HOST_NAME_SHORT, sanitizeName(StringUtils.split(hostname, '.')[0])); } valueMap.put(MACRO_HOST_ADDRESS, sanitizeName(localhost.getHostAddress())); valueMap.put(MACRO_HOST_FQDN, sanitizeName(localhost.getCanonicalHostName())); } return StrSubstitutor.replace(prefixTemplate, valueMap); }
public List<HostPort> getHostListAndStringList() { // some simple log valadatin' sinc we can't || the @NotNulls // make mini protected functions sans logging for Ganglia if (getHosts() == null && getHostsString() == null) { log.warn("No hosts specified as a list or delimited string"); return null; } if (getHosts() != null && getHostsString() != null) { log.warn("Did you really mean to have hosts as a list and delimited string?"); } ArrayList<HostPort> combinedHosts = new ArrayList<HostPort>(); if (getHosts() != null) { combinedHosts.addAll(getHosts()); } if (getHostsString() != null) { combinedHosts.addAll(parseHostString()); } return combinedHosts; }
this.resolvedPrefix = resolvePrefix(prefix);