List of usage examples for java.net InetSocketAddress getAddress
public final InetAddress getAddress()
From source file:org.apache.tajo.worker.TajoWorkerClientService.java
@Override public void serviceInit(Configuration conf) throws Exception { TajoConf tajoConf = TUtil.checkTypeAndGet(conf, TajoConf.class); this.serviceHandler = new TajoWorkerClientProtocolServiceHandler(); // init RPC Server in constructor cause Heartbeat Thread use bindAddr try {/* ww w .ja v a2s .com*/ InetSocketAddress initIsa = tajoConf.getSocketAddrVar(TajoConf.ConfVars.WORKER_CLIENT_RPC_ADDRESS); if (initIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + initIsa); } int workerNum = tajoConf.getIntVar(TajoConf.ConfVars.WORKER_SERVICE_RPC_SERVER_WORKER_THREAD_NUM); this.rpcServer = new BlockingRpcServer(QueryMasterClientProtocol.class, serviceHandler, initIsa, workerNum); this.rpcServer.start(); this.bindAddr = NetUtils.getConnectAddress(rpcServer.getListenAddress()); } catch (Exception e) { LOG.error(e.getMessage(), e); } // Get the master address LOG.info(TajoWorkerClientService.class.getSimpleName() + " is bind to " + bindAddr); tajoConf.setVar(TajoConf.ConfVars.WORKER_CLIENT_RPC_ADDRESS, NetUtils.getHostPortString(bindAddr)); super.serviceInit(tajoConf); }
From source file:com.ok2c.lightmtp.impl.protocol.ServiceReadyCodec.java
@Override public void reset(final IOSession iosession, final ServerState sessionState) throws IOException, SMTPProtocolException { this.writer.reset(); InetSocketAddress socketAddress = (InetSocketAddress) iosession.getRemoteAddress(); InetAddress clientAddress = socketAddress.getAddress(); if (this.addressValidator != null) { if (!this.addressValidator.validateAddress(clientAddress)) { sessionState.terminated();/*www. j a va 2 s . co m*/ iosession.close(); return; } } sessionState.setClientAddress(clientAddress); this.pendingReply = new SMTPReply(SMTPCodes.SERVICE_READY, null, sessionState.getServerId() + " service ready"); this.completed = false; iosession.setEventMask(SelectionKey.OP_WRITE); }
From source file:org.apache.tajo.master.TaskRunnerListener.java
public TaskRunnerListener(final QueryContext context) throws Exception { super(org.apache.tajo.master.cluster.WorkerListener.class.getName()); this.context = context; InetSocketAddress initIsa = new InetSocketAddress(InetAddress.getLocalHost(), 0); if (initIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + initIsa); }//from w w w . j ava 2 s . com try { this.rpcServer = new ProtoAsyncRpcServer(MasterWorkerProtocol.class, this, initIsa); } catch (Exception e) { LOG.error(e); } this.rpcServer.start(); this.bindAddr = rpcServer.getBindAddress(); this.addr = bindAddr.getHostName() + ":" + bindAddr.getPort(); }
From source file:org.scassandra.http.client.CurrentClient.java
public ConnectionReport getConnection(InetSocketAddress address) { return getConnection(address.getAddress().getHostAddress(), address.getPort()); }
From source file:org.hydracache.server.httpd.AsyncHttpLightServerTest.java
@Test public void testBuildInetAddressWithIp() { AsyncHttpLightServer server = new AsyncHttpLightServer(id, null, null, TEST_IP, TEST_PORT); InetSocketAddress address = server.buildInetSocketAddress(); assertFalse(address.isUnresolved()); assertFalse(address.getAddress().isAnyLocalAddress()); assertEquals(TEST_IP, address.getAddress().getHostAddress()); }
From source file:org.cosmo.common.service.SessionManager.java
public Session allocateNewSession(InetSocketAddress incomingAddress, StringTokens httpQueryString, HttpRequest httpRequest) {/* w w w.j a v a2 s. c om*/ byte[] ip = incomingAddress.getAddress().getAddress(); int port = incomingAddress.getPort(); Session session = SessionPool.Instance.getInstance(ip, port); session.setBrowserInfo(httpRequest.getHeader(HttpHeaders.Names.USER_AGENT)); return session; }
From source file:com.navercorp.pinpoint.collector.receiver.thrift.udp.SpanStreamUDPPacketHandlerFactory.java
private ServerRequest<TBase<?, ?>> newServerRequest(Message<TBase<?, ?>> message, InetSocketAddress remoteSocketAddress) { final String remoteAddress = remoteSocketAddress.getAddress().getHostAddress(); final int remotePort = remoteSocketAddress.getPort(); return new DefaultServerRequest<>(message, remoteAddress, remotePort); }
From source file:org.apache.tajo.master.TaskRunnerListener.java
@Override public void init(Configuration conf) { // Setup RPC server try {//from w w w. j av a 2s. c om InetSocketAddress initIsa = new InetSocketAddress(InetAddress.getLocalHost(), 0); if (initIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + initIsa); } this.rpcServer = new ProtoAsyncRpcServer(MasterWorkerProtocol.class, this, initIsa); this.rpcServer.start(); this.bindAddr = rpcServer.getBindAddress(); this.addr = bindAddr.getHostName() + ":" + bindAddr.getPort(); } catch (Exception e) { LOG.error(e); } // Get the master address LOG.info(org.apache.tajo.master.cluster.WorkerListener.class.getSimpleName() + " is bind to " + addr); context.getConf().setVar(TajoConf.ConfVars.TASKRUNNER_LISTENER_ADDRESS, addr); super.init(conf); }
From source file:org.openhealthtools.openatna.audit.server.UdpServer.java
private String logPacket(DatagramPacket packet) { String localAddress = udpConn.getServerSocket().getLocalAddress().getHostAddress(); int port = udpConn.getServerSocket().getLocalPort(); InetSocketAddress addr = (InetSocketAddress) packet.getSocketAddress(); return "UDP DatagramPacket received from:" + addr.getAddress().getHostAddress() + ":" + addr.getPort() + " to:" + localAddress + ":" + port; }
From source file:org.apache.tajo.worker.TajoWorkerManagerService.java
@Override public void serviceInit(Configuration conf) throws Exception { TajoConf tajoConf = TUtil.checkTypeAndGet(conf, TajoConf.class); try {// w w w .j a v a2s.c o m // Setup RPC server InetSocketAddress initIsa = tajoConf.getSocketAddrVar(TajoConf.ConfVars.WORKER_PEER_RPC_ADDRESS); if (initIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + initIsa); } int workerNum = tajoConf.getIntVar(TajoConf.ConfVars.WORKER_RPC_SERVER_WORKER_THREAD_NUM); this.rpcServer = new AsyncRpcServer(TajoWorkerProtocol.class, this, initIsa, workerNum); this.rpcServer.start(); this.bindAddr = NetUtils.getConnectAddress(rpcServer.getListenAddress()); } catch (Exception e) { LOG.error(e.getMessage(), e); } // Get the master address LOG.info("TajoWorkerManagerService is bind to " + bindAddr); tajoConf.setVar(TajoConf.ConfVars.WORKER_PEER_RPC_ADDRESS, NetUtils.getHostPortString(bindAddr)); super.serviceInit(tajoConf); }