gpt4 book ai didi

org.apache.hadoop.yarn.YarnUncaughtExceptionHandler类的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 09:40:40 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.yarn.YarnUncaughtExceptionHandler类的一些代码示例,展示了YarnUncaughtExceptionHandler类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YarnUncaughtExceptionHandler类的具体详情如下:
包路径:org.apache.hadoop.yarn.YarnUncaughtExceptionHandler
类名称:YarnUncaughtExceptionHandler

YarnUncaughtExceptionHandler介绍

[英]This class is intended to be installed by calling Thread#setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler)In the main entry point. It is intended to try and cleanly shut down programs using the YARN Event framework. Note: Right now it only will shut down the program if a Error is caught, but not any other exception. Anything else is just logged.
[中]此类旨在通过在主入口点中调用线程#setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler)来安装。它旨在尝试并彻底关闭使用Thread事件框架的程序。注意:现在它只会在发现错误时关闭程序,而不会关闭任何其他异常。其他任何东西都会被记录下来。

代码示例

代码示例来源:origin: Qihoo360/XLearning

static JobHistoryServer launchJobHistoryServer(String[] args) {
 Thread.
   setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
 StringUtils.startupShutdownMessage(JobHistoryServer.class, args, LOG);
 JobHistoryServer jobHistoryServer = null;
 try {
  jobHistoryServer = new JobHistoryServer();
  ShutdownHookManager.get().addShutdownHook(
    new CompositeServiceShutdownHook(jobHistoryServer),
    SHUTDOWN_HOOK_PRIORITY);
  YarnConfiguration conf = new YarnConfiguration(new JobConf());
  new GenericOptionsParser(conf, args);
  jobHistoryServer.init(conf);
  jobHistoryServer.start();
 } catch (Throwable t) {
  LOG.fatal("Error starting JobHistoryServer", t);
  ExitUtil.terminate(-1, "Error starting JobHistoryServer");
 }
 return jobHistoryServer;
}

代码示例来源:origin: io.hops/hadoop-yarn-common

/**
 * Throw {@code YarnRuntimeException} inside thread and
 * check {@code YarnUncaughtExceptionHandler} instance
 *
 * @throws InterruptedException
 */
