当前位置: 首页>>代码示例>>Java>>正文


Java Signal.KILL属性代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor.Signal.KILL属性的典型用法代码示例。如果您正苦于以下问题:Java Signal.KILL属性的具体用法?Java Signal.KILL怎么用?Java Signal.KILL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor.Signal的用法示例。


在下文中一共展示了Signal.KILL属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: translateCommandToSignal

@VisibleForTesting
public static Signal translateCommandToSignal(
    SignalContainerCommand command) {
  Signal signal = Signal.NULL;
  switch (command) {
    case OUTPUT_THREAD_DUMP:
      // TODO for windows support.
      signal = Shell.WINDOWS ? Signal.NULL: Signal.QUIT;
      break;
    case GRACEFUL_SHUTDOWN:
      signal = Signal.TERM;
      break;
    case FORCEFUL_SHUTDOWN:
      signal = Signal.KILL;
      break;
  }
  return signal;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:18,代码来源:ContainerLaunch.java

示例2: cleanupContainer

/**
 * Cleanup the container.
 * Cancels the launch if launch has not started yet or signals
 * the executor to not execute the process if not already done so.
 * Also, sends a SIGTERM followed by a SIGKILL to the process if
 * the process id is available.
 * @throws IOException
 */
@SuppressWarnings("unchecked") // dispatcher not typed
public void cleanupContainer() throws IOException {
  ContainerId containerId = container.getContainerId();
  String containerIdStr = ConverterUtils.toString(containerId);
  LOG.info("Cleaning up container " + containerIdStr);

  // launch flag will be set to true if process already launched
  boolean alreadyLaunched = !shouldLaunchContainer.compareAndSet(false, true);
  if (!alreadyLaunched) {
    LOG.info("Container " + containerIdStr + " not launched."
        + " No cleanup needed to be done");
    return;
  }

  LOG.debug("Marking container " + containerIdStr + " as inactive");
  // this should ensure that if the container process has not launched 
  // by this time, it will never be launched
  exec.deactivateContainer(containerId);

  if (LOG.isDebugEnabled()) {
    LOG.debug("Getting pid for container " + containerIdStr + " to kill"
        + " from pid file " 
        + (pidFilePath != null ? pidFilePath.toString() : "null"));
  }
  
  // however the container process may have already started
  try {

    // get process id from pid file if available
    // else if shell is still active, get it from the shell
    String processId = null;
    if (pidFilePath != null) {
      processId = getContainerPid(pidFilePath);
    }

    // kill process
    if (processId != null) {
      String user = container.getUser();
      LOG.debug("Sending signal to pid " + processId
          + " as user " + user
          + " for container " + containerIdStr);

      final Signal signal = sleepDelayBeforeSigKill > 0
        ? Signal.TERM
        : Signal.KILL;

      boolean result = exec.signalContainer(user, processId, signal);

      LOG.debug("Sent signal " + signal + " to pid " + processId
        + " as user " + user
        + " for container " + containerIdStr
        + ", result=" + (result? "success" : "failed"));

      if (sleepDelayBeforeSigKill > 0) {
        new DelayedProcessKiller(container, user,
            processId, sleepDelayBeforeSigKill, Signal.KILL, exec).start();
      }
    }
  } catch (Exception e) {
    String message =
        "Exception when trying to cleanup container " + containerIdStr
            + ": " + StringUtils.stringifyException(e);
    LOG.warn(message);
    dispatcher.getEventHandler().handle(
      new ContainerDiagnosticsUpdateEvent(containerId, message));
  } finally {
    // cleanup pid file if present
    if (pidFilePath != null) {
      FileContext lfs = FileContext.getLocalFSFileContext();
      lfs.delete(pidFilePath, false);
    }
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:81,代码来源:ContainerLaunch.java


注:本文中的org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor.Signal.KILL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。