public List<HostPort> getGmondSendChannelsFromConf(String conf) { String cleanConf = removeEmptyLines(stripComments(conf)); List<String> blobs = findSendChannels(cleanConf); log.debug("Found {} channels", blobs.size()); List<HostPort> hosts = new ArrayList<HostPort>(); for (String blob : blobs) { Map<String,String> chanMap = mapifyChannelString(blob); log.debug("Parsed channel from config {}", chanMap); HostPort hp = makeHostPort(chanMap); if (hp != null) { hosts.add(hp); } else { log.warn("Failure to create HostPort from {}", blob); } } return hosts; }
public List<HostPort> getGmondSendChannelsFromConf(String conf) { String cleanConf = removeEmptyLines(stripComments(conf)); List<String> blobs = findSendChannels(cleanConf); log.debug("Found {} channels", blobs.size()); List<HostPort> hosts = new ArrayList<HostPort>(); for (String blob : blobs) { Map<String,String> chanMap = mapifyChannelString(blob); log.debug("Parsed channel from config {}", chanMap); HostPort hp = makeHostPort(chanMap); if (hp != null) { hosts.add(hp); } else { log.warn("Failure to create HostPort from {}", blob); } } return hosts; }
@Test public void stringMapIfy() throws Exception { String sc = " bind_hostname = no \n host = \"bar.local\"\n port = 8649\n ttl = 1"; Map<String,String> expt = ImmutableMap.of("bind_hostname", "no", "host", "bar.local", "port", "8649", "ttl", "1"); GmondConfigParser g = new GmondConfigParser(); Map<String, String> chan = g.mapifyChannelString(sc); assertEquals(expt, chan); }
@Test public void stringMapIfy() throws Exception { String sc = " bind_hostname = no \n host = \"bar.local\"\n port = 8649\n ttl = 1"; Map<String,String> expt = ImmutableMap.of("bind_hostname", "no", "host", "bar.local", "port", "8649", "ttl", "1"); GmondConfigParser g = new GmondConfigParser(); Map<String, String> chan = g.mapifyChannelString(sc); assertEquals(expt, chan); }