Search in sources :

Example 1 with RemoteOutputStream

use of hudson.remoting.RemoteOutputStream in project hudson-2.x by hudson.

the class StreamTaskListener method writeObject.

private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeObject(new RemoteOutputStream(new CloseProofOutputStream(this.out)));
    out.writeObject(charset == null ? null : charset.name());
}
Also used : CloseProofOutputStream(hudson.CloseProofOutputStream) RemoteOutputStream(hudson.remoting.RemoteOutputStream)

Example 2 with RemoteOutputStream

use of hudson.remoting.RemoteOutputStream in project hudson-2.x by hudson.

the class FilePath method copyTo.

/**
     * Sends the contents of this file into the given {@link OutputStream}.
     */
public void copyTo(OutputStream os) throws IOException, InterruptedException {
    final OutputStream out = new RemoteOutputStream(os);
    act(new FileCallable<Void>() {

        public Void invoke(File f, VirtualChannel channel) throws IOException {
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(f);
                Util.copyStream(fis, out);
                try {
                    if (Channel.current() != null) {
                        Channel.current().flushPipe();
                    }
                } catch (InterruptedException ex) {
                    Logger.getLogger(FilePath.class.getName()).log(Level.SEVERE, null, ex);
                }
                return null;
            } finally {
                IOUtils.closeQuietly(fis);
                IOUtils.closeQuietly(out);
            }
        }
    });
}
Also used : RemoteOutputStream(hudson.remoting.RemoteOutputStream) VirtualChannel(hudson.remoting.VirtualChannel) GZIPOutputStream(java.util.zip.GZIPOutputStream) RemoteOutputStream(hudson.remoting.RemoteOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 3 with RemoteOutputStream

use of hudson.remoting.RemoteOutputStream in project hudson-2.x by hudson.

the class PortForwarder method run.

@Override
public void run() {
    try {
        try {
            while (true) {
                final Socket s = socket.accept();
                new Thread("Port forwarding session from " + s.getRemoteSocketAddress()) {

                    public void run() {
                        try {
                            final OutputStream out = forwarder.connect(new RemoteOutputStream(new SocketOutputStream(s)));
                            new CopyThread("Copier for " + s.getRemoteSocketAddress(), new SocketInputStream(s), out).start();
                        } catch (IOException e) {
                            // this happens if the socket connection is terminated abruptly.
                            LOGGER.log(FINE, "Port forwarding session was shut down abnormally", e);
                        }
                    }
                }.start();
            }
        } finally {
            socket.close();
        }
    } catch (IOException e) {
        LOGGER.log(FINE, "Port forwarding was shut down abnormally", e);
    }
}
Also used : RemoteOutputStream(hudson.remoting.RemoteOutputStream) SocketOutputStream(hudson.remoting.SocketOutputStream) OutputStream(java.io.OutputStream) RemoteOutputStream(hudson.remoting.RemoteOutputStream) SocketOutputStream(hudson.remoting.SocketOutputStream) SocketInputStream(hudson.remoting.SocketInputStream) IOException(java.io.IOException) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket)

Example 4 with RemoteOutputStream

use of hudson.remoting.RemoteOutputStream in project hudson-2.x by hudson.

the class FilePath method write.

/**
     * Writes to this file.
     * If this file already exists, it will be overwritten.
     * If the directory doesn't exist, it will be created.
     */
public OutputStream write() throws IOException, InterruptedException {
    if (channel == null) {
        File f = new File(remote).getAbsoluteFile();
        f.getParentFile().mkdirs();
        return new FileOutputStream(f);
    }
    return channel.call(new Callable<OutputStream, IOException>() {

        public OutputStream call() throws IOException {
            File f = new File(remote).getAbsoluteFile();
            f.getParentFile().mkdirs();
            FileOutputStream fos = new FileOutputStream(f);
            return new RemoteOutputStream(fos);
        }
    });
}
Also used : RemoteOutputStream(hudson.remoting.RemoteOutputStream) FileOutputStream(java.io.FileOutputStream) GZIPOutputStream(java.util.zip.GZIPOutputStream) RemoteOutputStream(hudson.remoting.RemoteOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Aggregations

RemoteOutputStream (hudson.remoting.RemoteOutputStream)4 IOException (java.io.IOException)3 OutputStream (java.io.OutputStream)3 BufferedOutputStream (java.io.BufferedOutputStream)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 CloseProofOutputStream (hudson.CloseProofOutputStream)1 SocketInputStream (hudson.remoting.SocketInputStream)1 SocketOutputStream (hudson.remoting.SocketOutputStream)1 VirtualChannel (hudson.remoting.VirtualChannel)1 FileInputStream (java.io.FileInputStream)1 ServerSocket (java.net.ServerSocket)1 Socket (java.net.Socket)1