/** * Reads the given InputStream as a tar file and extracts it into this directory. * * @param _in * The stream will be closed by this method after it's fully read. * @param compression * The compression method in use. * @since 1.292 */ public void untarFrom(InputStream _in, final TarCompression compression) throws IOException, InterruptedException { try { final InputStream in = new RemoteInputStream(_in, Flag.GREEDY); act(new UntarFrom(compression, in)); } finally { _in.close(); } } private class UntarFrom extends SecureFileCallable<Void> {
/** * Reads the given InputStream as a zip file and extracts it into this directory. * * @param _in * The stream will be closed by this method after it's fully read. * @since 1.283 * @see #unzip(FilePath) */ public void unzipFrom(InputStream _in) throws IOException, InterruptedException { final InputStream in = new RemoteInputStream(_in, Flag.GREEDY); act(new UnzipFrom(in)); } private class UnzipFrom extends SecureFileCallable<Void> {
public int execute(List<String> args, InputStream stdin, OutputStream stdout, OutputStream stderr) { return entryPoint.main(args, Locale.getDefault(), new RemoteInputStream(stdin), new RemoteOutputStream(stdout), new RemoteOutputStream(stderr)); }
public IOTriplet getIOtriplet() { IOTriplet r = new IOTriplet(); if (reverseStdout) r.stdout = new RemoteInputStream(p.getStdout()); if (reverseStderr) r.stderr = new RemoteInputStream(p.getStderr()); if (reverseStdin) r.stdin = new RemoteOutputStream(p.getStdin()); return r; } });
/** * When this {@link FilePath} represents a zip file, extracts that zip file. * * @param target * Target directory to expand files to. All the necessary directories will be created. * @since 1.248 * @see #unzipFrom(InputStream) */ public void unzip(final FilePath target) throws IOException, InterruptedException { // TODO: post release, re-unite two branches by introducing FileStreamCallable that resolves InputStream if (this.channel!=target.channel) {// local -> remote or remote->local final RemoteInputStream in = new RemoteInputStream(read(), Flag.GREEDY); target.act(new UnzipRemote(in)); } else {// local -> local or remote->remote target.act(new UnzipLocal()); } } private class UnzipRemote extends SecureFileCallable<Void> {
/** * When this {@link FilePath} represents a tar file, extracts that tar file. * * @param target * Target directory to expand files to. All the necessary directories will be created. * @param compression * Compression mode of this tar file. * @since 1.292 * @see #untarFrom(InputStream, TarCompression) */ public void untar(final FilePath target, final TarCompression compression) throws IOException, InterruptedException { // TODO: post release, re-unite two branches by introducing FileStreamCallable that resolves InputStream if (this.channel!=target.channel) {// local -> remote or remote->local final RemoteInputStream in = new RemoteInputStream(read(), Flag.GREEDY); target.act(new UntarRemote(compression, in)); } else {// local -> local or remote->remote target.act(new UntarLocal(compression)); } } private class UntarRemote extends SecureFileCallable<Void> {
public Proc launch(ProcStarter ps) throws IOException { final OutputStream out = ps.stdout == null || ps.stdoutListener != null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stdout)); final OutputStream err = ps.stderr==null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stderr)); final InputStream in = (ps.stdin==null || ps.stdin==NULL_INPUT_STREAM) ? null : new RemoteInputStream(ps.stdin,false); final FilePath psPwd = ps.pwd; final String workDir = psPwd==null ? null : psPwd.getRemote(); try { return new ProcImpl(getChannel().call(new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, ps.reverseStdin, out, ps.reverseStdout, err, ps.reverseStderr, ps.quiet, workDir, listener, ps.stdoutListener))); } catch (InterruptedException e) { throw (IOException)new InterruptedIOException().initCause(e); } }
/** * Executed on remote, returns connection wrapper with remote streams. */ private Object writeReplace() { return new ConnectionImpl(new RemoteInputStream(input), new RemoteOutputStream(output)); }
/** * Executed on remote, returns connection wrapper with remote streams. */ private Object writeReplace() { return new ConnectionImpl(new RemoteInputStream(input), new RemoteOutputStream(output)); }
/** * Executed on remote, returns connection wrapper with remote streams. */ private Object writeReplace() { return new ConnectionImpl(new RemoteInputStream(input), new RemoteOutputStream(output)); }
@Override public InputStream invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { return new RemoteInputStream(new Dockerfile(new File(f, "Dockerfile"), f).parse().buildDockerFolderTar(), RemoteInputStream.Flag.GREEDY); } }
public int execute(List<String> args, InputStream stdin, OutputStream stdout, OutputStream stderr) { return entryPoint.main(args,Locale.getDefault(), new RemoteInputStream(stdin), new RemoteOutputStream(stdout), new RemoteOutputStream(stderr)); }
public IOTriplet getIOtriplet() { IOTriplet r = new IOTriplet(); if (reverseStdout) r.stdout = new RemoteInputStream(p.getStdout()); if (reverseStderr) r.stderr = new RemoteInputStream(p.getStderr()); if (reverseStdin) r.stdin = new RemoteOutputStream(p.getStdin()); return r; } });
/** * Makes sure non-greedy RemoteInputStream is not completely dead on arrival. */ public void testNonGreedy() throws Exception { ByteArrayInputStream in = new ByteArrayInputStream(toBytes("12345678")); channel.call(new Read(new RemoteInputStream(in, NOT_GREEDY),toBytes("1234"))); assertTrue(Arrays.equals(readFully(in, 4), "5678".getBytes())); }
/** * Read in multiple chunks. */ public void testGreedy2() throws Exception { ByteArrayInputStream in = new ByteArrayInputStream(toBytes("12345678")); final RemoteInputStream i = new RemoteInputStream(in, GREEDY); channel.call(new TestGreedy2(i)); assertEquals(in.read(),-1); }
public Proc launch(ProcStarter ps) throws IOException { final OutputStream out = ps.stdout == null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stdout)); final OutputStream err = ps.stderr==null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stderr)); final InputStream in = (ps.stdin==null || ps.stdin==NULL_INPUT_STREAM) ? null : new RemoteInputStream(ps.stdin,false); final FilePath psPwd = ps.pwd; final String workDir = psPwd==null ? null : psPwd.getRemote(); try { return new ProcImpl(getChannel().call(new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, ps.reverseStdin, out, ps.reverseStdout, err, ps.reverseStderr, ps.quiet, workDir, listener))); } catch (InterruptedException e) { throw (IOException)new InterruptedIOException().initCause(e); } }
/** * Greedy {@link RemoteInputStream} should propagate error. */ public void testErrorPropagation() throws Exception { for (RemoteInputStream.Flag f : asList(GREEDY, NOT_GREEDY)) { InputStream in = new SequenceInputStream( new ByteArrayInputStream(toBytes("1234")), new BrokenInputStream(new SkyIsFalling()) ); final RemoteInputStream i = new RemoteInputStream(in, f); channel.call(new TestErrorPropagation(i)); } }
public Proc launch(ProcStarter ps) throws IOException { final OutputStream out = ps.stdout == null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stdout)); final OutputStream err = ps.stderr==null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stderr)); final InputStream in = ps.stdin==null ? null : new RemoteInputStream(ps.stdin); final String workDir = ps.pwd==null ? null : ps.pwd.getRemote(); return new RemoteProc(getChannel().callAsync(new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, out, err, workDir, listener))); }
public Proc launch(ProcStarter ps) throws IOException { final OutputStream out = ps.stdout == null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stdout)); final OutputStream err = ps.stderr==null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stderr)); final InputStream in = ps.stdin==null ? null : new RemoteInputStream(ps.stdin); final String workDir = ps.pwd==null ? null : ps.pwd.getRemote(); return new RemoteProc(getChannel().callAsync(new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, out, err, workDir, listener))); }
public Proc launch(ProcStarter ps) throws IOException { final OutputStream out = ps.stdout == null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stdout)); final OutputStream err = ps.stderr==null ? null : new RemoteOutputStream(new CloseProofOutputStream(ps.stderr)); final InputStream in = ps.stdin==null ? null : new RemoteInputStream(ps.stdin); final String workDir = ps.pwd==null ? null : ps.pwd.getRemote(); return new RemoteProc(getChannel().callAsync(new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, out, err, workDir, listener))); }