当前位置: 首页>>代码示例>>Java>>正文


Java ExitException类代码示例

本文整理汇总了Java中org.apache.hadoop.util.ExitUtil.ExitException的典型用法代码示例。如果您正苦于以下问题:Java ExitException类的具体用法?Java ExitException怎么用?Java ExitException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExitException类属于org.apache.hadoop.util.ExitUtil包,在下文中一共展示了ExitException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: expectOutput

import org.apache.hadoop.util.ExitUtil.ExitException; //导入依赖的package包/类
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);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:TestNativeLibraryChecker.java

示例2: testFormatWithEmptyDir

import org.apache.hadoop.util.ExitUtil.ExitException; //导入依赖的package包/类
/**
 * 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("")));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestClusterId.java

示例3: testFormatWithForce

import org.apache.hadoop.util.ExitUtil.ExitException; //导入依赖的package包/类
/**
 * 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("")));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestClusterId.java

示例4: testFormatWithForceAndClusterId

import org.apache.hadoop.util.ExitUtil.ExitException; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestClusterId.java

示例5: testFormatWithNonInteractive

import org.apache.hadoop.util.ExitUtil.ExitException; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestClusterId.java

示例6: testFormatWithNonInteractiveNameDirDoesNotExit

import org.apache.hadoop.util.ExitUtil.ExitException; //导入依赖的package包/类
/**
 * 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("")));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestClusterId.java

示例7: testFormatWithNonInteractiveAndForce

import org.apache.hadoop.util.ExitUtil.ExitException; //导入依赖的package包/类
/**
 * 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("")));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestClusterId.java

示例8: shutDownMiniCluster

import org.apache.hadoop.util.ExitUtil.ExitException; //导入依赖的package包/类
@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.
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:17,代码来源:TestEditLogJournalFailures.java


注:本文中的org.apache.hadoop.util.ExitUtil.ExitException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。