Exemplo n.º 1
0
 @Override
 public void uncaughtException(Thread t, Throwable e) {
   LOG.info("UncaughtExceptionHandler invoked");
   if (ShutdownHookManager.isShutdownInProgress()) {
     LOG.warn("Thread {} threw a Throwable, but we are shutting down, so ignoring this", t, e);
   } else if (e instanceof Error) {
     try {
       LOG.error("Thread {} threw an Error.  Shutting down now...", t, e);
     } catch (Throwable err) {
       // We don't want to not exit because of an issue with logging
     }
     if (e instanceof OutOfMemoryError) {
       // After catching an OOM java says it is undefined behavior, so don't
       // even try to clean up or we can get stuck on shutdown.
       try {
         System.err.println("Halting due to Out Of Memory Error...");
         e.printStackTrace();
       } catch (Throwable err) {
         // Again we done want to exit because of logging issues.
       }
       ExitUtil.halt(-1);
     } else {
       ExitUtil.terminate(-1);
     }
   } else {
     LOG.error("Thread {} threw an Exception. Shutting down now...", t, e);
     ExitUtil.terminate(-1);
   }
 }
Exemplo n.º 2
0
 @Before
 public void setup() {
   Logger rootLogger = LogManager.getRootLogger();
   rootLogger.setLevel(Level.DEBUG);
   ExitUtil.disableSystemExit();
   conf = new YarnConfiguration();
   UserGroupInformation.setConfiguration(conf);
   conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
   conf.set(YarnConfiguration.RM_SCHEDULER, FairScheduler.class.getName());
 }
 /** @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);
   }
 }