@BeforeClass public static void setUpClass() throws IOException { // NOTE : The MiniClusterDFS leaves behind the directory under which the cluster was created baseDir = new File("/tmp/" + UUID.randomUUID().toString()); FileUtil.fullyDelete(baseDir); // Append is not supported in LocalFileSystem. HDFS needs to be setup. Configuration conf = new Configuration(); // lower heartbeat interval for fast recognition of DN conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, baseDir.getAbsolutePath()); conf.setInt(DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY, 1000); conf.setInt(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1); conf.setInt(DFSConfigKeys.DFS_CLIENT_SOCKET_TIMEOUT_KEY, 3000); cluster = new MiniDFSCluster.Builder(conf).checkExitOnShutdown(true).numDataNodes(4).build(); }
@BeforeClass public static void setUp() throws Exception { final Configuration conf = new Configuration(); conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME); conf.set(YarnConfiguration.RM_PRINCIPAL, "jt_id/" + SecurityUtil.HOSTNAME_PATTERN + "@APACHE.ORG"); final MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf); builder.checkExitOnShutdown(true); builder.numDataNodes(numSlaves); builder.format(true); builder.racks(null); dfsCluster = builder.build(); mrCluster = new MiniMRYarnCluster(TestBinaryTokenFile.class.getName(), noOfNMs); mrCluster.init(conf); mrCluster.start(); NameNodeAdapter.getDtSecretManager(dfsCluster.getNamesystem()).startThreads(); FileSystem fs = dfsCluster.getFileSystem(); p1 = new Path("file1"); p1 = fs.makeQualified(p1); }
@Test(timeout = 30000) public void testMetadataVersionOutput() throws IOException { initConfig(); dfsCluster = new MiniDFSCluster.Builder(conf). manageNameDfsDirs(false). numDataNodes(1). checkExitOnShutdown(false). build(); dfsCluster.waitClusterUp(); dfsCluster.shutdown(false); initConfig(); final PrintStream origOut = System.out; final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final PrintStream stdOut = new PrintStream(baos); System.setOut(stdOut); try { NameNode.createNameNode(new String[] { "-metadataVersion" }, conf); } catch (Exception e) { assertExceptionContains("ExitException", e); } /* Check if meta data version is printed correctly. */ final String verNumStr = HdfsConstants.NAMENODE_LAYOUT_VERSION + ""; assertTrue(baos.toString("UTF-8"). contains("HDFS Image Version: " + verNumStr)); assertTrue(baos.toString("UTF-8"). contains("Software format version: " + verNumStr)); System.setOut(origOut); } }
.numDataNodes(0) .manageNameDfsDirs(false) .checkExitOnShutdown(false) .build(); .format(false) .manageNameDfsDirs(false) .checkExitOnShutdown(false) .build();
.nnTopology(MiniDFSNNTopology.simpleHATopology()) .numDataNodes(0) .checkExitOnShutdown(false) .build();
.numDataNodes(0) .manageNameDfsDirs(false) .checkExitOnShutdown(false) .build(); .format(false) .manageNameDfsDirs(false) .checkExitOnShutdown(false) .build();
.checkExitOnShutdown(false).build(); cluster.waitActive(); fs = cluster.getFileSystem();
.nnTopology(MiniDFSNNTopology.simpleHATopology()) .numDataNodes(0) .checkExitOnShutdown(false) .build(); cluster.waitActive();
.nnTopology(topology) .numDataNodes(0) .checkExitOnShutdown(false) .build(); } else { Builder builder = new MiniQJMHACluster.Builder(conf); builder.getDfsBuilder().numDataNodes(0).checkExitOnShutdown(false); miniQjmHaCluster = builder.build(); cluster = miniQjmHaCluster.getDfsCluster();
public void setUpMiniCluster(Configuration conf, boolean manageNameDfsDirs) throws IOException { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0) .manageNameDfsDirs(manageNameDfsDirs).checkExitOnShutdown(false).build(); cluster.waitActive(); fs = cluster.getFileSystem(); }