/** * Set the socket address for the <code>name</code> property as * a <code>host:port</code>. */ public void setSocketAddr(String name, InetSocketAddress addr) { set(name, NetUtils.getHostPortString(addr)); }
/** * Set the socket address for the <code>name</code> property as * a <code>host:port</code>. */ public void setSocketAddr(String name, InetSocketAddress addr) { set(name, NetUtils.getHostPortString(addr)); }
/** * Set the socket address for the <code>name</code> property as * a <code>host:port</code>. */ public void setSocketAddr(String name, InetSocketAddress addr) { set(name, NetUtils.getHostPortString(addr)); }
/** * Pass in a server, return a URL bound to localhost and its port * @param server server * @return a URL bonded to the base of the server * @throws MalformedURLException if the URL cannot be created. */ public static URL getServerURL(HttpServer server) throws MalformedURLException { assertNotNull("No server", server); return new URL("http://" + NetUtils.getHostPortString(server.getConnectorAddress(0))); }
@Test public void testXFrameHeaderSameOrigin() throws Exception { Configuration conf = new Configuration(); conf.set("hbase.http.filter.xframeoptions.mode", "SAMEORIGIN"); HttpServer myServer = new HttpServer.Builder().setName("test") .addEndpoint(new URI("http://localhost:0")) .setFindPort(true).setConf(conf).build(); myServer.setAttribute(HttpServer.CONF_CONTEXT_ATTRIBUTE, conf); myServer.addServlet("echo", "/echo", EchoServlet.class); myServer.start(); String serverURL = "http://" + NetUtils.getHostPortString(myServer.getConnectorAddress(0)); URL url = new URL(new URL(serverURL), "/echo?a=b&c=d"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); assertEquals("SAMEORIGIN", conn.getHeaderField("X-Frame-Options")); myServer.stop(); }
webAppBuild.invoke(WebApps.$for("jobhistory", HistoryClientService.class, this, "ws").with(conf).withHttpSpnegoKeytabKey(XLearningConfiguration.XLEARNING_WEBAPP_SPNEGO_KEYTAB_FILE_KEY).withHttpSpnegoPrincipalKey(XLearningConfiguration.XLEARNING_WEBAPP_SPNEGO_USER_NAME_KEY).at(NetUtils.getHostPortString(bindAddress)), webApp); HttpServer2 httpServer = webApp.httpServer(); WebAppContext webAppContext = httpServer.getWebAppContext(); .withHttpSpnegoPrincipalKey( XLearningConfiguration.XLEARNING_WEBAPP_SPNEGO_USER_NAME_KEY) .at(NetUtils.getHostPortString(bindAddress)).start(webApp); } catch (WebAppException e){ throw new WebAppException("Error starting http server", e);
+ NetUtils.getHostPortString(http.getConnectorAddress(0)); try { for(int i = 0; i < urls.length; i++) {
@Override // SecondaryNameNodeInfoMXBean public String getHostAndPort() { return NetUtils.getHostPortString(nameNodeAddr); }
String authority = NetUtils.getHostPortString(server .getConnectorAddress(0));
server.start(); baseUrl = new URL("https://" + NetUtils.getHostPortString(server.getConnectorAddress(0))); LOG.info("HTTP server started: " + baseUrl);
+ NetUtils.getHostPortString(myServer.getConnectorAddress(0)) + "/"; for (String servlet : new String[] { "conf", "logs", "stacks", "logLevel", "metrics" }) {
+ NetUtils.getHostPortString(http.getConnectorAddress(0)); try { for(int i = 0; i < filteredUrls.length; i++) {
myServer.setAttribute(HttpServer.CONF_CONTEXT_ATTRIBUTE, conf); myServer.start(); String serverURL = "http://" + NetUtils.getHostPortString(myServer.getConnectorAddress(0)) + "/"; for (String servlet : new String[] { "conf", "logs", "stacks", "logLevel", "metrics" }) {
+ NetUtils.getHostPortString(http.getConnectorAddress(0)); try { for(int i = 0; i < sequence.length; i++) {
@Override // NameNode protected void setRpcServerAddress(Configuration conf, InetSocketAddress addr) { conf.set(BN_ADDRESS_NAME_KEY, NetUtils.getHostPortString(addr)); }
/** * Modifies the configuration to contain the lifeline RPC address setting. * * @param conf configuration to modify * @param lifelineRPCAddress lifeline RPC address */ void setRpcLifelineServerAddress(Configuration conf, InetSocketAddress lifelineRPCAddress) { LOG.info("Setting lifeline RPC address {}", lifelineRPCAddress); conf.set(DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY, NetUtils.getHostPortString(lifelineRPCAddress)); }
/** * @return NameNode RPC address in "host:port" string form */ public String getNameNodeAddressHostPortString() { return NetUtils.getHostPortString(getNameNodeAddress()); }
/** * Modifies the configuration passed to contain the service rpc address setting */ protected void setRpcServiceServerAddress(Configuration conf, InetSocketAddress serviceRPCAddress) { setServiceAddress(conf, NetUtils.getHostPortString(serviceRPCAddress)); }
/** * Return the URI that locates the HTTP server. */ URI getServerURI() { // getHttpClientScheme() only returns https for HTTPS_ONLY policy. This // matches the behavior that the first connector is a HTTPS connector only // for HTTPS_ONLY policy. InetSocketAddress addr = httpServer.getConnectorAddress(0); return URI.create(DFSUtil.getHttpClientScheme(conf) + "://" + NetUtils.getHostPortString(addr)); }
NamenodeRegistration setRegistration() { nodeRegistration = new NamenodeRegistration( NetUtils.getHostPortString(getNameNodeAddress()), NetUtils.getHostPortString(getHttpAddress()), getFSImage().getStorage(), getRole()); return nodeRegistration; }