protected InetSocketAddress getHttpServerAddress(Configuration conf) { return getHttpAddress(conf); }
NamenodeRegistration setRegistration() { nodeRegistration = new NamenodeRegistration( NetUtils.getHostPortString(getNameNodeAddress()), NetUtils.getHostPortString(getHttpAddress()), getFSImage().getStorage(), getRole()); return nodeRegistration; }
protected InetSocketAddress getHttpServerAddress(Configuration conf) { return getHttpAddress(conf); }
protected InetSocketAddress getHttpServerAddress(Configuration conf) { return getHttpAddress(conf); }
private static void testViewingFile(MiniDFSCluster cluster, String filePath, boolean doTail) throws IOException { FileSystem fs = cluster.getFileSystem(); Path testPath = new Path(filePath); if (!fs.exists(testPath)) { DFSTestUtil.writeFile(fs, testPath, FILE_DATA); } InetSocketAddress nnHttpAddress = cluster.getNameNode().getHttpAddress(); int dnInfoPort = cluster.getDataNodes().get(0).getInfoPort(); String jspName = doTail ? "tail.jsp" : "browseDirectory.jsp"; String fileParamName = doTail ? "filename" : "dir"; URL url = new URL("http://localhost:" + dnInfoPort + "/" + jspName + JspHelper.getUrlParam(fileParamName, URLEncoder.encode(testPath.toString(), "UTF-8"), true) + JspHelper.getUrlParam("namenodeInfoPort", Integer.toString(nnHttpAddress.getPort()))); String viewFilePage = DFSTestUtil.urlGet(url); assertTrue("page should show preview of file contents", viewFilePage.contains(FILE_DATA)); if (!doTail) { assertTrue("page should show link to download file", viewFilePage .contains("/streamFile" + URIUtil.encodePath(testPath.toString()))); } }
@BeforeClass public static void setUp() throws IOException { conf = new Configuration(); conf.set(DFSConfigKeys.DFS_WEBHDFS_AUTHENTICATION_FILTER_KEY, CustomizedFilter.class.getName()); conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "localhost:0"); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build(); InetSocketAddress addr = cluster.getNameNode().getHttpAddress(); fs = FileSystem.get( URI.create("webhdfs://" + NetUtils.getHostPortString(addr)), conf); cluster.waitActive(); }
NamenodeRegistration setRegistration() { nodeRegistration = new NamenodeRegistration( NetUtils.getHostPortString(rpcServer.getRpcAddress()), NetUtils.getHostPortString(getHttpAddress()), getFSImage().getStorage(), getRole()); return nodeRegistration; }
NamenodeRegistration setRegistration() { nodeRegistration = new NamenodeRegistration( NetUtils.getHostPortString(rpcServer.getRpcAddress()), NetUtils.getHostPortString(getHttpAddress()), getFSImage().getStorage(), getRole()); return nodeRegistration; }
private static void setupCluster(final int nNameNodes, final int nDataNodes) throws Exception { LOG.info("nNameNodes=" + nNameNodes + ", nDataNodes=" + nDataNodes); conf.setBoolean(DFSConfigKeys.DFS_WEBHDFS_ENABLED_KEY, true); cluster = new MiniDFSCluster.Builder(conf) .nnTopology(MiniDFSNNTopology.simpleFederatedTopology(nNameNodes)) .numDataNodes(nDataNodes) .build(); cluster.waitActive(); webhdfs = new WebHdfsFileSystem[nNameNodes]; for(int i = 0; i < webhdfs.length; i++) { final InetSocketAddress addr = cluster.getNameNode(i).getHttpAddress(); final String uri = WebHdfsFileSystem.SCHEME + "://" + addr.getHostName() + ":" + addr.getPort() + "/"; webhdfs[i] = (WebHdfsFileSystem)FileSystem.get(new URI(uri), conf); } }
os.write(CONTENTS); InetSocketAddress addr = cluster.getNameNode().getHttpAddress(); URL url = new URL("http", addr.getHostString(), addr .getPort(), WebHdfsFileSystem.PATH_PREFIX + PATH + "?op=OPEN" +
if (nn.getHttpAddress() != null) { conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_HTTP_ADDRESS_KEY, nameserviceId, nnId), NetUtils.getHostPortString(nn.getHttpAddress()));
/** * Regression test for HDFS-1997. Test that, if an exception * occurs on the client side, it is properly reported as such */ @Test public void testClientSideException() throws IOException { Configuration conf = new HdfsConfiguration(); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .numDataNodes(0).build(); try { String fsName = NameNode.getHostPortString( cluster.getNameNode().getHttpAddress()); String id = "getimage=1"; File[] localPath = new File[] { new File("/xxxxx-does-not-exist/blah") }; TransferFsImage.getFileClient(fsName, id, localPath); fail("Didn't get an exception!"); } catch (IOException ioe) { assertTrue("Expected FNFE, got: " + StringUtils.stringifyException(ioe), ioe instanceof FileNotFoundException); } finally { cluster.shutdown(); } } }
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build(); cluster.waitActive(); String address = cluster.getNameNode().getHttpAddress().toString(); assertFalse("HTTP Bind address not expected to be wildcard by default.", address.startsWith(WILDCARD_ADDRESS)); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build(); cluster.waitActive(); String address = cluster.getNameNode().getHttpAddress().toString(); assertTrue("HTTP Bind address " + address + " is not wildcard.", address.startsWith(WILDCARD_ADDRESS));
URI uri = new URI( "http", NetUtils.getHostPortString(cluster.getNameNode().getHttpAddress()), "/webhdfs/v1/", op.toQueryString(), null);
.format(true).build(); int origPort = cluster.getNameNodePort(); int origHttpPort = cluster.getNameNode().getHttpAddress().getPort(); Configuration snnConf = new Configuration(conf); File checkpointDir = new File(MiniDFSCluster.getBaseDirectory(),
nn1.getHttpAddress().getHostName() + ":" + nn1.getHttpAddress().getPort() + "/jmx")); assertTrue(pageContents.contains("NumLiveDataNodes"));
@SuppressWarnings("unchecked") // for any(Token.class) @Test public void testLazyTokenFetchForWebhdfs() throws Exception { MiniDFSCluster cluster = null; WebHdfsFileSystem fs = null; try { final Configuration clusterConf = new HdfsConfiguration(conf); SecurityUtil.setAuthenticationMethod(SIMPLE, clusterConf); clusterConf.setBoolean(DFSConfigKeys .DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY, true); // trick the NN into thinking security is enabled w/o it trying // to login from a keytab UserGroupInformation.setConfiguration(clusterConf); cluster = new MiniDFSCluster.Builder(clusterConf).numDataNodes(1).build(); cluster.waitActive(); SecurityUtil.setAuthenticationMethod(KERBEROS, clusterConf); UserGroupInformation.setConfiguration(clusterConf); uri = DFSUtil.createUri( "webhdfs", cluster.getNameNode().getHttpAddress()); validateLazyTokenFetch(clusterConf); } finally { IOUtils.cleanup(null, fs); if (cluster != null) { cluster.shutdown(); } } }