Java Code Examples for org.apache.hadoop.util.ExitUtil#resetFirstExitException()

The following examples show how to use org.apache.hadoop.util.ExitUtil#resetFirstExitException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestApplicationHistoryServer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 60000)
public void testLaunchWithArguments() throws Exception {
  ExitUtil.disableSystemExit();
  ApplicationHistoryServer historyServer = null;
  try {
    // Not able to modify the config of this test case,
    // but others have been customized to avoid conflicts
    String[] args = new String[2];
    args[0]="-D" + YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS + "=4000";
    args[1]="-D" + YarnConfiguration.TIMELINE_SERVICE_TTL_MS + "=200";
    historyServer =
        ApplicationHistoryServer.launchAppHistoryServer(args);
    Configuration conf = historyServer.getConfig();
    assertEquals("4000", conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS));
    assertEquals("200", conf.get(YarnConfiguration.TIMELINE_SERVICE_TTL_MS));
  } catch (ExitUtil.ExitException e) {
    assertEquals(0, e.status);
    ExitUtil.resetFirstExitException();
    fail();
  } finally {
    if (historyServer != null) {
      historyServer.stop();
    }
  }
}
 
Example 2
Source File: TestApplicationHistoryServer.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 60000)
public void testLaunchWithArguments() throws Exception {
  ExitUtil.disableSystemExit();
  ApplicationHistoryServer historyServer = null;
  try {
    // Not able to modify the config of this test case,
    // but others have been customized to avoid conflicts
    String[] args = new String[2];
    args[0]="-D" + YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS + "=4000";
    args[1]="-D" + YarnConfiguration.TIMELINE_SERVICE_TTL_MS + "=200";
    historyServer =
        ApplicationHistoryServer.launchAppHistoryServer(args);
    Configuration conf = historyServer.getConfig();
    assertEquals("4000", conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS));
    assertEquals("200", conf.get(YarnConfiguration.TIMELINE_SERVICE_TTL_MS));
  } catch (ExitUtil.ExitException e) {
    assertEquals(0, e.status);
    ExitUtil.resetFirstExitException();
    fail();
  } finally {
    if (historyServer != null) {
      historyServer.stop();
    }
  }
}
 
Example 3
Source File: TestApplicationHistoryServer.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 60000)
public void testLaunch() throws Exception {
  ExitUtil.disableSystemExit();
  ApplicationHistoryServer historyServer = null;
  try {
    // Not able to modify the config of this test case,
    // but others have been customized to avoid conflicts
    historyServer =
        ApplicationHistoryServer.launchAppHistoryServer(new String[0]);
  } catch (ExitUtil.ExitException e) {
    assertEquals(0, e.status);
    ExitUtil.resetFirstExitException();
    fail();
  } finally {
    if (historyServer != null) {
      historyServer.stop();
    }
  }
}
 
Example 4
Source File: TestApplicationHistoryServer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 60000)
public void testLaunch() throws Exception {
  ExitUtil.disableSystemExit();
  ApplicationHistoryServer historyServer = null;
  try {
    // Not able to modify the config of this test case,
    // but others have been customized to avoid conflicts
    historyServer =
        ApplicationHistoryServer.launchAppHistoryServer(new String[0]);
  } catch (ExitUtil.ExitException e) {
    assertEquals(0, e.status);
    ExitUtil.resetFirstExitException();
    fail();
  } finally {
    if (historyServer != null) {
      historyServer.stop();
    }
  }
}
 
Example 5
Source File: TestGridmixSubmission.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test (timeout=100000)
public void testMain() throws Exception {

  SecurityManager securityManager = System.getSecurityManager();

  final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  final PrintStream out = new PrintStream(bytes);
  final PrintStream oldOut = System.out;
  System.setErr(out);
  ExitUtil.disableSystemExit();
  try {
    String[] argv = new String[0];
    DebugGridmix.main(argv);

  } catch (ExitUtil.ExitException e) {
    assertEquals("ExitException", e.getMessage());
    ExitUtil.resetFirstExitException();
  } finally {
    System.setErr(oldOut);
    System.setSecurityManager(securityManager);
  }
  String print = bytes.toString();
  // should be printed tip in std error stream
  assertTrue(print
          .contains("Usage: gridmix [-generate <MiB>] [-users URI] [-Dname=value ...] <iopath> <trace>"));
  assertTrue(print.contains("e.g. gridmix -generate 100m foo -"));
}
 
