/** * Take a quorum list and split it to (trimmed) pairs * * @param hostPortQuorumList list of form h1:port, h2:port2,... * @return a possibly empty list of values between commas. They may not be valid hostname:port * pairs */ public static List<String> splitToPairs(String hostPortQuorumList) { // split an address hot String[] strings = StringUtils.getStrings(hostPortQuorumList); int len = 0; if (strings != null) { len = strings.length; } List<String> tuples = new ArrayList<String>(len); if (strings != null) { for (String s : strings) { tuples.add(s.trim()); } } return tuples; }
/** * Split a quorum list into a list of hostnames and ports * * @param hostPortQuorumList split to a list of hosts and ports * @return a list of values */ public static List<HostAndPort> splitToHostsAndPorts(String hostPortQuorumList) { // split an address hot String[] strings = StringUtils.getStrings(hostPortQuorumList); int len = 0; if (strings != null) { len = strings.length; } List<HostAndPort> list = new ArrayList<HostAndPort>(len); if (strings != null) { for (String s : strings) { list.add(HostAndPort.fromString(s.trim()).withDefaultPort(DEFAULT_PORT)); } } return list; }
@Override protected void map(LongWritable key, Text value, Context ctx) throws IOException, InterruptedException { String[] cols = StringUtils.getStrings(value.toString()); ctx.write(new Text(cols[1]), ONE); }