List of usage examples for java.net InetSocketAddress getAddress
public final InetAddress getAddress()
From source file:org.apache.hadoop.mapred.ExtTaskTracker.java
/** * {@inheritDoc}/*from ww w . jav a 2 s. c o m*/ * * @return the binding information */ @Override public List<BindingTuple> getBindingInformation() { List<BindingTuple> bindings = new ArrayList<BindingTuple>(); //try and work out the underlying bindings by going back to the configuration InetSocketAddress httpAddr = NodeUtils.resolveAddress(getConf(), MAPRED_TASK_TRACKER_HTTP_ADDRESS); InetSocketAddress realHttpAddr = new InetSocketAddress(httpAddr.getAddress(), getWebPort()); InetSocketAddress jobTrackerIPCAddress = jobTrackAddr; bindings.add(NodeUtils.toBindingTuple(MAPRED_JOB_TRACKER, "ipc", jobTrackerIPCAddress)); bindings.add(NodeUtils.toBindingTuple(MAPRED_TASK_TRACKER_HTTP_ADDRESS, "http", realHttpAddr)); bindings.add(NodeUtils.toBindingTuple(MAPRED_TASK_TRACKER_REPORT_ADDRESS, "http", getTaskTrackerReportAddress())); return bindings; }
From source file:org.ros.internal.node.DefaultNodeTest.java
@Test public void testCreatePrivate() { Node node = nodeFactory.newNode(privateNodeConfiguration, false); InetSocketAddress nodeAddress = ((DefaultNode) node).getAddress(); assertTrue(nodeAddress.getPort() > 0); assertTrue(nodeAddress.getAddress().isLoopbackAddress()); node.shutdown();/* ww w .j av a 2 s. c o m*/ }
From source file:tajo.master.MockupWorker.java
protected void prepareServing() throws IOException { String hostname = DNS.getDefaultHost(conf.get("nta.master.dns.interface", "default"), conf.get("nta.master.dns.nameserver", "default")); int port = this.conf.getIntVar(TajoConf.ConfVars.LEAFSERVER_PORT); // Creation of a HSA will force a resolve. InetSocketAddress initialIsa = new InetSocketAddress(hostname, port); if (initialIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + this.isa); }/*ww w .j a va 2 s . c om*/ this.rpcServer = NettyRpc.getProtoParamRpcServer(this, AsyncWorkerProtocol.class, initialIsa); this.rpcServer.start(); this.isa = this.rpcServer.getBindAddress(); this.serverName = this.isa.getHostName() + ":" + this.isa.getPort(); this.zkClient = new ZkClient(this.conf); }
From source file:org.kde.kdeconnect.Backends.LanBackend.LanLink.java
public void injectNetworkPackage(NetworkPackage np) { if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_ENCRYPTED)) { try {//from w ww .j ava2 s.c o m np = np.decrypt(privateKey); } catch (Exception e) { e.printStackTrace(); Log.e("KDE/onPackageReceived", "Exception reading the key needed to decrypt the package"); } } if (np.hasPayloadTransferInfo()) { Socket socket = null; try { socket = new Socket(); int tcpPort = np.getPayloadTransferInfo().getInt("port"); InetSocketAddress address = (InetSocketAddress) session.getRemoteAddress(); socket.connect(new InetSocketAddress(address.getAddress(), tcpPort)); np.setPayload(socket.getInputStream(), np.getPayloadSize()); } catch (Exception e) { try { socket.close(); } catch (Exception ignored) { } e.printStackTrace(); Log.e("KDE/LanLink", "Exception connecting to payload remote socket"); } } packageReceived(np); }
From source file:org.sana.net.http.ssl.EasySSLSocketFactory.java
public Socket connectSocket(Socket arg0, InetSocketAddress arg1, InetSocketAddress arg2, HttpParams arg3) throws IOException, UnknownHostException, ConnectTimeoutException { return connectSocket(arg0, arg1.getHostName(), arg1.getPort(), arg2.getAddress(), arg2.getPort(), arg3); }
From source file:com.spotify.docker.client.UnixConnectionSocketFactory.java
@Override public Socket connectSocket(final int connectTimeout, final Socket socket, final HttpHost host, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpContext context) throws IOException { try {//from w w w . ja v a2 s. c o m socket.connect(new UnixSocketAddress(socketFile), connectTimeout); } catch (SocketTimeoutException e) { throw new ConnectTimeoutException(e, null, remoteAddress.getAddress()); } return socket; }
From source file:com.github.mrstampy.kitchensync.message.KiSyMessage.java
/** * The Constructor./* w ww. jav a2s. c om*/ * * @param originator * the originator of the message * @param types * the types applicable for this message */ public KiSyMessage(InetSocketAddress originator, KiSyMessageType... types) { this(originator.getAddress(), originator.getPort(), types); }
From source file:de.cubeisland.engine.core.webapi.HttpRequestHandler.java
@Override protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest message) throws Exception { InetSocketAddress inetSocketAddress = (InetSocketAddress) ctx.channel().remoteAddress(); this.log.info("{} connected...", inetSocketAddress.getAddress().getHostAddress()); if (!this.server.isAddressAccepted(inetSocketAddress.getAddress())) { this.log.info("Access denied!"); ctx.channel().close();/*from w ww . ja v a 2s. c om*/ } if (message.getDecoderResult().isFailure()) { this.error(ctx, UNKNOWN_ERROR); this.log.info(message.getDecoderResult().cause(), "The decoder failed on this request..."); return; } boolean authorized = this.server.isAuthorized(inetSocketAddress.getAddress()); QueryStringDecoder qsDecoder = new QueryStringDecoder(message.getUri(), this.UTF8, true, 100); final Parameters params = new Parameters(qsDecoder.parameters(), core.getCommandManager().getProviderManager()); User authUser = null; if (!authorized) { if (!core.getModuleManager().getServiceManager().isImplemented(Permission.class)) { this.error(ctx, AUTHENTICATION_FAILURE, new ApiRequestException("Authentication deactivated", 200)); return; } String user = params.get("user", String.class); String pass = params.get("pass", String.class); if (user == null || pass == null) { this.error(ctx, AUTHENTICATION_FAILURE, new ApiRequestException("Could not complete authentication", 200)); return; } User exactUser = core.getUserManager().findExactUser(user); if (exactUser == null || !exactUser.isPasswordSet() || !CubeEngine.getUserManager().checkPassword(exactUser, pass)) { this.error(ctx, AUTHENTICATION_FAILURE, new ApiRequestException("Could not complete authentication", 200)); return; } authUser = exactUser; } String path = qsDecoder.path().trim(); if (path.length() == 0 || "/".equals(path)) { this.error(ctx, ROUTE_NOT_FOUND); return; } path = normalizePath(path); // is this request intended to initialize a websockets connection? if (WEBSOCKET_ROUTE.equals(path)) { WebSocketRequestHandler handler; if (!(ctx.pipeline().last() instanceof WebSocketRequestHandler)) { handler = new WebSocketRequestHandler(core, server, objectMapper, authUser); ctx.pipeline().addLast("wsEncoder", new TextWebSocketFrameEncoder(objectMapper)); ctx.pipeline().addLast("handler", handler); } else { handler = (WebSocketRequestHandler) ctx.pipeline().last(); } this.log.info("received a websocket request..."); handler.doHandshake(ctx, message); return; } this.handleHttpRequest(ctx, message, path, params, authUser); }
From source file:org.apache.hadoop.hdfs.qjournal.server.JournalNodeJspHelper.java
/** * Fetch stats from a single given journal node over http. *///from ww w .j a v a 2s .c o m private String fetchStats(InetSocketAddress jn) throws IOException { try { return DFSUtil.getHTMLContentWithTimeout(new URI("http", null, jn.getAddress().getHostAddress(), jn.getPort(), "/journalStats", null, null).toURL(), HTTP_CONNECT_TIMEOUT, HTTP_READ_TIMEOUT); } catch (Exception e) { LOG.error("Problem connecting to " + getHostAddress(jn), e); return null; } }
From source file:org.apache.tajo.master.ha.HAServiceHDFSImpl.java
public HAServiceHDFSImpl(MasterContext context) throws IOException { this.context = context; this.conf = context.getConf(); initSystemDirectory();/*w ww . j a v a2 s . com*/ InetSocketAddress socketAddress = context.getTajoMasterService().getBindAddress(); this.masterName = socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort(); monitorInterval = conf.getIntVar(TajoConf.ConfVars.TAJO_MASTER_HA_MONITOR_INTERVAL); }