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
435218
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;
  }
509725
public HostPortList setStripedPassive()
        throws IOException,
               ServerException {
        Command cmd = new Command("SPAS",
                                  (controlChannel.isIPv6()) ? "2" : null);
        Reply reply = null;

        try {
            reply = controlChannel.execute(cmd);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(urce);
        } catch(FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        }

        this.gSession.serverMode = GridFTPSession.SERVER_EPAS;
        if (controlChannel.isIPv6()) {
            gSession.serverAddressList =
                HostPortList.parseIPv6Format(reply.getMessage());
            int size = gSession.serverAddressList.size();
            for (int i=0;i<size;i++) {
                HostPort6 hp = (HostPort6)gSession.serverAddressList.get(i);
                if (hp.getHost() == null) {
                    hp.setVersion(HostPort6.IPv6);
                    hp.setHost(controlChannel.getHost());
                }
            }
        } else {
            gSession.serverAddressList =
                HostPortList.parseIPv4Format(reply.getMessage());
        }
        return gSession.serverAddressList;
    }
1021402
public static String splitListByComma(List<String> hosts) {
        boolean firstHost = true;
        StringBuilder hostConnection = new StringBuilder();
        for (String host : hosts) {
            if (!firstHost) {
                hostConnection.append(",");
            }
            hostConnection.append(host.trim());
            firstHost = false;
        }
        return hostConnection.toString();
    }
865820
def get_cluster_info(host, port, ignore_cluster_errors=False):
    
    client = Telnet(host, int(port))
    client.write(b'version\n')
    res = client.read_until(b'\r\n').strip()
    version_list = res.split(b' ')
    if len(version_list) not in [2, 3] or version_list[0] != b'VERSION':
        raise WrongProtocolData('version', res)
    version = version_list[1]
    if StrictVersion(smart_text(version)) >= StrictVersion('1.4.14'):
        cmd = b'config get cluster\n'
    else:
        cmd = b'get AmazonElastiCache:cluster\n'
    client.write(cmd)
    regex_index, match_object, res = client.expect([
        re.compile(b'\n\r\nEND\r\n'),
        re.compile(b'ERROR\r\n')
    ])
    client.close()

    if res == b'ERROR\r\n' and ignore_cluster_errors:
        return {
            'version': version,
            'nodes': [
                '{0}:{1}'.format(smart_text(host),
                               smart_text(port))
            ]
        }

    ls = list(filter(None, re.compile(br'\r?\n').split(res)))
    if len(ls) != 4:
        raise WrongProtocolData(cmd, res)

    try:
        version = int(ls[1])
    except ValueError:
        raise WrongProtocolData(cmd, res)
    nodes = []
    try:
        for node in ls[2].split(b' '):
            host, ip, port = node.split(b'|')
            nodes.append('{0}:{1}'.format(smart_text(ip or host),
                                        smart_text(port)))
    except ValueError:
        raise WrongProtocolData(cmd, res)
    return {
        'version': version,
        'nodes': nodes
    }
291477
@Override
    public List<Host> getSeedHosts() {
        List<Host> hosts = new ArrayList<Host>();
        if (seeds != null) {
            for (String seed : seeds.split(",")) {
                seed = seed.trim();
                if (seed.length() > 0) {
                    hosts.add(new Host(seed, this.port));
                }
            }
        }
        return hosts;
    }
1168880
public static HostAndPort of(String host, int port) {

        LettuceAssert.isTrue(isValidPort(port), String.format("Port out of range: %s", port));

        HostAndPort parsedHost = parse(host);
        LettuceAssert.isTrue(!parsedHost.hasPort(), String.format("Host has a port: %s", host));
        return new HostAndPort(host, port);
    }
1126681
public final B host(String host, int port) {
        requireNonNull(host, "host");
        checkArgument(!host.startsWith("group:"), "host: %s (must not start with 'group:')", host);
        checkArgument(port >= 1 && port < 65536, "port: %s (expected: 1 .. 65535)", port);

        final InetSocketAddress addr = newEndpoint(host, port);
        checkState(selectedProfile == null, "profile() and host() cannot be used together.");
        hosts = ImmutableSet.<InetSocketAddress>builder().addAll(hosts).add(addr).build();
        return self();
    }
444526
function splitHostPort(hostport) {

   let host = hostport;
   let port = 80;
   const parts = hostport.split(':');
   if (parts.length > 1) {
      host = parts[0];
      port = parts[1];
   }

   return {'host': host, 'port': port};
}
40422
def collect_hosts(hosts, randomize=True):
    

    if isinstance(hosts, six.string_types):
        hosts = hosts.strip().split(',')

    result = []
    afi = socket.AF_INET
    for host_port in hosts:

        host, port, afi = get_ip_port_afi(host_port)

        if port < 0:
            port = DEFAULT_KAFKA_PORT

        result.append((host, port, afi))

    if randomize:
        shuffle(result)

    return result
864215
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 JstormYarnUtils.join(entries, ",", false);
  }
587868
public static ImmutableSortedSet<String> hosts(String option) {
        checkArgument(option != null, "option is null");
        if (option.trim().isEmpty()) {
            return ImmutableSortedSet.of(
                    HostAndPort.fromParts("", Constants.DEFAULT_INTERNAL_PORT).toString());
        }
        Splitter commaSplitter = Splitter.on(',').omitEmptyStrings().trimResults();
        ImmutableSortedSet.Builder<String> sbld = ImmutableSortedSet.naturalOrder();
        for (String h: commaSplitter.split(option)) {
            checkArgument(isValidCoordinatorSpec(h), "%s is not a valid host spec", h);
            sbld.add(HostAndPort.fromString(h).withDefaultPort(Constants.DEFAULT_INTERNAL_PORT).toString());
        }
        return sbld.build();
    }
