Java 类org.apache.hadoop.mapred.pipes.Submitter 实例源码

项目:mapreduce-fork    文件:TaskTracker.java   
/**
 * Run the debug-script now. Because debug-script can be user code, we use
 * {@link TaskController} to execute the debug script.
 * 
 * @throws IOException
 */
private void runDebugScript() throws IOException {
  String taskStdout ="";
  String taskStderr ="";
  String taskSyslog ="";
  String jobConf = task.getJobFile();
  try {
    // get task's stdout file 
    taskStdout = FileUtil
        .makeShellPath(TaskLog.getRealTaskLogFileLocation(task.getTaskID(),
            task.isTaskCleanupTask(), TaskLog.LogName.STDOUT));
    // get task's stderr file
    taskStderr = FileUtil
        .makeShellPath(TaskLog.getRealTaskLogFileLocation(task.getTaskID(),
            task.isTaskCleanupTask(), TaskLog.LogName.STDERR));
    // get task's syslog file
    taskSyslog = FileUtil
        .makeShellPath(TaskLog.getRealTaskLogFileLocation(task.getTaskID(),
            task.isTaskCleanupTask(), TaskLog.LogName.SYSLOG));
  } catch(Exception e){
    LOG.warn("Exception finding task's stdout/err/syslog files", e);
  }
  File workDir = new File(lDirAlloc.getLocalPathToRead(
      TaskTracker.getLocalTaskDir(task.getUser(), task.getJobID()
          .toString(), task.getTaskID().toString(), task
          .isTaskCleanupTask())
          + Path.SEPARATOR + MRConstants.WORKDIR, localJobConf).toString());
  // Build the command  
  File stdout = TaskLog.getTaskLogFile(task.getTaskID(), task
      .isTaskCleanupTask(), TaskLog.LogName.DEBUGOUT);
  // add pipes program as argument if it exists.
  String program ="";
  String executable = Submitter.getExecutable(localJobConf);
  if ( executable != null) {
    try {
      program = new URI(executable).getFragment();
    } catch (URISyntaxException ur) {
      LOG.warn("Problem in the URI fragment for pipes executable");
    }     
  }
  String [] debug = debugCommand.split(" ");
  List<String> vargs = new ArrayList<String>();
  for (String component : debug) {
    vargs.add(component);
  }
  vargs.add(taskStdout);
  vargs.add(taskStderr);
  vargs.add(taskSyslog);
  vargs.add(jobConf);
  vargs.add(program);
  DebugScriptContext context = 
    new TaskController.DebugScriptContext();
  context.args = vargs;
  context.stdout = stdout;
  context.workDir = workDir;
  context.task = task;
  getTaskController().runDebugScript(context);
  // add the lines of debug out to diagnostics
  int num = localJobConf.getInt(MRJobConfig.TASK_DEBUGOUT_LINES, -1);
  addDiagnostics(FileUtil.makeShellPath(stdout), num, "DEBUG OUT");
}