Package org.apache.hadoop.util.Shell

Examples of org.apache.hadoop.util.Shell.ShellCommandExecutor.execute()


    ShellCommandExecutor shExec = new ShellCommandExecutor(command);
    if (LOG.isDebugEnabled()) {
      LOG.debug("signalTask: " + Arrays.toString(command));
    }
    try {
      shExec.execute();
    } catch (ExitCodeException e) {
      int ret_code = shExec.getExitCode();
      if (ret_code != ResultCode.INVALID_TASK_PID.getValue()) {
        logOutput(shExec.getOutput());
        throw new IOException("Problem signalling task " + taskPid + " with " +
View Full Code Here


      }
    }
    ShellCommandExecutor shExec = new ShellCommandExecutor(taskControllerCmd);
   
    try {
      shExec.execute();
    } catch (Exception e) {
      LOG.warn("Exit code from " + taskControllerExe.toString() + " is : "
          + shExec.getExitCode() + " for truncateLogs");
      LOG.warn("Exception thrown by " + taskControllerExe.toString() + " : "
          + StringUtils.stringifyException(e));
View Full Code Here

    } else {
      untarCommand.append(FileUtil.makeShellPath(inFile));
    }
    String[] shellCmd = { "bash", "-c", untarCommand.toString() };
    ShellCommandExecutor shexec = new ShellCommandExecutor(shellCmd);
    shexec.execute();
    int exitcode = shexec.getExitCode();
    if (exitcode != 0) {
      throw new IOException("Error untarring file " + inFile +
                  ". Tar process exited with exit code " + exitcode);
    }
View Full Code Here

    cmdBuf.append(perm).append(" ");
    cmdBuf.append(filename);
    String[] shellCmd = {"bash", "-c" ,cmdBuf.toString()};
    ShellCommandExecutor shExec = new ShellCommandExecutor(shellCmd);
    try {
      shExec.execute();
    }catch(IOException e) {
      if(LOG.isDebugEnabled()) {
        LOG.debug("Error while changing permission : " + filename
                  +" Exception: " + StringUtils.stringifyException(e));
      }
View Full Code Here

          dir = new File(userDir);
        }
        ShellCommandExecutor s = new ShellCommandExecutor(
            cmdList.toArray(new String[0]), dir);
        try {
          s.execute();
          allOutput.append(s.getOutput() + " ");
        } catch (Exception e) {
          LOG.warn("Exception: ", e);
          return null;
        }
View Full Code Here

     * @throws IOException
     */
    public void runScript(List<String> args, File dir) throws IOException {
      ShellCommandExecutor shexec =
              new ShellCommandExecutor(args.toArray(new String[0]), dir);
      shexec.execute();
      int exitCode = shexec.getExitCode();
      if (exitCode != 0) {
        throw new IOException("Task debug script exit with nonzero status of "
                              + exitCode + ".");
      }
View Full Code Here

 
  private void executeCommand(ArrayList<String> cmdArgs) throws IOException{
    String[] cmd = (String[]) cmdArgs.toArray(new String[cmdArgs.size()]);
    ShellCommandExecutor executor = new ShellCommandExecutor(cmd);
    LOG.info(executor.toString());
    executor.execute();
    String output = executor.getOutput();   
    if (!output.isEmpty()) { //getOutput() never returns null value
      if (output.toLowerCase().contains("error")) {
        LOG.warn("Error is detected.");
        throw new IOException("Start error\n" + output);
View Full Code Here

      targetWorkDir.mkdirs();

      ShellCommandExecutor shexec = new ShellCommandExecutor(
        Shell.getSymlinkCommand(targetPath, linkPath));
      try {
        shexec.execute();
      } catch (IOException e) {
        throw new YarnRuntimeException(String.format(
          "failed to create symlink from %s to %s, shell output: %s", linkPath,
          targetPath, shexec.getOutput()), e);
      }
View Full Code Here

    for (int i = 0; i < inputFiles.length; i++) {
      tarCommand.append(" " + inputFiles[i]);
    }
    String[] shellCmd = {"bash", "-c", tarCommand.toString()};
    ShellCommandExecutor shexec = new ShellCommandExecutor(shellCmd);
    shexec.execute();
    int exitcode = shexec.getExitCode();
    if (exitcode != 0) {
      throw new IOException("Error tarring file " + outputFile
          + ". Tar process exited with exit code " + exitcode);
    }
View Full Code Here

      ShellCommandExecutor shexec = null;
      boolean setsidSupported = true;
      try {
        String[] args = {"setsid", "bash", "-c", "echo $$"};
        shexec = new ShellCommandExecutor(args);
        shexec.execute();
      } catch (IOException ioe) {
        LOG.warn("setsid is not available on this machine. So not using it.");
        setsidSupported = false;
      } finally { // handle the exit code
        LOG.info("setsid exited with exit code " + shexec.getExitCode());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.