874523
private static List<String> getServerAddrs() {
        List<String> result = ArbitrateConfigUtils.getServerAddrs();
        if (result == null || result.size() == 0) {
            result = Arrays.asList(cluster);
        }
        return result;
    }
202540
private static List<InetAddress> getMulticastAddresses() throws SocketException, UnknownHostException {
        List<InetAddress> addresses = NetworkUtil.getMulticastAddresses();
        if (addresses.size() == 0) {
            throw new UnknownHostException("Cannot find address of local host which can be used for sending discovery request");
        }
        return addresses;
    }
1150917
private static Tuple2<String, Integer> parseHostPort(String address) {
		String[] hostPort = address.split("@")[1].split(":");
		String host = hostPort[0];
		String port = hostPort[1].split("/")[0];
		return new Tuple2<>(host, Integer.valueOf(port));
	}
623263
@Override
	public LocatableInputSplit getNextInputSplit(String host, int taskId) {

		// for a null host, we return a remote split
		if (host == null) {
			synchronized (this.remoteSplitChooser) {
				synchronized (this.unassigned) {

					LocatableInputSplitWithCount split = this.remoteSplitChooser.getNextUnassignedMinLocalCountSplit(this.unassigned);

					if (split != null) {
						// got a split to assign. Double check that it hasn't been assigned before.
						if (this.unassigned.remove(split)) {
							if (LOG.isInfoEnabled()) {
								LOG.info("Assigning split to null host (random assignment).");
							}

							remoteAssignments++;
							return split.getSplit();
						} else {
							throw new IllegalStateException("Chosen InputSplit has already been assigned. This should not happen!");
						}
					} else {
						// all splits consumed
						if (LOG.isDebugEnabled()) {
							LOG.debug("No more unassigned input splits remaining.");
						}
						return null;
					}
				}
			}
		}

		host = host.toLowerCase(Locale.US);

		// for any non-null host, we take the list of non-null splits
		LocatableInputSplitChooser localSplits = this.localPerHost.get(host);

		// if we have no list for this host yet, create one
		if (localSplits == null) {
			localSplits = new LocatableInputSplitChooser();

			// lock the list, to be sure that others have to wait for that host's local list
			synchronized (localSplits) {
				LocatableInputSplitChooser prior = this.localPerHost.putIfAbsent(host, localSplits);

				// if someone else beat us in the case to create this list, then we do not populate this one, but
				// simply work with that other list
				if (prior == null) {
					// we are the first, we populate

					// first, copy the remaining splits to release the lock on the set early
					// because that is shared among threads
					LocatableInputSplitWithCount[] remaining;
					synchronized (this.unassigned) {
						remaining = this.unassigned.toArray(new LocatableInputSplitWithCount[this.unassigned.size()]);
					}

					for (LocatableInputSplitWithCount isw : remaining) {
						if (isLocal(host, isw.getSplit().getHostnames())) {
							// Split is local on host.
							// Increment local count
							isw.incrementLocalCount();
                            // and add to local split list
							localSplits.addInputSplit(isw);
						}
					}

				}
				else {
					// someone else was faster
					localSplits = prior;
				}
			}
		}


		// at this point, we have a list of local splits (possibly empty)
		// we need to make sure no one else operates in the current list (that protects against
		// list creation races) and that the unassigned set is consistent
		// NOTE: we need to obtain the locks in this order, strictly!!!
		synchronized (localSplits) {
			synchronized (this.unassigned) {

				LocatableInputSplitWithCount split = localSplits.getNextUnassignedMinLocalCountSplit(this.unassigned);

				if (split != null) {
					// found a valid split. Double check that it hasn't been assigned before.
					if (this.unassigned.remove(split)) {
						if (LOG.isInfoEnabled()) {
							LOG.info("Assigning local split to host " + host);
						}

						localAssignments++;
						return split.getSplit();
					} else {
						throw new IllegalStateException("Chosen InputSplit has already been assigned. This should not happen!");
					}
				}
			}
		}

		// we did not find a local split, return a remote split
		synchronized (this.remoteSplitChooser) {
			synchronized (this.unassigned) {
				LocatableInputSplitWithCount split = this.remoteSplitChooser.getNextUnassignedMinLocalCountSplit(this.unassigned);

				if (split != null) {
					// found a valid split. Double check that it hasn't been assigned yet.
					if (this.unassigned.remove(split)) {
						if (LOG.isInfoEnabled()) {
							LOG.info("Assigning remote split to host " + host);
						}

						remoteAssignments++;
						return split.getSplit();
					} else {
						throw new IllegalStateException("Chosen InputSplit has already been assigned. This should not happen!");
					}
				} else {
					// all splits consumed
					if (LOG.isDebugEnabled()) {
						LOG.debug("No more input splits remaining.");
					}
					return null;
				}
			}
		}
	}
843630
public List<String> getVhost(String address, String port) {
        if (null == address || null == port) {
            return null;
        }
        int portnum = Integer.parseInt(port);
        List<EndPointInfo> eps = EndPointMgrImpl.getRef().getEndPoints(address, portnum);
        List<String> rc = new ArrayList<String>(eps.size());
        for (EndPointInfo ep : eps) {
            rc.add(ep.getName());
        }
        return rc;
    }
341432
public int getPort() {
        String hostAndPort = hostAndPort();
        int indexOfMaohao = hostAndPort.indexOf(":");
        if (indexOfMaohao == -1) {
            return 3306;
        } else {
            return Integer.parseInt(hostAndPort.substring(indexOfMaohao + 1));
        }
    }