Example 6
Source File: TestTools.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static void expectDelegationTokenFetcherExit(String[] args) {
  try {
    DelegationTokenFetcher.main(args);
    fail("should call exit");
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } catch (Exception ex) {
    fail("expectDelegationTokenFetcherExit ex error " + ex);
  }
}
 
Example 7
Source File: MiniDFSCluster.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Shutdown all the nodes in the cluster.
 */
public void shutdown(boolean deleteDfsDir) {
  LOG.info("Shutting down the Mini HDFS Cluster");
  if (checkExitOnShutdown)  {
    if (ExitUtil.terminateCalled()) {
      LOG.fatal("Test resulted in an unexpected exit",
          ExitUtil.getFirstExitException());
      ExitUtil.resetFirstExitException();
      throw new AssertionError("Test resulted in an unexpected exit");
    }
  }
  shutdownDataNodes();
  for (NameNodeInfo nnInfo : nameNodes) {
    if (nnInfo == null) continue;
    NameNode nameNode = nnInfo.nameNode;
    if (nameNode != null) {
      nameNode.stop();
      nameNode.join();
      nameNode = null;
    }
  }
  if (deleteDfsDir) {
      base_dir.delete();
  } else {
      base_dir.deleteOnExit();
  }
}
 
Example 8
Source File: TestTools.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static void expectJMXGetExit(String[] args) {
  try {
    JMXGet.main(args);
    fail("should call exit");
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } catch (Exception ex) {
    fail("expectJMXGetExit ex error " + ex);
  }
}
 
Example 9
Source File: TestTools.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static void expectDelegationTokenFetcherExit(String[] args) {
  try {
    DelegationTokenFetcher.main(args);
    fail("should call exit");
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } catch (Exception ex) {
    fail("expectDelegationTokenFetcherExit ex error " + ex);
  }
}
 
Example 10
Source File: TestJobHistoryServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test (timeout =60000)
public void testLaunch() throws Exception {

  ExitUtil.disableSystemExit();
  try {
    historyServer = JobHistoryServer.launchJobHistoryServer(new String[0]);
  } catch (ExitUtil.ExitException e) {
    assertEquals(0,e.status);
    ExitUtil.resetFirstExitException();
    fail();
  }
}
 
Example 11
Source File: TestJobHistoryServer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test (timeout =60000)
public void testLaunch() throws Exception {

  ExitUtil.disableSystemExit();
  try {
    historyServer = JobHistoryServer.launchJobHistoryServer(new String[0]);
  } catch (ExitUtil.ExitException e) {
    assertEquals(0,e.status);
    ExitUtil.resetFirstExitException();
    fail();
  }
}
 
Example 12
Source File: TestGridmixSubmission.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test (timeout=100000)
public void testMain() throws Exception {

  SecurityManager securityManager = System.getSecurityManager();

  final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  final PrintStream out = new PrintStream(bytes);
  final PrintStream oldOut = System.out;
  System.setErr(out);
  ExitUtil.disableSystemExit();
  try {
    String[] argv = new String[0];
    DebugGridmix.main(argv);

  } catch (ExitUtil.ExitException e) {
    assertEquals("ExitException", e.getMessage());
    ExitUtil.resetFirstExitException();
  } finally {
    System.setErr(oldOut);
    System.setSecurityManager(securityManager);
  }
  String print = bytes.toString();
  // should be printed tip in std error stream
  assertTrue(print
          .contains("Usage: gridmix [-generate <MiB>] [-users URI] [-Dname=value ...] <iopath> <trace>"));
  assertTrue(print.contains("e.g. gridmix -generate 100m foo -"));
}
 
Example 13
Source File: MiniDFSCluster.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Shutdown all the nodes in the cluster.
 */
