List of usage examples for java.net InetSocketAddress getAddress
public final InetAddress getAddress()
From source file:org.commoncrawl.io.internal.NIOServerTCPSocket.java
public void open(InetSocketAddress address) throws IOException { if (_channel != null) { throw new IOException("Invalid State. Socket already bound"); }// w w w .j ava 2s.c o m LOG.info(this + " Binding to: " + address.getAddress().getHostAddress() + ":" + address.getPort()); _channel = ServerSocketChannel.open(); setListenerSocketOptions(_channel); _channel.socket().bind(address); }
From source file:org.apache.niolex.config.service.impl.ReplicaServiceImpl.java
public void tryConnectToOtherServer(InetSocketAddress addr) { /**//from w ww . ja va 2 s. c om * First of all, let's remove localhost from the list. */ if (IP_SET.contains(addr.getAddress()) && localPort == addr.getPort()) { return; } final PacketClient client = new PacketClient(); otherServers.put(addr.toString(), client); LOG.info("Want to connect to {}.", addr); client.setConnectTimeout(60000); client.setServerAddress(addr); ReConnectHandler handler = new ReConnectHandler(); handler.addHandler(CodeMap.GROUP_DIF, diffHandler); handler.addHandler(CodeMap.GROUP_ADD, addHandler); client.setPacketHandler(handler); // Do try connect in another thread. new Thread() { public void run() { initConnection(client); } }.start(); }
From source file:org.ros.internal.node.server.XmlRpcServer.java
/** * Construct a new server./* w w w . j av a 2 s .co m*/ * * @param bindAddress * the address to bind the server to * @param advertiseAddress * the address to be used for advertising the server * @param executorService * the threadpool for the server */ public XmlRpcServer(BindAddress bindAddress, AdvertiseAddress advertiseAddress, ScheduledExecutorService executorService) { InetSocketAddress address = bindAddress.toInetSocketAddress(); server = new NettyXmlRpcWebServer(address.getPort(), address.getAddress(), executorService, LOG); this.executorService = executorService; this.advertiseAddress = advertiseAddress; this.advertiseAddress.setPortCallable(new Callable<Integer>() { @Override public Integer call() throws Exception { return server.getPort(); } }); startLatch = new CountDownLatch(1); }
From source file:org.apache.hadoop.mapred.ExtJobTracker.java
/** * {@inheritDoc}/* www . j a v a2 s . com*/ * * @return the binding information */ @Override public List<BindingTuple> getBindingInformation() { List<BindingTuple> bindings = new ArrayList<BindingTuple>(); InetSocketAddress ipcAddress = interTrackerServer.getListenerAddress(); bindings.add(NodeUtils.toBindingTuple(MAPRED_JOB_TRACKER, "ipc", ipcAddress)); //try and work out the underlying bindings by going back to the configuration InetSocketAddress httpAddr = NodeUtils.resolveAddress(getConf(), MAPRED_JOB_TRACKER_HTTP_ADDRESS); InetSocketAddress realHttpAddr = new InetSocketAddress(httpAddr.getAddress(), getInfoPort()); bindings.add(NodeUtils.toBindingTuple(MAPRED_JOB_TRACKER_HTTP_ADDRESS, "http", realHttpAddr)); return bindings; }
From source file:eu.stratosphere.client.CliFrontendJobManagerConnectionTest.java
@Test public void testValidConfig() { try {/*from ww w .ja v a 2 s . co m*/ String[] arguments = {}; CommandLine line = new PosixParser().parse(CliFrontend.getJobManagerAddressOption(new Options()), arguments, false); TestingCliFrontend frontend = new TestingCliFrontend(CliFrontendTestUtils.getConfigDir()); InetSocketAddress address = frontend.getJobManagerAddress(line); assertNotNull(address); assertEquals(CliFrontendTestUtils.TEST_JOB_MANAGER_ADDRESS, address.getAddress().getHostAddress()); assertEquals(CliFrontendTestUtils.TEST_JOB_MANAGER_PORT, address.getPort()); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Program caused an exception: " + e.getMessage()); } }
From source file:org.hyperic.hq.plugin.netservices.NetServicesCollector.java
protected void netstat() { if (!this.enableNetstat) { return;//from w w w . j a v a2s .c o m } InetSocketAddress saddr = getSocketAddress(); byte[] address = saddr.getAddress().getAddress(); int port = saddr.getPort(); NetStat netstat; synchronized (sigar) { try { netstat = sigar.getNetStat(address, port); } catch (SigarException e) { return; } } setValue("InboundConnections", netstat.getTcpInboundTotal()); setValue("OutboundConnections", netstat.getTcpOutboundTotal()); setValue("AllInboundConnections", netstat.getAllInboundTotal()); setValue("AllOutboundConnections", netstat.getAllOutboundTotal()); int[] states = netstat.getTcpStates(); for (int i = 0; i < states.length; i++) { setValue("State" + NetConnection.getStateString(i), states[i]); } }
From source file:com.anrisoftware.sscontrol.parser.AppParser.java
private void parseAddress(List<InetSocketAddress> addresses, InetSocketAddressFormat format, int defaultPort, String s) throws ParseException { InetSocketAddress address = format.parse(s); if (address.getPort() == 0) { InetAddress host = address.getAddress(); addresses.add(new InetSocketAddress(host, defaultPort)); } else {// w w w .j a v a 2s .c o m addresses.add(address); } }
From source file:org.apache.hadoop.hdfs.qjournal.server.JournalNodeRpcServer.java
JournalNodeRpcServer(Configuration conf, JournalNode jn) throws IOException { this.jn = jn; Configuration confCopy = new Configuration(conf); // Ensure that nagling doesn't kick in, which could cause latency issues. confCopy.setBoolean("ipc.server.tcpnodelay", true); // reader threads will handle the RPC calls confCopy.setBoolean("ipc.direct.handling", true); // set the number of reader threads, should be at least the number of // served namenodes confCopy.setInt(Server.IPC_SERVER_RPC_READ_THREADS_KEY, confCopy.getInt( JournalConfigKeys.DFS_QJOURNAL_IPC_READER_KEY, JournalConfigKeys.DFS_QJOURNAL_IPC_READER_DEFAULT)); InetSocketAddress addr = getAddress(confCopy); this.server = RPC.getServer(this, addr.getAddress().getHostAddress(), addr.getPort(), HANDLER_COUNT, false, confCopy, false);//ww w . j a va 2 s.c o m this.conf = confCopy; }
From source file:org.apache.hadoop.hdfs.server.datanode.AvatarDataNode.java
/** * Returns the IP:port address of the avatar node *///from w ww.j a v a 2 s .c o m private static List<InetSocketAddress> getAvatarNodeAddresses(String suffix, Configuration conf, Collection<String> serviceIds) throws IOException { List<InetSocketAddress> namenodeAddresses = DFSUtil.getRPCAddresses(suffix, conf, serviceIds, FSConstants.DFS_NAMENODE_RPC_ADDRESS_KEY); List<InetSocketAddress> avatarnodeAddresses = new ArrayList<InetSocketAddress>(namenodeAddresses.size()); for (InetSocketAddress namenodeAddress : namenodeAddresses) { avatarnodeAddresses.add(new InetSocketAddress(namenodeAddress.getAddress(), conf.getInt("dfs.avatarnode.port", namenodeAddress.getPort() + 1))); } return avatarnodeAddresses; }
From source file:eu.stratosphere.client.CliFrontendJobManagerConnectionTest.java
@Test public void testYarnConfig() { try {//from www . ja v a 2s .c om String[] arguments = {}; CommandLine line = new PosixParser().parse(CliFrontend.getJobManagerAddressOption(new Options()), arguments, false); TestingCliFrontend frontend = new TestingCliFrontend(CliFrontendTestUtils.getConfigDirWithYarnFile()); InetSocketAddress address = frontend.getJobManagerAddress(line); assertNotNull(address); assertEquals(CliFrontendTestUtils.TEST_YARN_JOB_MANAGER_ADDRESS, address.getAddress().getHostAddress()); assertEquals(CliFrontendTestUtils.TEST_YARN_JOB_MANAGER_PORT, address.getPort()); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Program caused an exception: " + e.getMessage()); } }