Java Code Examples for org.apache.hadoop.util.ExitUtil#terminate()
The following examples show how to use
org.apache.hadoop.util.ExitUtil#terminate() .
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: LoadExecutors.java From hadoop-ozone with Apache License 2.0 | 6 votes |
private void load(long runTimeMillis) { long threadID = Thread.currentThread().getId(); LOG.info("LOADGEN: Started IO Thread:{}.", threadID); long startTime = Time.monotonicNow(); while (Time.monotonicNow() - startTime < runTimeMillis) { LoadGenerator gen = generators.get(RandomUtils.nextInt(0, numGenerators)); try { gen.generateLoad(); } catch (Throwable t) { LOG.error("{} LOADGEN: Exiting due to exception", gen, t); ExitUtil.terminate(new ExitUtil.ExitException(1, t)); break; } } }
Example 2
Source File: AMSApplicationServer.java From ambari-metrics with Apache License 2.0 | 6 votes |
static AMSApplicationServer launchAMSApplicationServer(String[] args) { Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); StringUtils.startupShutdownMessage(AMSApplicationServer.class, args, LOG); AMSApplicationServer amsApplicationServer = null; try { amsApplicationServer = new AMSApplicationServer(); ShutdownHookManager.get().addShutdownHook( new CompositeServiceShutdownHook(amsApplicationServer), SHUTDOWN_HOOK_PRIORITY); YarnConfiguration conf = new YarnConfiguration(); amsApplicationServer.init(conf); amsApplicationServer.start(); } catch (Throwable t) { LOG.fatal("Error starting AMSApplicationServer", t); ExitUtil.terminate(-1, "Error starting AMSApplicationServer"); } return amsApplicationServer; }
Example 3
Source File: ApplicationMaster.java From metron with Apache License 2.0 | 6 votes |
/** * @param args Command line args */ public static void main(String[] args) { boolean result = false; try { ApplicationMaster appMaster = new ApplicationMaster(); LOG.info("Initializing ApplicationMaster"); boolean doRun = appMaster.init(args); if (!doRun) { System.exit(0); } appMaster.run(); result = appMaster.finish(); } catch (Throwable t) { LOG.fatal("Error running ApplicationMaster", t); LogManager.shutdown(); ExitUtil.terminate(1, t); } if (result) { LOG.info("Application Master completed successfully. exiting"); System.exit(0); } else { LOG.info("Application Master failed. exiting"); System.exit(2); } }
Example 4
Source File: RMDelegationTokenSecretManager.java From hadoop with Apache License 2.0 | 5 votes |
@Override protected void storeNewToken(RMDelegationTokenIdentifier identifier, long renewDate) { try { LOG.info("storing RMDelegation token with sequence number: " + identifier.getSequenceNumber()); rmContext.getStateStore().storeRMDelegationToken(identifier, renewDate); } catch (Exception e) { LOG.error("Error in storing RMDelegationToken with sequence number: " + identifier.getSequenceNumber()); ExitUtil.terminate(1, e); } }
Example 5
Source File: Gridmix.java From big-c with Apache License 2.0 | 5 votes |
public static void main(String[] argv) throws Exception { int res = -1; try { res = ToolRunner.run(new Configuration(), new Gridmix(argv), argv); } finally { ExitUtil.terminate(res); } }
Example 6
Source File: RMDelegationTokenSecretManager.java From big-c with Apache License 2.0 | 5 votes |
@Override protected void storeNewToken(RMDelegationTokenIdentifier identifier, long renewDate) { try { LOG.info("storing RMDelegation token with sequence number: " + identifier.getSequenceNumber()); rmContext.getStateStore().storeRMDelegationToken(identifier, renewDate); } catch (Exception e) { LOG.error("Error in storing RMDelegationToken with sequence number: " + identifier.getSequenceNumber()); ExitUtil.terminate(1, e); } }
Example 7
Source File: WebAppProxyServer.java From big-c with Apache License 2.0 | 5 votes |
public static void main(String[] args) { Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); StringUtils.startupShutdownMessage(WebAppProxyServer.class, args, LOG); try { YarnConfiguration configuration = new YarnConfiguration(); new GenericOptionsParser(configuration, args); WebAppProxyServer proxyServer = startServer(configuration); proxyServer.proxy.join(); } catch (Throwable t) { ExitUtil.terminate(-1, t); } }
Example 8
Source File: ResourceManager.java From hadoop with Apache License 2.0 | 5 votes |
public void handleTransitionToStandBy() { if (rmContext.isHAEnabled()) { try { // Transition to standby and reinit active services LOG.info("Transitioning RM to Standby mode"); transitionToStandby(true); adminService.resetLeaderElection(); return; } catch (Exception e) { LOG.fatal("Failed to transition RM to Standby mode."); ExitUtil.terminate(1, e); } } }
Example 9
Source File: ResourceManager.java From hadoop with Apache License 2.0 | 5 votes |
@Override public void handle(RMFatalEvent event) { LOG.fatal("Received a " + RMFatalEvent.class.getName() + " of type " + event.getType().name() + ". Cause:\n" + event.getCause()); ExitUtil.terminate(1, event.getCause()); }
Example 10
Source File: RMDelegationTokenSecretManager.java From hadoop with Apache License 2.0 | 5 votes |
@Override protected void removeStoredToken(RMDelegationTokenIdentifier ident) throws IOException { try { LOG.info("removing RMDelegation token with sequence number: " + ident.getSequenceNumber()); rmContext.getStateStore().removeRMDelegationToken(ident); } catch (Exception e) { LOG.error("Error in removing RMDelegationToken with sequence number: " + ident.getSequenceNumber()); ExitUtil.terminate(1, e); } }
Example 11
Source File: RMDelegationTokenSecretManager.java From hadoop with Apache License 2.0 | 5 votes |
@Override protected void updateStoredToken(RMDelegationTokenIdentifier id, long renewDate) { try { LOG.info("updating RMDelegation token with sequence number: " + id.getSequenceNumber()); rmContext.getStateStore().updateRMDelegationToken(id, renewDate); } catch (Exception e) { LOG.error("Error in updating persisted RMDelegationToken" + " with sequence number: " + id.getSequenceNumber()); ExitUtil.terminate(1, e); } }
Example 12
Source File: ResourceManager.java From big-c with Apache License 2.0 | 5 votes |
public void handleTransitionToStandBy() { if (rmContext.isHAEnabled()) { try { // Transition to standby and reinit active services LOG.info("Transitioning RM to Standby mode"); transitionToStandby(true); adminService.resetLeaderElection(); return; } catch (Exception e) { LOG.fatal("Failed to transition RM to Standby mode."); ExitUtil.terminate(1, e); } } }
Example 13
Source File: RMDelegationTokenSecretManager.java From big-c with Apache License 2.0 | 5 votes |
@Override protected void storeNewMasterKey(DelegationKey newKey) { try { LOG.info("storing master key with keyID " + newKey.getKeyId()); rmContext.getStateStore().storeRMDTMasterKey(newKey); } catch (Exception e) { LOG.error("Error in storing master key with KeyID: " + newKey.getKeyId()); ExitUtil.terminate(1, e); } }
Example 14
Source File: Gridmix.java From hadoop with Apache License 2.0 | 5 votes |
public static void main(String[] argv) throws Exception { int res = -1; try { res = ToolRunner.run(new Configuration(), new Gridmix(argv), argv); } finally { ExitUtil.terminate(res); } }
Example 15
Source File: DelegationTokenFetcher.java From hadoop with Apache License 2.0 | 5 votes |
private static void printUsage(PrintStream err) { err.println("fetchdt retrieves delegation tokens from the NameNode"); err.println(); err.println("fetchdt <opts> <token file>"); err.println("Options:"); err.println(" --webservice <url> Url to contact NN on"); err.println(" --renewer <name> Name of the delegation token renewer"); err.println(" --cancel Cancel the delegation token"); err.println(" --renew Renew the delegation token. Delegation " + "token must have been fetched using the --renewer <name> option."); err.println(" --print Print the delegation token"); err.println(); GenericOptionsParser.printGenericCommandUsage(err); ExitUtil.terminate(1); }
Example 16
Source File: DelegationTokenFetcher.java From big-c with Apache License 2.0 | 5 votes |
private static void printUsage(PrintStream err) { err.println("fetchdt retrieves delegation tokens from the NameNode"); err.println(); err.println("fetchdt <opts> <token file>"); err.println("Options:"); err.println(" --webservice <url> Url to contact NN on"); err.println(" --renewer <name> Name of the delegation token renewer"); err.println(" --cancel Cancel the delegation token"); err.println(" --renew Renew the delegation token. Delegation " + "token must have been fetched using the --renewer <name> option."); err.println(" --print Print the delegation token"); err.println(); GenericOptionsParser.printGenericCommandUsage(err); ExitUtil.terminate(1); }
Example 17
Source File: TimelineMetricStoreWatcherTest.java From ambari-metrics with Apache License 2.0 | 5 votes |
@Test public void testRunNegative() throws Exception { HBaseTimelineMetricsService metricStore = createNiceMock(HBaseTimelineMetricsService.class); expect(metricStore.putMetrics(anyObject(TimelineMetrics.class))) .andReturn(new TimelinePutResponse()); // no metrics found expect(metricStore.getTimelineMetrics(EasyMock.<List<String>>anyObject(), EasyMock.<List<String>>anyObject(), anyObject(String.class), anyObject(String.class), anyObject(Long.class), anyObject(Long.class), eq(Precision.SECONDS), eq(1), eq(true), anyObject(TopNConfig.class), anyString())) .andReturn(null).anyTimes(); String msg = "Error getting metrics from TimelineMetricStore. " + "Shutting down by TimelineMetricStoreWatcher."; mockStatic(ExitUtil.class); ExitUtil.terminate(-1, msg); expectLastCall().anyTimes(); replayAll(); TimelineMetricStoreWatcher timelineMetricStoreWatcher = new TimelineMetricStoreWatcher(metricStore, TimelineMetricConfiguration.getInstance()); timelineMetricStoreWatcher.run(); timelineMetricStoreWatcher.run(); timelineMetricStoreWatcher.run(); verifyAll(); }
Example 18
Source File: Submitter.java From big-c with Apache License 2.0 | 4 votes |
/** * Submit a pipes job based on the command line arguments. * @param args */ public static void main(String[] args) throws Exception { int exitCode = new Submitter().run(args); ExitUtil.terminate(exitCode); }
Example 19
Source File: CLI.java From hadoop with Apache License 2.0 | 4 votes |
public static void main(String[] argv) throws Exception { int res = ToolRunner.run(new CLI(), argv); ExitUtil.terminate(res); }
Example 20
Source File: MRAppMaster.java From hadoop with Apache License 2.0 | 4 votes |
public static void main(String[] args) { try { Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); String containerIdStr = System.getenv(Environment.CONTAINER_ID.name()); String nodeHostString = System.getenv(Environment.NM_HOST.name()); String nodePortString = System.getenv(Environment.NM_PORT.name()); String nodeHttpPortString = System.getenv(Environment.NM_HTTP_PORT.name()); String appSubmitTimeStr = System.getenv(ApplicationConstants.APP_SUBMIT_TIME_ENV); validateInputParam(containerIdStr, Environment.CONTAINER_ID.name()); validateInputParam(nodeHostString, Environment.NM_HOST.name()); validateInputParam(nodePortString, Environment.NM_PORT.name()); validateInputParam(nodeHttpPortString, Environment.NM_HTTP_PORT.name()); validateInputParam(appSubmitTimeStr, ApplicationConstants.APP_SUBMIT_TIME_ENV); ContainerId containerId = ConverterUtils.toContainerId(containerIdStr); ApplicationAttemptId applicationAttemptId = containerId.getApplicationAttemptId(); long appSubmitTime = Long.parseLong(appSubmitTimeStr); MRAppMaster appMaster = new MRAppMaster(applicationAttemptId, containerId, nodeHostString, Integer.parseInt(nodePortString), Integer.parseInt(nodeHttpPortString), appSubmitTime); ShutdownHookManager.get().addShutdownHook( new MRAppMasterShutdownHook(appMaster), SHUTDOWN_HOOK_PRIORITY); JobConf conf = new JobConf(new YarnConfiguration()); conf.addResource(new Path(MRJobConfig.JOB_CONF_FILE)); MRWebAppUtil.initialize(conf); String jobUserName = System .getenv(ApplicationConstants.Environment.USER.name()); conf.set(MRJobConfig.USER_NAME, jobUserName); initAndStartAppMaster(appMaster, conf, jobUserName); } catch (Throwable t) { LOG.fatal("Error starting MRAppMaster", t); ExitUtil.terminate(1, t); } }