List of usage examples for java.net InetSocketAddress getPort
public final int getPort()
From source file:org.apache.hadoop.hdfsproxy.HdfsProxy.java
private void initialize(Configuration conf) throws IOException { sslAddr = getSslAddr(conf);//from www .j a v a 2s.co m String nn = conf.get("hdfsproxy.dfs.namenode.address"); if (nn == null) throw new IOException("HDFS NameNode address is not specified"); InetSocketAddress nnAddr = NetUtils.createSocketAddr(nn); LOG.info("HDFS NameNode is at: " + nnAddr.getHostName() + ":" + nnAddr.getPort()); Configuration sslConf = new Configuration(false); sslConf.addResource(conf.get("hdfsproxy.https.server.keystore.resource", "ssl-server.xml")); // unit testing sslConf.set("proxy.http.test.listener.addr", conf.get("proxy.http.test.listener.addr")); this.server = new ProxyHttpServer(sslAddr, sslConf); this.server.setAttribute("proxy.https.port", server.getPort()); this.server.setAttribute("name.node.address", nnAddr); this.server.setAttribute(JspHelper.CURRENT_CONF, new Configuration()); this.server.addGlobalFilter("ProxyFilter", ProxyFilter.class.getName(), null); this.server.addServlet("listPaths", "/listPaths/*", ProxyListPathsServlet.class); this.server.addServlet("data", "/data/*", ProxyFileDataServlet.class); this.server.addServlet("streamFile", "/streamFile/*", ProxyStreamFile.class); }
From source file:backup.datanode.DataNodeBackupServicePlugin.java
@Override public void start(Object service) { DataNode datanode = (DataNode) service; Configuration conf = getConf(); RPC.setProtocolEngine(conf, DataNodeBackupRPC.class, WritableRpcEngine.class); // This object is created here so that it's lifecycle follows the datanode try {/*w w w .j a v a 2s . com*/ backupProcessor = SingletonManager.getManager(DataNodeBackupProcessor.class).getInstance(datanode, () -> new DataNodeBackupProcessor(conf, datanode)); restoreProcessor = SingletonManager.getManager(DataNodeRestoreProcessor.class).getInstance(datanode, () -> new DataNodeRestoreProcessor(conf, datanode)); DataNodeBackupRPCImpl backupRPCImpl = new DataNodeBackupRPCImpl(backupProcessor, restoreProcessor); InetSocketAddress listenerAddress = datanode.ipcServer.getListenerAddress(); int ipcPort = listenerAddress.getPort(); String bindAddress = listenerAddress.getAddress().getHostAddress(); int port = conf.getInt(DFS_BACKUP_DATANODE_RPC_PORT_KEY, DFS_BACKUP_DATANODE_RPC_PORT_DEFAULT); if (port == 0) { port = ipcPort + 1; } server = new RPC.Builder(conf).setBindAddress(bindAddress).setPort(port).setInstance(backupRPCImpl) .setProtocol(DataNodeBackupRPC.class).build(); ServiceAuthorizationManager serviceAuthorizationManager = server.getServiceAuthorizationManager(); serviceAuthorizationManager.refresh(conf, new BackupPolicyProvider()); server.start(); LOG.info("DataNode Backup RPC listening on {}", port); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.apache.hadoop.mapred.tools.MRZKFailoverController.java
@Override protected byte[] targetToData(HAServiceTarget target) { InetSocketAddress addr = target.getAddress(); return ActiveNodeInfo.newBuilder().setHostname(addr.getHostName()).setPort(addr.getPort()) .setZkfcPort(target.getZKFCAddress().getPort()).setNameserviceId(localJTTarget.getLogicalName()) .setNamenodeId(localJTTarget.getJobTrackerId()).build().toByteArray(); }
From source file:org.siddhiesb.transport.http.conn.ClientConnFactory.java
private SSLContext getSSLContext(final IOSession iosession) { InetSocketAddress address = (InetSocketAddress) iosession.getRemoteAddress(); String host = address.getHostName() + ":" + address.getPort(); SSLContext customContext = null; if (sslByHostMap != null) { // See if there's a custom SSL profile configured for this server customContext = sslByHostMap.get(host); }/*from w ww . j ava2 s . c o m*/ if (customContext != null) { return customContext; } else { return ssl != null ? ssl.getContext() : null; } }
From source file:org.apache.hadoop.metrics2.sink.TSDBSink.java
public void init(SubsetConfiguration conf) { this.LOG.info("Initializing TSDBSink"); if (conf.getString("slave.host.name") != null) this.fqdn = conf.getString("slave.host.name"); else {//from ww w . j a v a 2 s .co m try { this.fqdn = DNS.getDefaultHost(conf.getString("dfs.datanode.dns.interface", "default"), conf.getString("dfs.datanode.dns.nameserver", "default")); } catch (UnknownHostException exception) { this.LOG.error(exception); } } this.TSDBServers = Servers.parse(conf.getString("servers"), 4242); try { InetSocketAddress address = (InetSocketAddress) this.TSDBServers.get(0); this.collector = new Socket(address.getHostName(), address.getPort()); this.TSDBEndPoint = new DataOutputStream(this.collector.getOutputStream()); } catch (IOException exception) { this.LOG.error(exception); } }
From source file:nl.esciencecenter.osmium.mac.MacITCase.java
public URI getServerURI() throws URISyntaxException { InetSocketAddress address = server.getServiceAddress(); return new URI("http", null, address.getHostString(), address.getPort(), "/status", null, null); }
From source file:org.apache.http.localserver.AbstractAsyncTest.java
public HttpHost startServer() throws Exception { this.server = this.serverBootstrap.create(); this.server.start(); final ListenerEndpoint endpoint = this.server.getEndpoint(); endpoint.waitFor();//from ww w. ja va2 s .c o m final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress(); return new HttpHost("localhost", address.getPort(), this.scheme.name()); }
From source file:common.NameNode.java
public static URI getUri(InetSocketAddress namenode) { int port = namenode.getPort(); String portString = port == DEFAULT_PORT ? "" : (":" + port); return URI.create(FSConstants.HDFS_URI_SCHEME + "://" + namenode.getHostName() + portString); }
From source file:org.apache.hadoop.hdfs.server.namenode.AvatarNodeNew.java
public static InetSocketAddress getLocalAddress(Configuration conf) { InetSocketAddress u = NameNode.getAddress(conf); int port = conf.getInt("dfs.avatarnode.port", u.getPort() + 1); return new InetSocketAddress(getHostIP.getLocalIP(), port); }
From source file:org.apache.hadoop.hdfs.server.namenode.AvatarNodeNew.java
/** * Returns the hostname:port for the AvatarNode. The default * port for the AvatarNode is one more than the port of the * underlying namenode.//w w w . j av a2 s . c o m */ public static InetSocketAddress getAddress(Configuration conf) { InetSocketAddress u = NameNode.getAddress(conf); int port = conf.getInt("dfs.avatarnode.port", u.getPort() + 1); return new InetSocketAddress(u.getHostName(), port); }