/** * @return NameNode RPC address in "host:port" string form */ public String getNameNodeAddressHostPortString() { return NetUtils.getHostPortString(getNameNodeAddress()); }
/** * @return NameNode service RPC address if configured, the * NameNode RPC address otherwise */ public InetSocketAddress getServiceRpcAddress() { final InetSocketAddress serviceAddr = rpcServer.getServiceRpcAddress(); return serviceAddr == null ? getNameNodeAddress() : serviceAddr; }
/** A utility method for creating credentials. */ public static Credentials createCredentials(final NameNode namenode, final UserGroupInformation ugi, final String renewer) throws IOException { final Token<DelegationTokenIdentifier> token = namenode.getRpcServer( ).getDelegationToken(new Text(renewer)); if (token == null) { return null; } final InetSocketAddress addr = namenode.getNameNodeAddress(); SecurityUtil.setTokenService(token, addr); final Credentials c = new Credentials(); c.addToken(new Text(ugi.getShortUserName()), token); return c; }
if (NamenodeRole.NAMENODE != role) { startHttpServer(conf); httpServer.setNameNodeAddress(getNameNodeAddress()); httpServer.setFSImage(getFSImage()); LOG.info(getRole() + " RPC up at: " + getNameNodeAddress()); if (rpcServer.getServiceRpcAddress() != null) { LOG.info(getRole() + " service RPC up at: "
NamenodeRegistration setRegistration() { nodeRegistration = new NamenodeRegistration( NetUtils.getHostPortString(getNameNodeAddress()), NetUtils.getHostPortString(getHttpAddress()), getFSImage().getStorage(), getRole()); return nodeRegistration; }
NetUtils.getHostPortString(getNameNodeAddress()); LOG.info("Clients are to use " + clientNamenodeAddress + " to access" + " this namenode/service."); httpServer.setNameNodeAddress(getNameNodeAddress()); httpServer.setFSImage(getFSImage());
/** * Gets the rpc port used by the NameNode, because the caller * supplied port is not necessarily the actual port used. */ public int getNameNodePort() { return nameNode.getNameNodeAddress().getPort(); }
public String getNamenode() { return "hdfs://" + miniDFSCluster.getNameNode().getNameNodeAddress().getHostName() + ":" + miniDFSCluster.getNameNode().getNameNodeAddress().getPort(); }
static void checkPath(MiniDFSCluster cluster, FileSystem fileSys) throws IOException { InetSocketAddress add = cluster.getNameNode().getNameNodeAddress(); // Test upper/lower case fileSys.checkPath(new Path("hdfs://" + add.getHostName().toUpperCase() + ":" + add.getPort())); }
/** * Gets the rpc port used by the NameNode at the given index, because the * caller supplied port is not necessarily the actual port used. */ public int getNameNodePort(int nnIndex) { return nameNodes[nnIndex].nameNode.getNameNodeAddress().getPort(); }
/** * Create a {@link NameNode} proxy from the current {@link ServletContext}. */ protected ClientProtocol createNameNodeProxy(UnixUserGroupInformation ugi ) throws IOException { ServletContext context = getServletContext(); NameNode nn = (NameNode)context.getAttribute("name.node"); Configuration conf = new Configuration( (Configuration)context.getAttribute("name.conf")); UnixUserGroupInformation.saveToConf(conf, UnixUserGroupInformation.UGI_PROPERTY_NAME, ugi); return DFSClient.createNamenode(nn.getNameNodeAddress(), conf); }
/** A utility method for creating credentials. */ public static Credentials createCredentials(final NameNode namenode, final UserGroupInformation ugi, final String renewer) throws IOException { final Token<DelegationTokenIdentifier> token = namenode.getRpcServer( ).getDelegationToken(new Text(renewer)); if (token == null) { return null; } final InetSocketAddress addr = namenode.getNameNodeAddress(); SecurityUtil.setTokenService(token, addr); final Credentials c = new Credentials(); c.addToken(new Text(ugi.getShortUserName()), token); return c; }
/** Create a URI for redirecting request to a datanode */ protected URI createRedirectUri(String servletpath, UserGroupInformation ugi, DatanodeID host, HttpServletRequest request, NameNode nn) throws URISyntaxException { final String hostname = host instanceof DatanodeInfo? ((DatanodeInfo)host).getHostName(): host.getHost(); final String scheme = request.getScheme(); final int port = "https".equals(scheme)? (Integer)getServletContext().getAttribute("datanode.https.port") : host.getInfoPort(); // Add namenode address to the URL params final String nnAddr = NameNode.getHostPortString(nn.getNameNodeAddress()); final String filename = request.getPathInfo(); return new URI(scheme, null, hostname, port, servletpath, "filename=" + filename + "&ugi=" + ugi + JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnAddr), null); }
/** A utility method for creating credentials. */ public static Credentials createCredentials(final NameNode namenode, final UserGroupInformation ugi, final String renewer) throws IOException { final Token<DelegationTokenIdentifier> token = namenode.getRpcServer( ).getDelegationToken(new Text(renewer)); if (token == null) { return null; } final InetSocketAddress addr = namenode.getNameNodeAddress(); SecurityUtil.setTokenService(token, addr); final Credentials c = new Credentials(); c.addToken(new Text(ugi.getShortUserName()), token); return c; }
private static DFSClient getDfsClient(NameNode nn, Configuration conf) throws IOException { return new DFSClient(nn.getNameNodeAddress(), conf); }
/** Sets the required configurations for performing failover. */ public static void setFailoverConfigurations(MiniDFSCluster cluster, Configuration conf, String logicalName, int nsIndex) { InetSocketAddress nnAddr1 = cluster.getNameNode(2 * nsIndex).getNameNodeAddress(); InetSocketAddress nnAddr2 = cluster.getNameNode(2 * nsIndex + 1).getNameNodeAddress(); setFailoverConfigurations(conf, logicalName, nnAddr1, nnAddr2); }
public static void setFederatedConfiguration(MiniDFSCluster cluster, Configuration conf) { Set<String> nameservices = new HashSet<String>(); for (NameNodeInfo info : cluster.getNameNodeInfos()) { assert info.nameserviceId != null; nameservices.add(info.nameserviceId); conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_RPC_ADDRESS_KEY, info.nameserviceId), DFSUtil.createUri(HdfsConstants.HDFS_URI_SCHEME, info.nameNode.getNameNodeAddress()).toString()); conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, info.nameserviceId), DFSUtil.createUri(HdfsConstants.HDFS_URI_SCHEME, info.nameNode.getNameNodeAddress()).toString()); } conf.set(DFSConfigKeys.DFS_NAMESERVICES, Joiner.on(",") .join(nameservices)); }
static void checkPath(MiniDFSCluster cluster, FileSystem fileSys) throws IOException { InetSocketAddress add = cluster.getNameNode().getNameNodeAddress(); // Test upper/lower case fileSys.checkPath(new Path("hdfs://" + StringUtils.toUpperCase(add.getHostName()) + ":" + add.getPort())); }
public void startServerForClientRequests() throws IOException { if (this.server == null) { InetSocketAddress socAddr = NameNode.getAddress(getConf()); int handlerCount = getConf().getInt("dfs.namenode.handler.count", 10); // create rpc server this.server = RPC.getServer(this, socAddr.getHostName(), socAddr.getPort(), handlerCount, false, getConf()); // The rpc-server port can be ephemeral... ensure we have the correct info this.serverAddress = this.server.getListenerAddress(); FileSystem.setDefaultUri(getConf(), getUri(serverAddress)); if (this.httpServer != null) { // This means the server is being started once out of safemode // and jetty is initialized already this.httpServer.setAttribute("name.node.address", getNameNodeAddress()); } LOG.info("Namenode up at: " + this.serverAddress); this.server.start(); } }
@BeforeClass public static void setUp() throws Exception { cluster = (new MiniDFSCluster.Builder(conf)) .numDataNodes(1).build(); nnAddress = cluster.getNameNode().getNameNodeAddress(); DataNode dn = cluster.getDataNodes().get(0); dnAddress = new InetSocketAddress(dn.getDatanodeId().getIpAddr(), dn.getIpcPort()); }