Refine search
public String getClientAddress() { if (null == peer.clientAddr) { return ""; } return peer.clientAddr.getHostString() + ":" + peer.clientAddr.getPort(); }
public MysqlConnector(InetSocketAddress address, String username, String password){ String addr = address.getHostString(); int port = address.getPort(); this.address = new InetSocketAddress(addr, port); this.username = username; this.password = password; }
public String getElectionAddress() { return peer.electionAddr.getHostString() + ":" + peer.electionAddr.getPort(); }
public String getQuorumAddress() { return peer.addr.getHostString()+":"+peer.addr.getPort(); }
private static String generateSourceIdentity(final InetSocketAddress address) { return address.getHostString() + ':' + address.getPort(); }
@Override public String apply(final InetSocketAddress addr) { return addr.getHostString() + ":" + addr.getPort(); } }));
void setTargetBroker(InetSocketAddress targetBrokerAddress) { this.proxyToTargetBrokerAddress = String.format("%s:%d", targetBrokerAddress.getHostString(), targetBrokerAddress.getPort()); }
public static String formatInetAddr(InetSocketAddress addr) { InetAddress ia = addr.getAddress(); if (ia == null) { return String.format("%s:%s", addr.getHostString(), addr.getPort()); } if (ia instanceof Inet6Address) { return String.format("[%s]:%s", ia.getHostAddress(), addr.getPort()); } else { return String.format("%s:%s", ia.getHostAddress(), addr.getPort()); } } }
/** * Set the (new) value of the {@code Host} header. * <p>If the given {@linkplain InetSocketAddress#getPort() port} is {@code 0}, * the host header will only contain the * {@linkplain InetSocketAddress#getHostString() host name}. * @since 5.0 */ public void setHost(@Nullable InetSocketAddress host) { if (host != null) { String value = host.getHostString(); int port = host.getPort(); if (port != 0) { value = value + ":" + port; } set(HOST, value); } else { remove(HOST, null); } }
private String getKey(InetSocketAddress address) { InetAddress addr = address.getAddress(); // addr == null if the hostname can't be resolved return (addr == null ? address.getHostString() : addr.getHostAddress()) + ":" + address.getPort(); }
/** * Encodes an IP address and port to be included in URL. in particular, this method makes * sure that IPv6 addresses have the proper formatting to be included in URLs. * * @param address The socket address with the IP address and port. * @return The proper URL string encoded IP address and port. */ public static String socketAddressToUrlString(InetSocketAddress address) { if (address.isUnresolved()) { throw new IllegalArgumentException("Address cannot be resolved: " + address.getHostString()); } return ipAddressAndPortToUrlString(address.getAddress(), address.getPort()); }
public static String format( java.net.SocketAddress address ) { if ( address instanceof InetSocketAddress ) { InetSocketAddress inetSocketAddress = (InetSocketAddress) address; return format( inetSocketAddress.getHostString(), inetSocketAddress.getPort() ); } return address.toString(); }
public void register( String connectorKey, InetSocketAddress localAddress ) { HostnamePort hostnamePort = new HostnamePort( localAddress.getHostString(), localAddress.getPort() ); connectorsInfo.put( connectorKey, hostnamePort ); }
/** * Create a "bootstrap" cluster using the given list of host/ports * @param addresses The addresses * @return A cluster for these hosts/ports */ public static Cluster bootstrap(List<InetSocketAddress> addresses) { List<Node> nodes = new ArrayList<>(); int nodeId = -1; for (InetSocketAddress address : addresses) nodes.add(new Node(nodeId--, address.getHostString(), address.getPort())); return new Cluster(null, true, nodes, new ArrayList<>(0), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), null); }
static MetadataCache bootstrap(List<InetSocketAddress> addresses) { List<Node> nodes = new ArrayList<>(); int nodeId = -1; for (InetSocketAddress address : addresses) nodes.add(new Node(nodeId--, address.getHostString(), address.getPort())); return new MetadataCache(null, nodes, Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), null, Cluster.bootstrap(addresses)); }
private InetSocketAddress resolve(InetSocketAddress address) { try { String curHostString = address.getHostString(); List<InetAddress> resolvedAddresses = new ArrayList<>(Arrays.asList(this.resolver.getAllByName(curHostString))); if (resolvedAddresses.isEmpty()) { return address; } Collections.shuffle(resolvedAddresses); return new InetSocketAddress(resolvedAddresses.get(0), address.getPort()); } catch (UnknownHostException e) { LOG.error("Unable to resolve address: {}", address.toString(), e); return address; } }
@Override public Authority toAuthority() { return new MultiMasterAuthority(mAddresses.stream() .map(addr -> addr.getHostString() + ":" + addr.getPort()).collect(joining(","))); }
@Override public Authority toAuthority() { return new SingleMasterAuthority(mAddress.getHostString(), mAddress.getPort()); }
public static InetSocketAddress computeRemoteAddr(InetSocketAddress remoteAddr, InetSocketAddress osRemoteAddr) { if (osRemoteAddr != null) { if (PlatformDependent.javaVersion() >= 7) { try { // Only try to construct a new InetSocketAddress if we using java >= 7 as getHostString() does not // exists in earlier releases and so the retrieval of the hostname could block the EventLoop if a // reverse lookup would be needed. return new InetSocketAddress(InetAddress.getByAddress(remoteAddr.getHostString(), osRemoteAddr.getAddress().getAddress()), osRemoteAddr.getPort()); } catch (UnknownHostException ignore) { // Should never happen but fallback to osRemoteAddr anyway. } } return osRemoteAddr; } return remoteAddr; } }
/** {@inheritDoc} */ @Override public ClientProtocol create(InetSocketAddress addr, Configuration conf) throws IOException { if (FRAMEWORK_NAME.equals(conf.get(MRConfig.FRAMEWORK_NAME))) return createProtocol(addr.getHostString() + ":" + addr.getPort(), conf); return null; }