public HostAndPort getHttpBindAddress() { return httpBindAddress .requireBracketsForIPv6() .withDefaultPort(GRAYLOG_DEFAULT_PORT); }
private List<InetSocketAddress> parseServerIpAddresses(String dnsServerIps) { // Parse and prepare DNS server IP addresses for Netty. return StreamSupport // Split comma-separated sever IP:port combos. .stream(Splitter.on(",").trimResults().omitEmptyStrings().split(dnsServerIps).spliterator(), false) // Parse as HostAndPort objects (allows convenient handling of port provided after colon). .map(hostAndPort -> HostAndPort.fromString(hostAndPort).withDefaultPort(DnsClient.DEFAULT_DNS_PORT)) // Convert HostAndPort > InetSocketAddress as required by Netty. .map(hostAndPort -> new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort())) .collect(Collectors.toList()); }
/** * @param ipAddresses A comma-separated list of IP addresses * @return true if all comma-separated IP addresses are valid * "8.8.4.4, 8.8.8.8" returns true * "8.8.4.4, " returns true * "8.8.4.4" returns true * "8.8.4.4 8.8.8.8" returns false * "8.8.4.4, google.com" returns false */ public static boolean allIpAddressesValid(String ipAddresses) { if (!Strings.isNullOrEmpty(ipAddresses)) { return Lists.newArrayList(Splitter.on(",") .trimResults() .omitEmptyStrings() .split(ipAddresses)).stream() .map(hostAndPort -> HostAndPort.fromString(hostAndPort).withDefaultPort(DnsClient.DEFAULT_DNS_PORT)) .allMatch(hostAndPort -> isValidIpAddress(hostAndPort.getHost())); } return false; } }
/** * 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; }
private static Iterable<InetSocketAddress> getZkAddresses(URI uri) { String zkServers = getZKServersFromDLUri(uri); String[] zkServerList = StringUtils.split(zkServers, ','); ImmutableList.Builder<InetSocketAddress> builder = ImmutableList.builder(); for (String zkServer : zkServerList) { HostAndPort hostAndPort = HostAndPort.fromString(zkServer).withDefaultPort(2181); builder.add(InetSocketAddress.createUnresolved( hostAndPort.getHostText(), hostAndPort.getPort())); } return builder.build(); }
/** * Parse the authority part of a URI. The authority part may have one of the following formats: * <ul> * <li>{@code "group:<groupName>"} for a group endpoint</li> * <li>{@code "<host>:<port>"} for a host endpoint</li> * <li>{@code "<host>"} for a host endpoint with no port number specified</li> * </ul> * An IPv4 or IPv6 address can be specified in lieu of a host name, e.g. {@code "127.0.0.1:8080"} and * {@code "[::1]:8080"}. */ public static Endpoint parse(String authority) { requireNonNull(authority, "authority"); if (authority.startsWith("group:")) { return ofGroup(authority.substring(6)); } final HostAndPort parsed = HostAndPort.fromString(authority).withDefaultPort(0); return create(parsed.getHost(), parsed.getPort()); }
if (shard.getAuth().getUser() != null) { HostAndPort syncSource = HostAndPort.fromString(shard.getSyncSource().value().get(0)) .withDefaultPort(27017); ConfigUtils.parseMongopassFile(new MongoPasswordConfig() {
private static HostAndPort toHostAddress(String value) { return HostAndPort.fromString(value).withDefaultPort(KAFKA_DEFAULT_PORT); }
@Config("http.server.address") public HttpServerConfig setAddress(String address) { if (address == null) this.address = HostAndPort.fromParts(RAKAM_DEFAULT_HOST, RAKAM_DEFAULT_PORT); else this.address = HostAndPort.fromString(address).withDefaultPort(RAKAM_DEFAULT_PORT); return this; }
HostAndPort hp2 = null; try { hp2 = hp.withDefaultPort(defaultPort); assertFalse(badDefaultPort); } catch (IllegalArgumentException e) {
public MongoClientConfiguration(HostAndPort hostAndPort, SocketFactory socketFactory, boolean sslEnabled, boolean sslAllowInvalidHostnames, ImmutableList<MongoAuthenticationConfiguration> authenticationConfiguration) { super(); this.hostAndPort = hostAndPort.withDefaultPort(27017); this.socketFactory = socketFactory; this.sslEnabled = sslEnabled; this.sslAllowInvalidHostnames = sslAllowInvalidHostnames; this.authenticationConfigurations = authenticationConfiguration; }
public MongoClientConfiguration(HostAndPort hostAndPort, MongoClientConfigurationProperties properties) { super(); this.hostAndPort = hostAndPort.withDefaultPort(27017); this.properties = properties; }
static HostAndPort hostAndPort(String input, Integer defaultPort) { final HostAndPort result = HostAndPort.fromString(input); if (null != defaultPort) { result.withDefaultPort(defaultPort); } return result; }
public static HostAndPort readNameServerAddresses() { String nameServerAddress = properties.getProperty(Constants.NAME_SERVER_ADDRESS); if (StringUtils.isNotEmpty(nameServerAddress)) { return HostAndPort.fromString(nameServerAddress) .withDefaultPort(Constants.DEFAULT_NAME_SERVER_PORT); } return HostAndPort.fromParts(Constants.DEFAULT_DIAMOND_SERVER_NAME, Constants.DEFAULT_NAME_SERVER_PORT); }
private List<InetSocketAddress> parseServerIpAddresses(String dnsServerIps) { // Parse and prepare DNS server IP addresses for Netty. return StreamSupport // Split comma-separated sever IP:port combos. .stream(Splitter.on(",").trimResults().omitEmptyStrings().split(dnsServerIps).spliterator(), false) // Parse as HostAndPort objects (allows convenient handling of port provided after colon). .map(hostAndPort -> HostAndPort.fromString(hostAndPort).withDefaultPort(DnsClient.DEFAULT_DNS_PORT)) // Convert HostAndPort > InetSocketAddress as required by Netty. .map(hostAndPort -> new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort())) .collect(Collectors.toList()); }
private static Iterable<InetSocketAddress> getZkAddresses(URI uri) { String zkServers = getZKServersFromDLUri(uri); String[] zkServerList = StringUtils.split(zkServers, ','); ImmutableList.Builder<InetSocketAddress> builder = ImmutableList.builder(); for (String zkServer : zkServerList) { HostAndPort hostAndPort = HostAndPort.fromString(zkServer).withDefaultPort(2181); builder.add(InetSocketAddress.createUnresolved( hostAndPort.getHostText(), hostAndPort.getPort())); } return builder.build(); }
private static Iterable<InetSocketAddress> getZkAddresses(URI uri) { String zkServers = getZKServersFromDLUri(uri); String[] zkServerList = StringUtils.split(zkServers, ','); ImmutableList.Builder<InetSocketAddress> builder = ImmutableList.builder(); for (String zkServer : zkServerList) { HostAndPort hostAndPort = HostAndPort.fromString(zkServer).withDefaultPort(2181); builder.add(InetSocketAddress.createUnresolved( hostAndPort.getHostText(), hostAndPort.getPort())); } return builder.build(); }
@Override public HostAndPort convert(final String value) { try { return HostAndPort.fromString(value).withDefaultPort(DEFAULT_PORT); } catch (IllegalStateException ex) { throw new ParameterException(getErrorString(value, "host and port")); } } }
@Override public HostAndPort convert(final String value) { try { return HostAndPort.fromString(value).withDefaultPort(DEFAULT_PORT); } catch (IllegalStateException ex) { throw new ParameterException(getErrorString(value, "host and port")); } } }