List of usage examples for java.net InetSocketAddress getAddress
public final InetAddress getAddress()
From source file:org.eclipse.mylyn.commons.http.HttpUtil.java
private static void configureHttpClientProxy(AbstractHttpClient client, HttpContext context, AbstractWebLocation location) {/*from w ww.j a v a 2 s .c om*/ String host = getHost(location.getUrl()); Proxy proxy; if (isRepositoryHttps(location.getUrl())) { proxy = location.getProxyForHost(host, IProxyData.HTTPS_PROXY_TYPE); } else { proxy = location.getProxyForHost(host, IProxyData.HTTP_PROXY_TYPE); } if (proxy != null && !Proxy.NO_PROXY.equals(proxy)) { InetSocketAddress address = (InetSocketAddress) proxy.address(); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(address.getHostName(), address.getPort())); if (proxy instanceof AuthenticatedProxy) { AuthenticatedProxy authProxy = (AuthenticatedProxy) proxy; Credentials credentials = getCredentials(authProxy.getUserName(), authProxy.getPassword(), address.getAddress()); if (credentials instanceof NTCredentials) { List<String> authpref = new ArrayList<String>(); authpref.add(AuthPolicy.NTLM); authpref.add(AuthPolicy.BASIC); authpref.add(AuthPolicy.DIGEST); client.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref); } else { List<String> authpref = new ArrayList<String>(); authpref.add(AuthPolicy.BASIC); authpref.add(AuthPolicy.DIGEST); authpref.add(AuthPolicy.NTLM); client.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref); } AuthScope proxyAuthScope = new AuthScope(address.getHostName(), address.getPort(), AuthScope.ANY_REALM); client.getCredentialsProvider().setCredentials(proxyAuthScope, credentials); } } else { client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } }
From source file:com.mastfrog.scamper.Address.java
public Address(InetSocketAddress a) { this(a.getAddress().getHostAddress(), a.getPort()); }
From source file:me.haohui.libhdfspp.NativeRpcEngine.java
void connect(InetSocketAddress addr) throws IOException { byte[] status = connect(handle, addr.getAddress().getHostAddress(), addr.getPort()); NativeStatus stat = new NativeStatus(status); stat.checkForIOException();//from w w w .j av a 2 s . co m }
From source file:asia.stampy.common.gateway.HostPort.java
/** * Instantiates a new host port.// w w w . j a va 2 s .c o m * * @param address * the address */ public HostPort(InetSocketAddress address) { this.host = address.getAddress().getHostAddress(); this.port = address.getPort(); }
From source file:org.bgp4j.config.nodes.impl.ClientConfigurationImpl.java
public ClientConfigurationImpl(InetSocketAddress remoteAddress) throws ConfigurationException { if (remoteAddress.getAddress().isAnyLocalAddress()) throw new ConfigurationException("wildcard remote address not allowed"); this.remoteAddress = remoteAddress; }
From source file:edu.umass.cs.gigapaxos.PaxosConfig.java
/** * @param servers// w ww.ja v a 2s . co m * @param globalInt * @return Socket addresses with the port offset added to each element. */ public static Set<InetSocketAddress> offsetSocketAddresses(Set<InetSocketAddress> servers, int globalInt) { Set<InetSocketAddress> offsetted = new HashSet<InetSocketAddress>(); for (InetSocketAddress isa : servers) { offsetted.add(new InetSocketAddress(isa.getAddress(), isa.getPort() + globalInt)); } return offsetted; }
From source file:io.netlibs.bgp.config.nodes.impl.ClientConfigurationImpl.java
public ClientConfigurationImpl(final InetSocketAddress remoteAddress) throws ConfigurationException { if (remoteAddress.getAddress().isAnyLocalAddress()) { throw new ConfigurationException("wildcard remote address not allowed"); }//from w ww . java 2 s . c o m this.remoteAddress = remoteAddress; }
From source file:org.waveprotocol.box.server.rpc.ServerRpcProvider.java
private static InetSocketAddress[] parseAddressList(List<String> addressList, String websocketAddress) { if (addressList == null || addressList.size() == 0) { return new InetSocketAddress[0]; } else {/* w w w . j av a 2 s.co m*/ Set<InetSocketAddress> addresses = Sets.newHashSet(); // We add the websocketAddress as another listening address. ArrayList<String> mergedAddressList = new ArrayList<>(addressList); if (!StringUtils.isEmpty(websocketAddress)) { mergedAddressList.add(websocketAddress); } for (String str : mergedAddressList) { if (str.length() == 0) { LOG.warning("Encountered empty address in http addresses list."); } else { try { InetSocketAddress address = NetUtils.parseHttpAddress(str); if (!addresses.contains(address)) { addresses.add(address); } else { LOG.warning("Ignoring duplicate address in http addresses list: Duplicate entry '" + str + "' resolved to " + address.getAddress().getHostAddress()); } } catch (IOException e) { LOG.severe("Unable to process address " + str, e); } } } return addresses.toArray(new InetSocketAddress[addresses.size()]); } }
From source file:org.lilyproject.tools.printhost.PrintHostTool.java
@Override public int run(CommandLine cmd) throws Exception { int result = super.run(cmd); if (result != 0) { return result; }/*www . ja v a2 s . com*/ System.out.println("Below we print the detected host name and address."); System.out.println("These are used by Lily and Hadoop. For example, this is what is"); System.out.println("published in ZooKeeper so that other nodes or clients can"); System.out.println("connect to this node."); System.out.println(); System.out.println("If this shows localhost and 127.0.0.1, adjust your system setup."); System.out.println(); String nameserver = "default"; if (cmd.hasOption(nameserverOption.getOpt())) { nameserver = cmd.getOptionValue(nameserverOption.getOpt()); } System.out.println("Using nameserver: " + nameserver); String cn = InetAddress.getLocalHost().getCanonicalHostName(); System.out.println("Canonical host name: " + cn); InetSocketAddress ad = new InetSocketAddress(cn, 1234); System.out.println("Address of the canonical host name: " + ad.getAddress().getHostAddress()); System.out.println(); System.out.println("If you use the hostname \"" + cn + "\" in your ZooKeeper connection"); System.out.println("string, it is interesting to know that what ZooKeeper actually does"); System.out.println("is retrieving all IP addresses of all hosts listed in the ZK connection"); System.out.println("string, and then it picks one out of these to connect to."); System.out.println("These are all the IP-addresses coupled to " + cn + ":"); InetAddress addrs[] = InetAddress.getAllByName(cn); for (InetAddress addr : addrs) { System.out.println(" " + addr.getHostAddress()); } return 0; }
From source file:tajo.engine.cluster.WorkerListener.java
public WorkerListener(TajoConf conf, QueryManager qm, TajoMaster master) { String confMasterAddr = conf.getVar(ConfVars.MASTER_ADDRESS); InetSocketAddress initIsa = NetUtils.createSocketAddr(confMasterAddr); if (initIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + initIsa); }// w w w .jav a 2 s.c om this.rpcServer = NettyRpc.getProtoParamRpcServer(this, MasterWorkerProtocol.class, initIsa); this.qm = qm; this.stopped = false; this.rpcServer.start(); this.bindAddr = rpcServer.getBindAddress(); this.addr = bindAddr.getHostName() + ":" + bindAddr.getPort(); processed = new AtomicInteger(0); sleeper = new Sleeper(); this.master = master; }