public static ByteArrayOutputStream readFully(InputStream stream, LoggerFactory loggerFactory) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); new StreamCopier(stream, baos, loggerFactory).copy(); return baos; }
@Override public void run() { try { log.debug("Will copy from {} to {}", in, out); copy(); log.debug("Done copying from {}", in); doneEvent.set(); } catch (IOException ioe) { log.error(String.format("In pipe from %1$s to %2$s", in.toString(), out.toString()), ioe); doneEvent.deliverError(ioe); } } }.start();
long transferFromRemote(StreamCopier.Listener listener, OutputStream dest, long length) throws IOException { return new StreamCopier(scp.getInputStream(), dest, loggerFactory) .bufSize(scp.getLocalMaxPacketSize()).length(length) .keepFlushing(false) .listener(listener) .copy(); }
long transferToRemote(StreamCopier.Listener listener, InputStream src, long length) throws IOException { return new StreamCopier(src, scp.getOutputStream(), loggerFactory) .bufSize(scp.getRemoteMaxPacketSize()).length(length) .keepFlushing(false) .listener(listener) .copy(); }
.keepFlushing(false) .listener(listener) .copy(); } finally { if (rf != null) {
private LocalDestFile downloadFile(final StreamCopier.Listener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjusted = local.getTargetFile(remote.getName()); final RemoteFile rf = engine.open(remote.getPath()); try { final RemoteFile.ReadAheadRemoteFileInputStream rfis = rf.new ReadAheadRemoteFileInputStream(16); final OutputStream os = adjusted.getOutputStream(); try { new StreamCopier(rfis, os, engine.getLoggerFactory()) .bufSize(engine.getSubsystem().getLocalMaxPacketSize()) .keepFlushing(false) .listener(listener) .copy(); } finally { rfis.close(); os.close(); } } finally { rf.close(); } return adjusted; }
public static ByteArrayOutputStream readFully(InputStream stream, LoggerFactory loggerFactory) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); new StreamCopier(stream, baos, loggerFactory).copy(); return baos; }
public static ByteArrayOutputStream readFully(InputStream stream) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); new StreamCopier(stream, baos).copy(); return baos; }
@Override public void run() { try { log.debug("Will copy from {} to {}", in, out); copy(); log.debug("Done copying from {}", in); doneEvent.set(); } catch (IOException ioe) { log.error(String.format("In pipe from %1$s to %2$s", in.toString(), out.toString()), ioe); doneEvent.deliverError(ioe); } } }.start();
@Override public void run() { try { log.debug("Will copy from {} to {}", in, out); copy(); log.debug("Done copying from {}", in); doneEvent.set(); } catch (IOException ioe) { log.error("In pipe from {} to {}: {}", in, out, ioe); doneEvent.deliverError(ioe); } } }.start();
long transferFromRemote(StreamCopier.Listener listener, OutputStream dest, long length) throws IOException { return new StreamCopier(scp.getInputStream(), dest) .bufSize(scp.getLocalMaxPacketSize()).length(length) .keepFlushing(false) .listener(listener) .copy(); }
long transferFromRemote(StreamCopier.Listener listener, OutputStream dest, long length) throws IOException { return new StreamCopier(scp.getInputStream(), dest, loggerFactory) .bufSize(scp.getLocalMaxPacketSize()).length(length) .keepFlushing(false) .listener(listener) .copy(); }
long transferToRemote(StreamCopier.Listener listener, InputStream src, long length) throws IOException { return new StreamCopier(src, scp.getOutputStream()) .bufSize(scp.getRemoteMaxPacketSize()).length(length) .keepFlushing(false) .listener(listener) .copy(); }
long transferToRemote(StreamCopier.Listener listener, InputStream src, long length) throws IOException { return new StreamCopier(src, scp.getOutputStream(), loggerFactory) .bufSize(scp.getRemoteMaxPacketSize()).length(length) .keepFlushing(false) .listener(listener) .copy(); }
private String uploadFile(final StreamCopier.Listener listener, final LocalSourceFile local, final String remote) throws IOException { final String adjusted = prepareFile(local, remote); final RemoteFile rf = engine.open(adjusted, EnumSet.of(OpenMode.WRITE, OpenMode.CREAT, OpenMode.TRUNC)); try { final InputStream fis = local.getInputStream(); final RemoteFile.RemoteFileOutputStream rfos = rf.new RemoteFileOutputStream(0, 16); try { new StreamCopier(fis, rfos) .bufSize(engine.getSubsystem().getRemoteMaxPacketSize() - rf.getOutgoingPacketOverhead()) .keepFlushing(false) .listener(listener) .copy(); } finally { fis.close(); rfos.close(); } } finally { rf.close(); } return adjusted; }
.keepFlushing(false) .listener(listener) .copy(); } finally { if (rf != null) {
private LocalDestFile downloadFile(final StreamCopier.Listener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjusted = local.getTargetFile(remote.getName()); final RemoteFile rf = engine.open(remote.getPath()); try { final RemoteFile.ReadAheadRemoteFileInputStream rfis = rf.new ReadAheadRemoteFileInputStream(16); final OutputStream os = adjusted.getOutputStream(); try { new StreamCopier(rfis, os) .bufSize(engine.getSubsystem().getLocalMaxPacketSize()) .keepFlushing(false) .listener(listener) .copy(); } finally { rfis.close(); os.close(); } } finally { rf.close(); } return adjusted; }
private LocalDestFile downloadFile(final StreamCopier.Listener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjusted = local.getTargetFile(remote.getName()); final RemoteFile rf = engine.open(remote.getPath()); try { final RemoteFile.ReadAheadRemoteFileInputStream rfis = rf.new ReadAheadRemoteFileInputStream(16); final OutputStream os = adjusted.getOutputStream(); try { new StreamCopier(rfis, os, engine.getLoggerFactory()) .bufSize(engine.getSubsystem().getLocalMaxPacketSize()) .keepFlushing(false) .listener(listener) .copy(); } finally { rfis.close(); os.close(); } } finally { rf.close(); } return adjusted; }
private void logIntoIp(String ipAddress) throws IOException, InterruptedException { final SSHClient ssh = new SSHClient(); OpenSSHKeyFile k = new OpenSSHKeyFile(); k.init(new File(dotHaruhi, keyPairName + ".pem")); ssh.addHostKeyVerifier(new PromiscuousVerifier()); ssh.connect(ipAddress); try { ssh.authPublickey(clusterUsername, k); Session that = ssh.startSession(); try { that.allocateDefaultPTY(); Session.Shell shell = that.startShell(); new StreamCopier(shell.getInputStream(), System.out) .bufSize(shell.getLocalMaxPacketSize()) .spawn("stdout"); new StreamCopier(shell.getErrorStream(), System.err) .bufSize(shell.getLocalMaxPacketSize()) .spawn("stderr"); new StreamCopier(System.in, shell.getOutputStream()) .bufSize(shell.getRemoteMaxPacketSize()) .copy(); } finally { that.close(); } } finally { ssh.close(); } }