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


Java ProcessTree类代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.util.ProcessTree的典型用法代码示例。如果您正苦于以下问题:Java ProcessTree类的具体用法?Java ProcessTree怎么用?Java ProcessTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: terminateTask

import org.apache.hadoop.mapreduce.util.ProcessTree; //导入依赖的package包/类
@Override
void terminateTask(TaskControllerContext context) {
  ShellCommandExecutor shexec = context.shExec;
  if (shexec != null) {
    Process process = shexec.getProcess();
    if (Shell.WINDOWS) {
      // Currently we don't use setsid on WINDOWS. 
      //So kill the process alone.
      if (process != null) {
        process.destroy();
      }
    }
    else { // In addition to the task JVM, kill its subprocesses also.
      String pid = context.pid;
      if (pid != null) {
        if(ProcessTree.isSetsidAvailable) {
          ProcessTree.terminateProcessGroup(pid);
        }else {
          ProcessTree.terminateProcess(pid);
        }
      }
    }
  }
}
 
开发者ID:rekhajoshm,项目名称:mapreduce-fork,代码行数:25,代码来源:DefaultTaskController.java

示例2: killTask

import org.apache.hadoop.mapreduce.util.ProcessTree; //导入依赖的package包/类
@Override
void killTask(TaskControllerContext context) {
  ShellCommandExecutor shexec = context.shExec;
  if (shexec != null) {
    if (Shell.WINDOWS) {
      //We don't do send kill process signal in case of windows as 
      //already we have done a process.destroy() in terminateTaskJVM()
      return;
    }
    String pid = context.pid;
    if (pid != null) {
      if(ProcessTree.isSetsidAvailable) {
        ProcessTree.killProcessGroup(pid);
      } else {
        ProcessTree.killProcess(pid);
      }
    }
  }
}
 
开发者ID:rekhajoshm,项目名称:mapreduce-fork,代码行数:20,代码来源:DefaultTaskController.java

示例3: dumpTaskStack

import org.apache.hadoop.mapreduce.util.ProcessTree; //导入依赖的package包/类
@Override
void dumpTaskStack(TaskControllerContext context) {
  ShellCommandExecutor shexec = context.shExec;
  if (shexec != null) {
    if (Shell.WINDOWS) {
      // We don't use signals in Windows.
      return;
    }
    String pid = context.pid;
    if (pid != null) {
      // Send SIGQUIT to get a stack dump
      if (ProcessTree.isSetsidAvailable) {
        ProcessTree.sigQuitProcessGroup(pid);
      } else {
        ProcessTree.sigQuitProcess(pid);
      }
    }
  }
}
 
开发者ID:rekhajoshm,项目名称:mapreduce-fork,代码行数:20,代码来源:DefaultTaskController.java

示例4: JvmRunner

import org.apache.hadoop.mapreduce.util.ProcessTree; //导入依赖的package包/类
public JvmRunner(JvmEnv env, JobID jobId) {
  this.env = env;
  this.jvmId = new JVMId(jobId, isMap, rand.nextInt());
  this.numTasksToRun = env.conf.getNumTasksToExecutePerJvm();

  this.initalContext = new TaskControllerContext();
  initalContext.sleeptimeBeforeSigkill = tracker.getJobConf()
    .getLong(TTConfig.TT_SLEEP_TIME_BEFORE_SIG_KILL,
             ProcessTree.DEFAULT_SLEEPTIME_BEFORE_SIGKILL);
  LOG.info("In JvmRunner constructed JVM ID: " + jvmId);
}
 
开发者ID:rekhajoshm,项目名称:mapreduce-fork,代码行数:12,代码来源:JvmManager.java

示例5: buildCommandLine

import org.apache.hadoop.mapreduce.util.ProcessTree; //导入依赖的package包/类
/**
 * Construct the command line for running the task JVM
 * @param setup The setup commands for the execed process.
 * @param cmd The command and the arguments that should be run
 * @param stdoutFilename The filename that stdout should be saved to
 * @param stderrFilename The filename that stderr should be saved to
 * @param tailLength The length of the tail to be saved.
 * @return the command line as a String
 * @throws IOException
 */
static String buildCommandLine(List<String> setup, List<String> cmd, 
                                    File stdoutFilename,
                                    File stderrFilename,
                                    long tailLength, 
                                    boolean useSetsid)
                              throws IOException {
  
  String stdout = FileUtil.makeShellPath(stdoutFilename);
  String stderr = FileUtil.makeShellPath(stderrFilename);    
  StringBuffer mergedCmd = new StringBuffer();
  
  // Export the pid of taskJvm to env variable JVM_PID.
  // Currently pid is not used on Windows
  if (!Shell.WINDOWS) {
    mergedCmd.append(" export JVM_PID=`echo $$` ; ");
  }

  if (setup != null && setup.size() > 0) {
    mergedCmd.append(addCommand(setup, false));
    mergedCmd.append(";");
  }
  if (tailLength > 0) {
    mergedCmd.append("(");
  } else if(ProcessTree.isSetsidAvailable && useSetsid &&
      !Shell.WINDOWS) {
    mergedCmd.append("exec setsid ");
  } else {
    mergedCmd.append("exec ");
  }
  mergedCmd.append(addCommand(cmd, true));
  mergedCmd.append(" < /dev/null ");
  if (tailLength > 0) {
    mergedCmd.append(" | ");
    mergedCmd.append(tailCommand);
    mergedCmd.append(" -c ");
    mergedCmd.append(tailLength);
    mergedCmd.append(" >> ");
    mergedCmd.append(stdout);
    mergedCmd.append(" ; exit $PIPESTATUS ) 2>&1 | ");
    mergedCmd.append(tailCommand);
    mergedCmd.append(" -c ");
    mergedCmd.append(tailLength);
    mergedCmd.append(" >> ");
    mergedCmd.append(stderr);
    mergedCmd.append(" ; exit $PIPESTATUS");
  } else {
    mergedCmd.append(" 1>> ");
    mergedCmd.append(stdout);
    mergedCmd.append(" 2>> ");
    mergedCmd.append(stderr);
  }
  return mergedCmd.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:64,代码来源:TaskLog.java


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