@Test
public void testUncaughtExceptionHandlerWithRuntimeException()
  throws InterruptedException {
 final YarnUncaughtExceptionHandler spyYarnHandler = spy(exHandler);
 final YarnRuntimeException yarnException = new YarnRuntimeException(
   "test-yarn-runtime-exception");
 final Thread yarnThread = new Thread(new Runnable() {
  @Override
  public void run() {
   throw yarnException;
  }
 });
 yarnThread.setUncaughtExceptionHandler(spyYarnHandler);
 assertSame(spyYarnHandler, yarnThread.getUncaughtExceptionHandler());
 yarnThread.start();
 yarnThread.join();
 verify(spyYarnHandler).uncaughtException(yarnThread, yarnException);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-common

/**
 * <p>
 * Throw {@code Error} inside thread and
 * check {@code YarnUncaughtExceptionHandler} instance
 * <p>
 * Used {@code ExitUtil} class to avoid jvm exit through
 * {@code System.exit(-1) }
 *
 * @throws InterruptedException
 */
@Test
public void testUncaughtExceptionHandlerWithError()
  throws InterruptedException {
 ExitUtil.disableSystemExit();
 final YarnUncaughtExceptionHandler spyErrorHandler = spy(exHandler);
 final java.lang.Error error = new java.lang.Error("test-error");
 final Thread errorThread = new Thread(new Runnable() {
  @Override
  public void run() {
   throw error;
  }
 });
 errorThread.setUncaughtExceptionHandler(spyErrorHandler);
 assertSame(spyErrorHandler, errorThread.getUncaughtExceptionHandler());
 errorThread.start();
 errorThread.join();
 verify(spyErrorHandler).uncaughtException(errorThread, error);
}

代码示例来源:origin: org.apache.slider/slider-core

/**
 * The real main function, which takes the arguments as a list
 * arg 0 must be the service classname
 * @param argsList the list of arguments
 */
public static void serviceMain(List<String> argsList) {
 if (argsList.isEmpty()) {
  exitWithMessage(EXIT_USAGE, USAGE_MESSAGE);
 } else {
  String serviceClassName = argsList.get(0);
  if (LOG.isDebugEnabled()) {
   LOG.debug(startupShutdownMessage(serviceClassName, argsList));
   StringBuilder builder = new StringBuilder();
   for (String arg : argsList) {
    builder.append('"').append(arg).append("\" ");
   }
   LOG.debug(builder.toString());
  }
  Thread.setDefaultUncaughtExceptionHandler(
   new YarnUncaughtExceptionHandler());
  ServiceLauncher serviceLauncher = new ServiceLauncher<>(serviceClassName);
  serviceLauncher.launchServiceAndExit(argsList);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

/**
 * Throw {@code YarnRuntimeException} inside thread and
 * check {@code YarnUncaughtExceptionHandler} instance
 *
 * @throws InterruptedException
 */
@Test
public void testUncaughtExceptionHandlerWithRuntimeException()
  throws InterruptedException {
 final YarnUncaughtExceptionHandler spyYarnHandler = spy(exHandler);
 final YarnRuntimeException yarnException = new YarnRuntimeException(
   "test-yarn-runtime-exception");
 final Thread yarnThread = new Thread(new Runnable() {
  @Override
  public void run() {
   throw yarnException;
  }
 });
 yarnThread.setUncaughtExceptionHandler(spyYarnHandler);
 assertSame(spyYarnHandler, yarnThread.getUncaughtExceptionHandler());
 yarnThread.start();
 yarnThread.join();
 verify(spyYarnHandler).uncaughtException(yarnThread, yarnException);
}

代码示例来源:origin: apache/incubator-slider

/**
 * The real main function, which takes the arguments as a list
 * arg 0 must be the service classname
 * @param argsList the list of arguments
 */
public static void serviceMain(List<String> argsList) {
 if (argsList.isEmpty()) {
  exitWithMessage(EXIT_USAGE, USAGE_MESSAGE);
 } else {
  String serviceClassName = argsList.get(0);
  if (LOG.isDebugEnabled()) {
   LOG.debug(startupShutdownMessage(serviceClassName, argsList));
   StringBuilder builder = new StringBuilder();
   for (String arg : argsList) {
    builder.append('"').append(arg).append("\" ");
   }
   LOG.debug(builder.toString());
  }
  Thread.setDefaultUncaughtExceptionHandler(
   new YarnUncaughtExceptionHandler());
  ServiceLauncher serviceLauncher = new ServiceLauncher<>(serviceClassName);
  serviceLauncher.launchServiceAndExit(argsList);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-common

/**
  * <p>
  * Throw {@code OutOfMemoryError} inside thread and
  * check {@code YarnUncaughtExceptionHandler} instance
  * <p>
  * Used {@code ExitUtil} class to avoid jvm exit through
  * {@code Runtime.getRuntime().halt(-1)}
  *
  * @throws InterruptedException
  */
 @Test
 public void testUncaughtExceptionHandlerWithOutOfMemoryError()
   throws InterruptedException {
  ExitUtil.disableSystemHalt();
  final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler);
  final OutOfMemoryError oomError = new OutOfMemoryError("out-of-memory-error");
  final Thread oomThread = new Thread(new Runnable() {
   @Override
   public void run() {
    throw oomError;
   }
  });
  oomThread.setUncaughtExceptionHandler(spyOomHandler);
  assertSame(spyOomHandler, oomThread.getUncaughtExceptionHandler());
  oomThread.start();
  oomThread.join();
  verify(spyOomHandler).uncaughtException(oomThread, oomError);
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-nodemanager

public static void main(String[] argv) throws Throwable {
 Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

/**
 * <p>
 * Throw {@code Error} inside thread and
 * check {@code YarnUncaughtExceptionHandler} instance
 * <p>
 * Used {@code ExitUtil} class to avoid jvm exit through
 * {@code System.exit(-1) }
 *
 * @throws InterruptedException
 */
@Test
public void testUncaughtExceptionHandlerWithError()
  throws InterruptedException {
 ExitUtil.disableSystemExit();
 final YarnUncaughtExceptionHandler spyErrorHandler = spy(exHandler);
 final java.lang.Error error = new java.lang.Error("test-error");
 final Thread errorThread = new Thread(new Runnable() {
  @Override
  public void run() {
   throw error;
  }
 });
 errorThread.setUncaughtExceptionHandler(spyErrorHandler);
 assertSame(spyErrorHandler, errorThread.getUncaughtExceptionHandler());
 errorThread.start();
 errorThread.join();
 verify(spyErrorHandler).uncaughtException(errorThread, error);
}

代码示例来源:origin: io.hops/hadoop-yarn-server-nodemanager

public static void main(String[] argv) throws Throwable {
 Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

/**
  * <p>
  * Throw {@code OutOfMemoryError} inside thread and
  * check {@code YarnUncaughtExceptionHandler} instance
  * <p>
  * Used {@code ExitUtil} class to avoid jvm exit through
  * {@code Runtime.getRuntime().halt(-1)}
  *
  * @throws InterruptedException
  */
 @Test
 public void testUncaughtExceptionHandlerWithOutOfMemoryError()
   throws InterruptedException {
  ExitUtil.disableSystemHalt();
  final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler);
  final OutOfMemoryError oomError = new OutOfMemoryError("out-of-memory-error");
  final Thread oomThread = new Thread(new Runnable() {
   @Override
   public void run() {
    throw oomError;
   }
  });
  oomThread.setUncaughtExceptionHandler(spyOomHandler);
  assertSame(spyOomHandler, oomThread.getUncaughtExceptionHandler());
  oomThread.start();
  oomThread.join();
  verify(spyOomHandler).uncaughtException(oomThread, oomError);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-nodemanager

public static void main(String[] argv) throws Throwable {
 Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());

代码示例来源:origin: io.hops/hadoop-yarn-common

/**
 * <p>
 * Throw {@code Error} inside thread and
 * check {@code YarnUncaughtExceptionHandler} instance
 * <p>
 * Used {@code ExitUtil} class to avoid jvm exit through
 * {@code System.exit(-1) }
 *
 * @throws InterruptedException
 */
@Test
public void testUncaughtExceptionHandlerWithError()
  throws InterruptedException {
 ExitUtil.disableSystemExit();
 final YarnUncaughtExceptionHandler spyErrorHandler = spy(exHandler);
 final java.lang.Error error = new java.lang.Error("test-error");
 final Thread errorThread = new Thread(new Runnable() {
  @Override
  public void run() {
   throw error;
  }
 });
 errorThread.setUncaughtExceptionHandler(spyErrorHandler);
 assertSame(spyErrorHandler, errorThread.getUncaughtExceptionHandler());
 errorThread.start();
 errorThread.join();
 verify(spyErrorHandler).uncaughtException(errorThread, error);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-nodemanager

public static void main(String[] argv) throws Throwable {
 Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
 int nRet = 0;

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-common

/**
 * Throw {@code YarnRuntimeException} inside thread and
 * check {@code YarnUncaughtExceptionHandler} instance
 *
 * @throws InterruptedException
 */
@Test
public void testUncaughtExceptionHandlerWithRuntimeException()
  throws InterruptedException {
 final YarnUncaughtExceptionHandler spyYarnHandler = spy(exHandler);
 final YarnRuntimeException yarnException = new YarnRuntimeException(
   "test-yarn-runtime-exception");
 final Thread yarnThread = new Thread(new Runnable() {
  @Override
  public void run() {
   throw yarnException;
  }
 });
 yarnThread.setUncaughtExceptionHandler(spyYarnHandler);
 assertSame(spyYarnHandler, yarnThread.getUncaughtExceptionHandler());
 yarnThread.start();
 yarnThread.join();
 verify(spyYarnHandler).uncaughtException(yarnThread, yarnException);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-nodemanager

public static void main(String[] args) throws IOException {
 Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
 StringUtils.startupShutdownMessage(NodeManager.class, args, LOG);
 @SuppressWarnings("resource")
 NodeManager nodeManager = new NodeManager();
 Configuration conf = new YarnConfiguration();
 new GenericOptionsParser(conf, args);
 nodeManager.initAndStartNodeManager(conf, false);
}

代码示例来源:origin: io.hops/hadoop-yarn-common

/**
  * <p>
  * Throw {@code OutOfMemoryError} inside thread and
  * check {@code YarnUncaughtExceptionHandler} instance
  * <p>
  * Used {@code ExitUtil} class to avoid jvm exit through
  * {@code Runtime.getRuntime().halt(-1)}
  *
  * @throws InterruptedException
  */
 @Test
 public void testUncaughtExceptionHandlerWithOutOfMemoryError()
   throws InterruptedException {
  ExitUtil.disableSystemHalt();
  final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler);
  final OutOfMemoryError oomError = new OutOfMemoryError("out-of-memory-error");
  final Thread oomThread = new Thread(new Runnable() {
   @Override
   public void run() {
    throw oomError;
   }
  });
  oomThread.setUncaughtExceptionHandler(spyOomHandler);
  assertSame(spyOomHandler, oomThread.getUncaughtExceptionHandler());
  oomThread.start();
  oomThread.join();
  verify(spyOomHandler).uncaughtException(oomThread, oomError);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-nodemanager

public static void main(String[] args) throws IOException {
 Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
 StringUtils.startupShutdownMessage(NodeManager.class, args, LOG);
 NodeManager nodeManager = new NodeManager();
 Configuration conf = new YarnConfiguration();
 new GenericOptionsParser(conf, args);
 nodeManager.initAndStartNodeManager(conf, false);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-nodemanager

public static void main(String[] args) throws IOException {
 Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
 StringUtils.startupShutdownMessage(NodeManager.class, args, LOG);
 NodeManager nodeManager = new NodeManager();
 Configuration conf = new YarnConfiguration();
 new GenericOptionsParser(conf, args);
 nodeManager.initAndStartNodeManager(conf, false);
}

代码示例来源:origin: io.hops/hadoop-yarn-server-nodemanager

public static void main(String[] args) throws IOException {
 Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
 StringUtils.startupShutdownMessage(NodeManager.class, args, LOG);
 NodeManager nodeManager = new NodeManager();
 Configuration conf = new YarnConfiguration();
 new GenericOptionsParser(conf, args);
 nodeManager.initAndStartNodeManager(conf, false);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com