Example usage for java.net InetSocketAddress createUnresolved

List of usage examples for java.net InetSocketAddress createUnresolved

Introduction

In this page you can find the example usage for java.net InetSocketAddress createUnresolved.

Prototype

public static InetSocketAddress createUnresolved(String host, int port) 

Source Link

Document

Creates an unresolved socket address from a hostname and a port number.

Usage

From source file:de.vanita5.twittnuker.util.Utils.java

public static Proxy getProxy(final Context context) {
    if (context == null)
        return null;
    final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    final boolean enable_proxy = prefs.getBoolean(KEY_ENABLE_PROXY, false);
    if (!enable_proxy)
        return Proxy.NO_PROXY;
    final String proxyHost = prefs.getString(KEY_PROXY_HOST, null);
    final int proxyPort = ParseUtils.parseInt(prefs.getString(KEY_PROXY_PORT, "-1"));
    if (!isEmpty(proxyHost) && proxyPort >= 0 && proxyPort < 65535) {
        final SocketAddress addr = InetSocketAddress.createUnresolved(proxyHost, proxyPort);
        return new Proxy(Proxy.Type.HTTP, addr);
    }/*  ww  w  . j a  v a  2s .c  om*/
    return Proxy.NO_PROXY;
}

From source file:org.apache.hadoop.hbase.regionserver.HRegionServer.java

@Override
public void updateRegionFavoredNodesMapping(String encodedRegionName,
        List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName> favoredNodes) {
    InetSocketAddress[] addr = new InetSocketAddress[favoredNodes.size()];
    // Refer to the comment on the declaration of regionFavoredNodesMap on why
    // it is a map of region name to InetSocketAddress[]
    for (int i = 0; i < favoredNodes.size(); i++) {
        addr[i] = InetSocketAddress.createUnresolved(favoredNodes.get(i).getHostName(),
                favoredNodes.get(i).getPort());
    }//from www .  java2  s.  co  m
    regionFavoredNodesMap.put(encodedRegionName, addr);
}