Examples of PumpStreamHandler


Examples of gov.lanl.util.PumpStreamHandler

        try {
            final String command = getKduExtractCommand(input, output, dims, params);
            final Process process = Runtime.getRuntime().exec(command, envParams, new File(env));
            ByteArrayOutputStream stdout = new ByteArrayOutputStream();
            ByteArrayOutputStream stderr = new ByteArrayOutputStream();
            ExecuteStreamHandler streamHandler = new PumpStreamHandler(stdout, stderr, is);
            try {
                streamHandler.setProcessInputStream(process.getOutputStream());
                streamHandler.setProcessOutputStream(process.getInputStream());
                streamHandler.setProcessErrorStream(process.getErrorStream());
            } catch (IOException e) {
                logger.error(e, e);
                if (process != null) {
                    closeStreams(process);
                }
                throw e;
            }
            streamHandler.start();

            try {
                waitFor(process);
                final ByteArrayInputStream bais = new ByteArrayInputStream(stdout.toByteArray());
                bi = new PNMReader().open(bais);
                streamHandler.stop();
            } catch (ThreadDeath t) {
                logger.error(t, t);
                process.destroy();
                throw t;
            } finally {
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

        String tmStr = config.getProperty(PROP_EXIT_TIMEOUT_SECONDS);
        final int exitTimeoutSeconds = tmStr == null ? DEFAULT_EXIT_TIMEOUT : Integer.valueOf(tmStr);

        log.info("Executing " + cl);
        executor.setStreamHandler(new PumpStreamHandler());
        final ShutdownHookSingleProcessDestroyer pd = new ShutdownHookSingleProcessDestroyer("java -jar " + jarToExecute.getName(), exitTimeoutSeconds);
        final boolean waitOnShutdown = Boolean.valueOf(config.getProperty(PROP_WAIT_ONSHUTDOWN, "false"));
        log.info("Setting up ProcessDestroyer with waitOnShutdown=" + waitOnShutdown);
        pd.setWaitOnShutdown(waitOnShutdown);
        executor.setProcessDestroyer(pd);
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

          }
        }
      }
    };
   
    streamHandler = new PumpStreamHandler(outStream, errStream);
   
    executor = new DefaultExecutor();
    executor.setStreamHandler(streamHandler);

  }
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

        Executor exec = new DefaultExecutor();
        Map<String, String> env = new HashMap<String, String>(System.getenv());
//        env.put("path", ";");
//        env.put("path", System.getProperty("java.home"));

        ExecuteStreamHandler handler = new PumpStreamHandler(System.out, System.err, System.in);
        exec.setStreamHandler(handler);
        exec.setWorkingDirectory(getWorkingDirectory());

        int status;
        try {
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

      if(this.writerStdIn)
      {
        this.bais = new ByteArrayInputStream(in.getText().getBytes());

        executor.setStreamHandler(new PumpStreamHandler(this.baos, this.baosErr, this.bais));
      }
      else
      {
        executor.setStreamHandler(new PumpStreamHandler(this.baos, this.baosErr));
      }

      executor.setWatchdog(watchdog);

      executor.execute(commandLine, new ExecuteResultHandler(){
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

    private String exec(File workingDir, org.apache.commons.exec.CommandLine cmdLine) throws Exception {
        Executor executor = new DefaultExecutor();
        org.apache.commons.io.output.ByteArrayOutputStream buffer = new org.apache.commons.io.output.ByteArrayOutputStream();
        NullOutputStream nullOs = new NullOutputStream();
        PumpStreamHandler streamHandler = new PumpStreamHandler(nullOs, buffer);
        executor.setWorkingDirectory(workingDir);
        executor.setStreamHandler(streamHandler);
        String result = "";

        try {
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

    }

    protected void killPid(String pid) throws IOException {
        Executor executor = new DefaultExecutor();
        executor.setWorkingDirectory(getBinDir());
        PumpStreamHandler streamHandler = new PumpStreamHandler(createNullOutputStream(), createNullOutputStream());
        executor.setStreamHandler(streamHandler);
        org.apache.commons.exec.CommandLine commandLine;

        commandLine = new org.apache.commons.exec.CommandLine("kill").addArgument(pid);
        executor.execute(commandLine);
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

    protected boolean isUnixPidRunning(String pid) {

        Executor executor = new DefaultExecutor();
        executor.setWorkingDirectory(getBinDir());
        PumpStreamHandler streamHandler = new PumpStreamHandler(createNullOutputStream(), createNullOutputStream());
        executor.setStreamHandler(streamHandler);
        org.apache.commons.exec.CommandLine commandLine;
        commandLine = new org.apache.commons.exec.CommandLine("kill").addArgument("-0").addArgument(pid);

        boolean isRunning = true; // assume it is running
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

    cmdLine.addArguments(pid);
    final Executor executor = new DefaultExecutor();
    executor.setExitValue(1);
    final DefaultExecuteResultHandler derh = new DefaultExecuteResultHandler();
//    executor.setProcessDestroyer(MPlayerFileService.PROCESS_SHUTDOWN_HOOK);
    executor.setStreamHandler(new PumpStreamHandler(out, err));
    try {
      logger.info("execute " + kill_cmd_log + " " + pid);
      executor.execute(cmdLine, derh);
      derh.waitFor();
      return true;
View Full Code Here

Examples of org.apache.commons.exec.PumpStreamHandler

    final Executor executor = new DefaultExecutor();
    executor.setExitValue(1);

    final DefaultExecuteResultHandler derh = new DefaultExecuteResultHandler();
    executor.setProcessDestroyer(MPlayerFileService.PROCESS_SHUTDOWN_HOOK);
    executor.setStreamHandler(new PumpStreamHandler(out, err));
    try {
      logger.info("execute " + list_cmd_log);
      executor.execute(cmdLine, derh);
      derh.waitFor();
     
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.