Examples of StreamCopyThread


Examples of hudson.util.StreamCopyThread

           
            final Process proc = _proc = pb.start();

            // capture error information from stderr. this will terminate itself
            // when the process is killed.
            new StreamCopyThread("stderr copier for remote agent on " + computer.getDisplayName(),
                    proc.getErrorStream(), listener.getLogger()).start();

            computer.setChannel(proc.getInputStream(), proc.getOutputStream(), listener.getLogger(), new Channel.Listener() {
                @Override
                public void onClosed(Channel channel, IOException cause) {
View Full Code Here

Examples of hudson.util.StreamCopyThread

            this.name = name;
            this.out = out;
            this.cookie = EnvVars.createCookie();
            procBuilder.environment().putAll(cookie);
            this.proc = procBuilder.start();
            copier = new StreamCopyThread(name+": stdout copier", proc.getInputStream(), out);
            copier.start();
            if(in!=null)
                new StdinCopyThread(name+": stdin copier",in,proc.getOutputStream()).start();
            else
                proc.getOutputStream().close();
            if(err!=null) {
                copier2 = new StreamCopyThread(name+": stderr copier", proc.getErrorStream(), err);
                copier2.start();
            } else {
                // while this is not discussed in javadoc, even with ProcessBuilder.redirectErrorStream(true),
                // Process.getErrorStream() still returns a distinct reader end of a pipe that needs to be closed.
                // this is according to the source code of JVM
View Full Code Here

Examples of hudson.util.StreamCopyThread

        } catch (JIException e) {
            throw new IOException2(e);
        } catch (InterruptedException e) {
            throw new IOException2(e);
        }
        final Thread t1 = new StreamCopyThread("stdout copier: "+name, proc.getInputStream(), ps.stdout(),false);
        t1.start();
        final Thread t2 = new StreamCopyThread("stdin copier: "+name,ps.stdin(), proc.getOutputStream(),true);
        t2.start();

        return new Proc() {
            public boolean isAlive() throws IOException, InterruptedException {
                try {
                    proc.exitValue();
                    return false;
                } catch (IllegalThreadStateException e) {
                    return true;
                }
            }

            public void kill() throws IOException, InterruptedException {
                t1.interrupt();
                t2.interrupt();
                proc.destroy();
            }

            public int join() throws IOException, InterruptedException {
                try {
                    t1.join();
                    t2.join();
                    return proc.waitFor();
                } finally {
                    proc.destroy();
                }
            }
View Full Code Here

Examples of org.eclipse.jgit.util.io.StreamCopyThread

      setMessageWriter(msg);

      uploadPack = spawn(getOptionUploadPack());

      final InputStream upErr = uploadPack.getErrorStream();
      errorReaderThread = new StreamCopyThread(upErr, msg.getRawStream());
      errorReaderThread.start();

      InputStream upIn = uploadPack.getInputStream();
      OutputStream upOut = uploadPack.getOutputStream();
View Full Code Here

Examples of org.eclipse.jgit.util.io.StreamCopyThread

      setMessageWriter(msg);

      receivePack = spawn(getOptionReceivePack());

      final InputStream rpErr = receivePack.getErrorStream();
      errorReaderThread = new StreamCopyThread(rpErr, msg.getRawStream());
      errorReaderThread.start();

      InputStream rpIn = receivePack.getInputStream();
      OutputStream rpOut = receivePack.getOutputStream();
View Full Code Here

Examples of org.eclipse.jgit.util.io.StreamCopyThread

      setMessageWriter(msg);

      uploadPack = spawn(getOptionUploadPack());

      final InputStream upErr = uploadPack.getErrorStream();
      errorReaderThread = new StreamCopyThread(upErr, msg.getRawStream());
      errorReaderThread.start();

      InputStream upIn = uploadPack.getInputStream();
      OutputStream upOut = uploadPack.getOutputStream();
View Full Code Here

Examples of org.eclipse.jgit.util.io.StreamCopyThread

      setMessageWriter(msg);

      receivePack = spawn(getOptionReceivePack());

      final InputStream rpErr = receivePack.getErrorStream();
      errorReaderThread = new StreamCopyThread(rpErr, msg.getRawStream());
      errorReaderThread.start();

      InputStream rpIn = receivePack.getInputStream();
      OutputStream rpOut = receivePack.getOutputStream();
View Full Code Here

Examples of org.eclipse.jgit.util.io.StreamCopyThread

            getTimeout());
        final MessageWriter msg = new MessageWriter();
        setMessageWriter(msg);

        final InputStream upErr = process.getErrorStream();
        errorThread = new StreamCopyThread(upErr, msg.getRawStream());
        errorThread.start();

        init(process.getInputStream(), process.getOutputStream());

      } catch (TransportException err) {
View Full Code Here

Examples of org.eclipse.jgit.util.io.StreamCopyThread

            getTimeout());
        final MessageWriter msg = new MessageWriter();
        setMessageWriter(msg);

        final InputStream rpErr = process.getErrorStream();
        errorThread = new StreamCopyThread(rpErr, msg.getRawStream());
        errorThread.start();

        init(process.getInputStream(), process.getOutputStream());

      } catch (TransportException err) {
View Full Code Here

Examples of org.eclipse.jgit.util.io.StreamCopyThread

      final OutputStream out = channel.getOutputStream();
      if (timeout <= 0) {
        outputStream = out;
      } else {
        final PipedInputStream pipeIn = new PipedInputStream();
        final StreamCopyThread copier = new StreamCopyThread(pipeIn,
            out);
        final PipedOutputStream pipeOut = new PipedOutputStream(pipeIn) {
          @Override
          public void flush() throws IOException {
            super.flush();
            copier.flush();
          }

          @Override
          public void close() throws IOException {
            super.close();
            try {
              copier.join(timeout * 1000);
            } catch (InterruptedException e) {
              // Just wake early, the thread will terminate
              // anyway.
            }
          }
        };
        copier.start();
        outputStream = pipeOut;
      }

      errStream = channel.getErrStream();
    }
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.