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());
}
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);
}
}
});
}
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);
}
}
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);
}
});
}
Aggregations