Exemple #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);
   }
 }
Exemple #2
0
 /**
  * Shutdown the NN immediately in an ungraceful way. Used when it would be unsafe for the NN to
  * continue operating, e.g. during a failed HA state transition.
  *
  * @param t exception which warrants the shutdown. Printed to the NN log before exit.
  * @throws ExitException thrown only for testing.
  */
 protected synchronized void doImmediateShutdown(Throwable t) throws ExitException {
   String message = "Error encountered requiring NN shutdown. " + "Shutting down immediately.";
   try {
     LOG.fatal(message, t);
   } catch (Throwable ignored) {
     // This is unlikely to happen, but there's nothing we can do if it does.
   }
   terminate(1, t);
 }
Exemple #3
0
  public static void main(String argv[]) throws Exception {
    if (DFSUtil.parseHelpArgument(argv, NameNode.USAGE, System.out, true)) {
      System.exit(0);
    }

    try {
      StringUtils.startupShutdownMessage(NameNode.class, argv, LOG);
      NameNode namenode = createNameNode(argv, null);
      if (namenode != null) {
        namenode.join();
      }
    } catch (Throwable e) {
      LOG.fatal("Exception in namenode join", e);
      terminate(1, e);
    }
  }
 /** @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);
   }
 }
 /**
  * Like {@link terminate(int, String)} without a message.
  *
  * @param status
  * @throws ExitException if System.exit is disabled for test purposes
  */
 public static void terminate(int status) throws ExitException {
   terminate(status, "ExitException");
 }
 /**
  * Like {@link terminate(int, String)} but uses the given throwable to initialize the
  * ExitException.
  *
  * @param status
  * @param t throwable used to create the ExitException
  * @throws ExitException if System.exit is disabled for test purposes
  */
 public static void terminate(int status, Throwable t) throws ExitException {
   terminate(status, StringUtils.stringifyException(t));
 }
Exemple #7
0
  public static NameNode createNameNode(String argv[], Configuration conf) throws IOException {
    if (conf == null) {
      conf = new HdfsConfiguration();
    }
    StartupOption startOpt = parseArguments(argv);
    if (startOpt == null) {
      printUsage(System.err);
      return null;
    }
    setStartupOption(conf, startOpt);

    switch (startOpt) {
        // HOP
      case DROP_AND_CREATE_DB:
        { // delete everything other than inode and blocks table. this is tmp fix for safe mode
          dropAndCreateDB(conf);
          return null;
        }
      case FORMAT:
        {
          boolean aborted =
              format(conf, startOpt.getForceFormat(), startOpt.getInteractiveFormat());
          terminate(aborted ? 1 : 0);
          return null; // avoid javac warning
        }
      case GENCLUSTERID:
        {
          System.err.println("Generating new cluster id:");
          System.out.println(StorageInfo.newClusterID());
          terminate(0);
          return null;
        }
      case FINALIZE:
        {
          throw new UnsupportedOperationException("HOP: FINALIZE is not supported anymore");
        }
      case BOOTSTRAPSTANDBY:
        {
          throw new UnsupportedOperationException("HOP: BOOTSTRAPSTANDBY is not supported anymore");
        }
      case INITIALIZESHAREDEDITS:
        {
          throw new UnsupportedOperationException(
              "HOP: INITIALIZESHAREDEDITS is not supported anymore");
        }
      case BACKUP:
      case CHECKPOINT:
        {
          throw new UnsupportedOperationException(
              "HOP: BACKUP/CHECKPOINT is not supported anymore");
        }
      case RECOVER:
        {
          new UnsupportedOperationException("Hops. Metadata recovery is not supported");
          return null;
        }
      default:
        {
          DefaultMetricsSystem.initialize("NameNode");
          return new NameNode(conf);
        }
    }
  }