/** * Creates a {@link Pipe} that allows remote system to write and local system to read. */ public static Pipe createRemoteToLocal() { // OutputStream will be created on the target return new Pipe(new FastPipedInputStream(), null); }
/** * Creates a {@link Pipe} that allows remote system to write and local system to read. */ public static Pipe createRemoteToLocal() { // OutputStream will be created on the target return new Pipe(new FastPipedInputStream(), null); }
/** * Creates a {@link Pipe} that allows remote system to write and local system to read. */ public static Pipe createRemoteToLocal() { // OutputStream will be created on the target return new Pipe(new FastPipedInputStream(), null); }
/** * Creates a {@link Pipe} that allows remote system to write and local system to read. */ public static Pipe createRemoteToLocal() { // OutputStream will be created on the target return new Pipe(new FastPipedInputStream(),null); }
WindowsProcess(WinRMClient client, String command) throws IOException { this.client = client; this.command = command; toCallersStdin = new FastPipedInputStream(); callersStdin = new FastPipedOutputStream(toCallersStdin); callersStdout = new FastPipedInputStream(); toCallersStdout = new FastPipedOutputStream(callersStdout); callersStderr = new FastPipedInputStream(); toCallersStderr = new FastPipedOutputStream(callersStderr); startStdoutCopyThread(); try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } startStdinCopyThread(); }
Future<Integer> remoteOCProcessFuture = null; try (FastPipedOutputStream stdout = new FastPipedOutputStream(); InputStream redirectedStdout = new FastPipedInputStream(stdout); FastPipedOutputStream stderr = new FastPipedOutputStream(); InputStream redirectedStderr = new FastPipedInputStream(stderr)) {
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { final Channel channel = getChannelForSerialization(); if(ois.readBoolean()) { // local will write to remote in = null; out = new ProxyOutputStream(channel, ois.readInt()); } else { // local will read from remote. // tell the remote system about this local read pipe // this is the OutputStream that wants to send data to us final int oidRos = ois.readInt(); // we want 'oidRos' to send data to this PipedOutputStream FastPipedOutputStream pos = new FastPipedOutputStream(); FastPipedInputStream pis = new FastPipedInputStream(pos); final int oidPos = channel.internalExport(Object.class, pos, false); // this gets unexported when the remote ProxyOutputStream closes. // tell 'ros' to connect to our 'pos'. channel.send(new ConnectCommand(oidRos, oidPos)); out = null; in = pis; } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { final Channel channel = Channel.current(); assert channel != null; if (ois.readBoolean()) { // local will write to remote in = null; out = new ProxyOutputStream(channel, ois.readInt()); } else { // local will read from remote. // tell the remote system about this local read pipe // this is the OutputStream that wants to send data to us final int oidRos = ois.readInt(); // we want 'oidRos' to send data to this PipedOutputStream FastPipedOutputStream pos = new FastPipedOutputStream(); FastPipedInputStream pis = new FastPipedInputStream(pos); final int oidPos = channel.export(pos); // tell 'ros' to connect to our 'pos'. channel.send(new ConnectCommand(oidRos, oidPos)); out = null; in = pis; } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { final Channel channel = Channel.current(); assert channel != null; if (ois.readBoolean()) { // local will write to remote in = null; out = new ProxyOutputStream(channel, ois.readInt()); } else { // local will read from remote. // tell the remote system about this local read pipe // this is the OutputStream that wants to send data to us final int oidRos = ois.readInt(); // we want 'oidRos' to send data to this PipedOutputStream FastPipedOutputStream pos = new FastPipedOutputStream(); FastPipedInputStream pis = new FastPipedInputStream(pos); final int oidPos = channel.export(pos); // tell 'ros' to connect to our 'pos'. channel.send(new ConnectCommand(oidRos, oidPos)); out = null; in = pis; } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { final Channel channel = Channel.current(); assert channel != null; if (ois.readBoolean()) { // local will write to remote in = null; out = new ProxyOutputStream(channel, ois.readInt()); } else { // local will read from remote. // tell the remote system about this local read pipe // this is the OutputStream that wants to send data to us final int oidRos = ois.readInt(); // we want 'oidRos' to send data to this PipedOutputStream FastPipedOutputStream pos = new FastPipedOutputStream(); FastPipedInputStream pis = new FastPipedInputStream(pos); final int oidPos = channel.export(pos); // tell 'ros' to connect to our 'pos'. channel.send(new ConnectCommand(oidRos, oidPos)); out = null; in = pis; } }
public void exec(String[] cmd) throws PerforceException { try { // ensure we actually have a valid hudson launcher if (null == hudsonLauncher) { hudsonLauncher = Hudson.getInstance().createLauncher(new StreamTaskListener(System.out)); } // hudsonOut->p4in->reader HudsonPipedOutputStream hudsonOut = new HudsonPipedOutputStream(); FastPipedInputStream p4in = new FastPipedInputStream(hudsonOut); reader = new BufferedReader(new InputStreamReader(p4in)); // hudsonIn<-p4Out<-writer FastPipedInputStream hudsonIn = new FastPipedInputStream(); FastPipedOutputStream p4out = new FastPipedOutputStream(hudsonIn); writer = new BufferedWriter(new OutputStreamWriter(p4out)); Proc process = hudsonLauncher.launch().cmds(cmd).envs(env).stdin(hudsonIn).stdout(hudsonOut).pwd(filePath).start(); // Required to close hudsonOut stream hudsonOut.closeOnProcess(process); } catch(IOException e) { //try to close all the pipes before throwing an exception closeBuffers(); throw new PerforceException("Could not run perforce command.", e); } }
public Channel start() throws Exception { final FastPipedInputStream in1 = new FastPipedInputStream(); final FastPipedOutputStream out1 = new FastPipedOutputStream(in1); final FastPipedInputStream in2 = new FastPipedInputStream(); final FastPipedOutputStream out2 = new FastPipedOutputStream(in2); final SynchronousQueue<Channel> southHandoff = new SynchronousQueue<Channel>(); executor = Executors.newCachedThreadPool(); Thread t = new Thread("south bridge runner") { public void run() { try { Channel south = configureSouth().build(in2,out1); southHandoff.put(south); south.join(); System.out.println("south completed"); } catch (Exception e) { e.printStackTrace(); failure = e; } } }; t.start(); Channel north = configureNorth().build(in1, out2); south = southHandoff.poll(10, TimeUnit.SECONDS); return north; }
/** * This tests the behaviour of the diagnosis blocking on a non-completed stream, as the writer end is kept open. */ @Test(timeout=3000) public void blockingStreamShouldNotPreventDiagnosis() throws Exception { FastPipedInputStream in = new FastPipedInputStream(); FastPipedOutputStream out = new FastPipedOutputStream(in); out.write(payload); ClassicCommandTransport ct = (ClassicCommandTransport) new ChannelBuilder("dummy",null) .withMode(Mode.BINARY) .withBaseLoader(getClass().getClassLoader()) .negotiate(in, new NullOutputStream()); verify(ct); } }