public void shutdown(boolean deleteDfsDir) {
  LOG.info("Shutting down the Mini HDFS Cluster");
  if (checkExitOnShutdown)  {
    if (ExitUtil.terminateCalled()) {
      LOG.fatal("Test resulted in an unexpected exit",
          ExitUtil.getFirstExitException());
      ExitUtil.resetFirstExitException();
      throw new AssertionError("Test resulted in an unexpected exit");
    }
  }
  shutdownDataNodes();
  for (NameNodeInfo nnInfo : nameNodes) {
    if (nnInfo == null) continue;
    NameNode nameNode = nnInfo.nameNode;
    if (nameNode != null) {
      nameNode.stop();
      nameNode.join();
      nameNode = null;
    }
  }
  if (deleteDfsDir) {
      base_dir.delete();
  } else {
      base_dir.deleteOnExit();
  }
}
 
Example 14
Source File: TestTools.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static void expectJMXGetExit(String[] args) {
  try {
    JMXGet.main(args);
    fail("should call exit");
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } catch (Exception ex) {
    fail("expectJMXGetExit ex error " + ex);
  }
}
 
Example 15
Source File: TestBookKeeperAsHASharedDir.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Before
public void clearExitStatus() {
  ExitUtil.resetFirstExitException();
}
 
Example 16
Source File: TestNNWithQJM.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Before
public void resetSystemExit() {
  ExitUtil.resetFirstExitException();
}
 
Example 17
Source File: TestCheckpoint.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test(timeout=30000)
public void testTooManyEditReplayFailures() throws IOException {
  Configuration conf = new HdfsConfiguration();
  conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_MAX_RETRIES_KEY, 1);
  conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_PERIOD_KEY, 1);

  FSDataOutputStream fos = null;
  SecondaryNameNode secondary = null;
  MiniDFSCluster cluster = null;
  FileSystem fs = null;

  try {
    cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDatanodes)
        .checkExitOnShutdown(false).build();
    cluster.waitActive();
    fs = cluster.getFileSystem();
    fos = fs.create(new Path("tmpfile0"));
    fos.write(new byte[] { 0, 1, 2, 3 });

    // Cause merge to fail in next checkpoint.
    Mockito.doThrow(new IOException(
        "Injecting failure during merge"))
        .when(faultInjector).duringMerge();

    secondary = startSecondaryNameNode(conf);
    secondary.doWork();
    // Fail if we get here.
    fail("2NN did not exit.");
  } catch (ExitException ee) {
    // ignore
    ExitUtil.resetFirstExitException();
    assertEquals("Max retries", 1, secondary.getMergeErrorCount() - 1);
  } finally {
    if (fs != null) {
      fs.close();
    }
    cleanup(secondary);
    secondary = null;
    cleanup(cluster);
    cluster = null;
    Mockito.reset(faultInjector);
  }
}
 
Example 18
Source File: TestCheckpoint.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test(timeout=30000)
public void testTooManyEditReplayFailures() throws IOException {
  Configuration conf = new HdfsConfiguration();
  conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_MAX_RETRIES_KEY, 1);
  conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_PERIOD_KEY, 1);

  FSDataOutputStream fos = null;
  SecondaryNameNode secondary = null;
  MiniDFSCluster cluster = null;
  FileSystem fs = null;

  try {
    cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDatanodes)
        .checkExitOnShutdown(false).build();
    cluster.waitActive();
    fs = cluster.getFileSystem();
    fos = fs.create(new Path("tmpfile0"));
    fos.write(new byte[] { 0, 1, 2, 3 });

    // Cause merge to fail in next checkpoint.
    Mockito.doThrow(new IOException(
        "Injecting failure during merge"))
        .when(faultInjector).duringMerge();

    secondary = startSecondaryNameNode(conf);
    secondary.doWork();
    // Fail if we get here.
    fail("2NN did not exit.");
  } catch (ExitException ee) {
    // ignore
    ExitUtil.resetFirstExitException();
    assertEquals("Max retries", 1, secondary.getMergeErrorCount() - 1);
  } finally {
    if (fs != null) {
      fs.close();
    }
    cleanup(secondary);
    secondary = null;
    cleanup(cluster);
    cluster = null;
    Mockito.reset(faultInjector);
  }
}
 
Example 19
Source File: TestNNWithQJM.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void resetSystemExit() {
  ExitUtil.resetFirstExitException();
}
 
Example 20
Source File: TestBookKeeperAsHASharedDir.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void clearExitStatus() {
  ExitUtil.resetFirstExitException();
}