Java 类org.apache.hadoop.util.ExitUtil.ExitException 实例源码

项目:hadoop-oss    文件:TestNativeLibraryChecker.java   
private void expectOutput(String [] args) {
  ExitUtil.disableSystemExit();
  ByteArrayOutputStream outContent = new ByteArrayOutputStream();
  PrintStream originalPs = System.out;
  System.setOut(new PrintStream(outContent));
  try {
    NativeLibraryChecker.main(args);
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } finally {
    if (Shell.WINDOWS) {
      assertEquals(outContent.toString().indexOf("winutils: true") != -1, true);
    }
    if (NativeCodeLoader.isNativeCodeLoaded()) {
      assertEquals(outContent.toString().indexOf("hadoop:  true") != -1, true);
    }
    System.setOut(originalPs);
  }
}
项目:hadoop    文件:TestClusterId.java   
/**
 * Test namenode format with -format option when an empty name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithEmptyDir() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force options when name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force -clusterid option when name
 * directory exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForceAndClusterId() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String myId = "testFormatWithForceAndClusterId";
  String[] argv = { "-format", "-force", "-clusterid", myId };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cId = getClusterId(config);
  assertEquals("ClusterIds do not match", myId, cId);
}
项目:hadoop    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when a non empty
 * name directory exists. Format should not succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractive() throws IOException {

  // we check for a non empty dir, so create a child path
  File data = new File(hdfsDir, "file");
  if (!data.mkdirs()) {
    fail("Failed to create dir " + data.getPath());
  }

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have been aborted with exit code 1", 1,
        e.status);
  }

  // check if the version file does not exists.
  File version = new File(hdfsDir, "current/VERSION");
  assertFalse("Check version should not exist", version.exists());
}
项目:hadoop    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when name
 * directory does not exist. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveNameDirDoesNotExit()
    throws IOException {

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop    文件:TestClusterId.java   
/**
 * Test namenode format with -force -nonInteractive -force option. Format
 * should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveAndForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-nonInteractive", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop    文件:TestNativeLibraryChecker.java   
private void expectOutput(String [] args) {
  ExitUtil.disableSystemExit();
  ByteArrayOutputStream outContent = new ByteArrayOutputStream();
  PrintStream originalPs = System.out;
  System.setOut(new PrintStream(outContent));
  try {
    NativeLibraryChecker.main(args);
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } finally {
    if (Shell.WINDOWS) {
      assertEquals(outContent.toString().indexOf("winutils: true") != -1, true);
    }
    if (NativeCodeLoader.isNativeCodeLoaded()) {
      assertEquals(outContent.toString().indexOf("hadoop:  true") != -1, true);
    }
    System.setOut(originalPs);
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterId.java   
/**
 * Test namenode format with -format option when an empty name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithEmptyDir() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force options when name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force -clusterid option when name
 * directory exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForceAndClusterId() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String myId = "testFormatWithForceAndClusterId";
  String[] argv = { "-format", "-force", "-clusterid", myId };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cId = getClusterId(config);
  assertEquals("ClusterIds do not match", myId, cId);
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when a non empty
 * name directory exists. Format should not succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractive() throws IOException {

  // we check for a non empty dir, so create a child path
  File data = new File(hdfsDir, "file");
  if (!data.mkdirs()) {
    fail("Failed to create dir " + data.getPath());
  }

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have been aborted with exit code 1", 1,
        e.status);
  }

  // check if the version file does not exists.
  File version = new File(hdfsDir, "current/VERSION");
  assertFalse("Check version should not exist", version.exists());
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when name
 * directory does not exist. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveNameDirDoesNotExit()
    throws IOException {

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterId.java   
/**
 * Test namenode format with -force -nonInteractive -force option. Format
 * should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveAndForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-nonInteractive", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:aliyun-oss-hadoop-fs    文件:TestEditLogJournalFailures.java   
@After
public void shutDownMiniCluster() throws IOException {
  if (fs != null) {
    fs.close();
    fs = null;
  }
  if (cluster != null) {
    try {
      cluster.shutdown();
      cluster = null;
    } catch (ExitException ee) {
      // Ignore ExitExceptions as the tests may result in the
      // NameNode doing an immediate shutdown.
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestNativeLibraryChecker.java   
private void expectOutput(String [] args) {
  ExitUtil.disableSystemExit();
  ByteArrayOutputStream outContent = new ByteArrayOutputStream();
  PrintStream originalPs = System.out;
  System.setOut(new PrintStream(outContent));
  try {
    NativeLibraryChecker.main(args);
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } finally {
    if (Shell.WINDOWS) {
      assertEquals(outContent.toString().indexOf("winutils: true") != -1, true);
    }
    if (NativeCodeLoader.isNativeCodeLoaded()) {
      assertEquals(outContent.toString().indexOf("hadoop:  true") != -1, true);
    }
    System.setOut(originalPs);
  }
}
项目:big-c    文件:TestClusterId.java   
/**
 * Test namenode format with -format option when an empty name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithEmptyDir() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:big-c    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force options when name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:big-c    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force -clusterid option when name
 * directory exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForceAndClusterId() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String myId = "testFormatWithForceAndClusterId";
  String[] argv = { "-format", "-force", "-clusterid", myId };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cId = getClusterId(config);
  assertEquals("ClusterIds do not match", myId, cId);
}
项目:big-c    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when a non empty
 * name directory exists. Format should not succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractive() throws IOException {

  // we check for a non empty dir, so create a child path
  File data = new File(hdfsDir, "file");
  if (!data.mkdirs()) {
    fail("Failed to create dir " + data.getPath());
  }

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have been aborted with exit code 1", 1,
        e.status);
  }

  // check if the version file does not exists.
  File version = new File(hdfsDir, "current/VERSION");
  assertFalse("Check version should not exist", version.exists());
}
项目:big-c    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when name
 * directory does not exist. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveNameDirDoesNotExit()
    throws IOException {

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:big-c    文件:TestClusterId.java   
/**
 * Test namenode format with -force -nonInteractive -force option. Format
 * should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveAndForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-nonInteractive", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:big-c    文件:TestNativeLibraryChecker.java   
private void expectOutput(String [] args) {
  ExitUtil.disableSystemExit();
  ByteArrayOutputStream outContent = new ByteArrayOutputStream();
  PrintStream originalPs = System.out;
  System.setOut(new PrintStream(outContent));
  try {
    NativeLibraryChecker.main(args);
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } finally {
    if (Shell.WINDOWS) {
      assertEquals(outContent.toString().indexOf("winutils: true") != -1, true);
    }
    if (NativeCodeLoader.isNativeCodeLoaded()) {
      assertEquals(outContent.toString().indexOf("hadoop:  true") != -1, true);
    }
    System.setOut(originalPs);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestClusterId.java   
/**
 * Test namenode format with -format option when an empty name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithEmptyDir() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force options when name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force -clusterid option when name
 * directory exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForceAndClusterId() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String myId = "testFormatWithForceAndClusterId";
  String[] argv = { "-format", "-force", "-clusterid", myId };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cId = getClusterId(config);
  assertEquals("ClusterIds do not match", myId, cId);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when a non empty
 * name directory exists. Format should not succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractive() throws IOException {

  // we check for a non empty dir, so create a child path
  File data = new File(hdfsDir, "file");
  if (!data.mkdirs()) {
    fail("Failed to create dir " + data.getPath());
  }

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have been aborted with exit code 1", 1,
        e.status);
  }

  // check if the version file does not exists.
  File version = new File(hdfsDir, "current/VERSION");
  assertFalse("Check version should not exist", version.exists());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when name
 * directory does not exist. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveNameDirDoesNotExit()
    throws IOException {

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestClusterId.java   
/**
 * Test namenode format with -force -nonInteractive -force option. Format
 * should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveAndForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-nonInteractive", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestNativeLibraryChecker.java   
private void expectOutput(String [] args) {
  ExitUtil.disableSystemExit();
  ByteArrayOutputStream outContent = new ByteArrayOutputStream();
  PrintStream originalPs = System.out;
  System.setOut(new PrintStream(outContent));
  try {
    NativeLibraryChecker.main(args);
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } finally {
    if (Shell.WINDOWS) {
      assertEquals(outContent.toString().indexOf("winutils: true") != -1, true);
    }
    if (NativeCodeLoader.isNativeCodeLoaded()) {
      assertEquals(outContent.toString().indexOf("hadoop:  true") != -1, true);
    }
    System.setOut(originalPs);
  }
}
项目:hadoop-plus    文件:TestClusterId.java   
/**
 * Test namenode format with -format option when an empty name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithEmptyDir() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop-plus    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force options when name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop-plus    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force -clusterid option when name
 * directory exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForceAndClusterId() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String myId = "testFormatWithForceAndClusterId";
  String[] argv = { "-format", "-force", "-clusterid", myId };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cId = getClusterId(config);
  assertEquals("ClusterIds do not match", myId, cId);
}
项目:hadoop-plus    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when a non empty
 * name directory exists. Format should not succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractive() throws IOException {

  // we check for a non empty dir, so create a child path
  File data = new File(hdfsDir, "file");
  if (!data.mkdirs()) {
    fail("Failed to create dir " + data.getPath());
  }

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have been aborted with exit code 1", 1,
        e.status);
  }

  // check if the version file does not exists.
  File version = new File(hdfsDir, "current/VERSION");
  assertFalse("Check version should not exist", version.exists());
}
项目:hadoop-plus    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when name
 * directory does not exist. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveNameDirDoesNotExit()
    throws IOException {

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:hadoop-plus    文件:TestClusterId.java   
/**
 * Test namenode format with -force -nonInteractive -force option. Format
 * should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractiveAndForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-nonInteractive", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:FlexMap    文件:TestClusterId.java   
/**
 * Test namenode format with -format option when an empty name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithEmptyDir() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:FlexMap    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force options when name directory
 * exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForce() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String[] argv = { "-format", "-force" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cid = getClusterId(config);
  assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")));
}
项目:FlexMap    文件:TestClusterId.java   
/**
 * Test namenode format with -format -force -clusterid option when name
 * directory exists. Format should succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithForceAndClusterId() throws IOException {

  if (!hdfsDir.mkdirs()) {
    fail("Failed to create dir " + hdfsDir.getPath());
  }

  String myId = "testFormatWithForceAndClusterId";
  String[] argv = { "-format", "-force", "-clusterid", myId };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have succeeded", 0, e.status);
  }

  String cId = getClusterId(config);
  assertEquals("ClusterIds do not match", myId, cId);
}
项目:FlexMap    文件:TestClusterId.java   
/**
 * Test namenode format with -format -nonInteractive options when a non empty
 * name directory exists. Format should not succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractive() throws IOException {

  // we check for a non empty dir, so create a child path
  File data = new File(hdfsDir, "file");
  if (!data.mkdirs()) {
    fail("Failed to create dir " + data.getPath());
  }

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have been aborted with exit code 1", 1,
        e.status);
  }

  // check if the version file does not exists.
  File version = new File(hdfsDir, "current/VERSION");
  assertFalse("Check version should not exist", version.exists());
}