org.apache.sshd.common.io.IoOutputStream Java Examples
The following examples show how to use
org.apache.sshd.common.io.IoOutputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TtyCommand.java From aesh-readline with Apache License 2.0 | 6 votes |
@Override public void setIoOutputStream(IoOutputStream out) { this.ioOut = out; this.out = (byte[] bytes) -> { if(writeFuture == null) writeFuture = out.write(new ByteArrayBuffer(bytes)); else if(writeFuture.isWritten()) writeFuture = out.write(new ByteArrayBuffer(bytes)); else { try { writeFuture.await(); writeFuture = out.write(new ByteArrayBuffer(bytes)); } catch (IOException e) { e.printStackTrace(); } } }; }
Example #2
Source File: TtyCommand.java From termd with Apache License 2.0 | 5 votes |
@Override public void setIoOutputStream(final IoOutputStream out) { this.ioOut = out; this.out = new Consumer<byte[]>() { @Override public void accept(byte[] bytes) { out.write(new ByteArrayBuffer(bytes)); } }; }
Example #3
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoOutputStream(IoOutputStream out) { this.out = new BufferedIoOutputStream(out); }
Example #4
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 4 votes |
public IoOutputStream getErr() { return err; }
Example #5
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 4 votes |
public IoOutputStream getOut() { return out; }
Example #6
Source File: WindowAdjustTest.java From termd with Apache License 2.0 | 4 votes |
AsyncInPendingWrapper(IoOutputStream out) { this.asyncIn = out; }
Example #7
Source File: WindowAdjustTest.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoErrorStream(IoOutputStream err) { // ignored }
Example #8
Source File: WindowAdjustTest.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoOutputStream(IoOutputStream out) { pendingWrapper = new AsyncInPendingWrapper(out); }
Example #9
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoErrorStream(IoOutputStream err) { this.err = new BufferedIoOutputStream(err); }
Example #10
Source File: TtyCommand.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoOutputStream(IoOutputStream out) { this.ioOut = out; this.out = bytes -> out.write(new ByteArrayBuffer(bytes)); }
Example #11
Source File: WindowTest.java From termd with Apache License 2.0 | 4 votes |
@Test public void testWindowConsumptionWithAsyncStreams() throws Exception { sshd.setShellFactory(new AsyncEchoShellFactory()); PropertyResolverUtils.updateProperty(sshd, FactoryManager.WINDOW_SIZE, 1024); PropertyResolverUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 1024); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ChannelShell channel = session.createShellChannel()) { channel.setStreaming(ClientChannel.Streaming.Async); channel.open().verify(5L, TimeUnit.SECONDS); try (Channel serverChannel = sshd.getActiveSessions().iterator().next().getService(ServerConnectionService.class).getChannels().iterator().next()) { Window clientLocal = channel.getLocalWindow(); Window clientRemote = channel.getRemoteWindow(); Window serverLocal = serverChannel.getLocalWindow(); Window serverRemote = serverChannel.getRemoteWindow(); final String message = "0123456789\n"; final byte[] bytes = message.getBytes(StandardCharsets.UTF_8); final int nbMessages = 500; IoOutputStream output = channel.getAsyncIn(); IoInputStream input = channel.getAsyncOut(); for (int i = 0; i < nbMessages; i++) { Buffer buffer = new ByteArrayBuffer(bytes); output.write(buffer).verify(5L, TimeUnit.SECONDS); waitForWindowNotEquals(clientLocal, serverRemote, "client local", "server remote", TimeUnit.SECONDS.toMillis(3L)); Buffer buf = new ByteArrayBuffer(16); IoReadFuture future = input.read(buf); future.verify(5L, TimeUnit.SECONDS); assertEquals("Mismatched available data at line #" + i, message.length(), buf.available()); assertEquals("Mismatched data at line #" + i, message, new String(buf.array(), buf.rpos(), buf.available())); waitForWindowEquals(clientLocal, serverRemote, "client local", "server remote", TimeUnit.SECONDS.toMillis(3L)); waitForWindowEquals(clientRemote, serverLocal, "client remote", "server local", TimeUnit.SECONDS.toMillis(3L)); } } } } finally { client.stop(); } }
Example #12
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoErrorStream(IoOutputStream err) { this.err = new BufferedIoOutputStream(err); }
Example #13
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoOutputStream(IoOutputStream out) { this.out = new BufferedIoOutputStream(out); }
Example #14
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 4 votes |
public IoOutputStream getErr() { return err; }
Example #15
Source File: AsyncEchoShellFactory.java From termd with Apache License 2.0 | 4 votes |
public IoOutputStream getOut() { return out; }
Example #16
Source File: WindowAdjustTest.java From termd with Apache License 2.0 | 4 votes |
AsyncInPendingWrapper(IoOutputStream out) { this.asyncIn = out; }
Example #17
Source File: WindowAdjustTest.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoErrorStream(IoOutputStream err) { // ignored }
Example #18
Source File: WindowAdjustTest.java From termd with Apache License 2.0 | 4 votes |
@Override public void setIoOutputStream(IoOutputStream out) { pendingWrapper = new AsyncInPendingWrapper(out); }
Example #19
Source File: WindowTest.java From termd with Apache License 2.0 | 4 votes |
@Test public void testWindowConsumptionWithAsyncStreams() throws Exception { sshd.setShellFactory(new AsyncEchoShellFactory()); PropertyResolverUtils.updateProperty(sshd, FactoryManager.WINDOW_SIZE, 1024); PropertyResolverUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 1024); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ChannelShell channel = session.createShellChannel()) { channel.setStreaming(ClientChannel.Streaming.Async); channel.open().verify(5L, TimeUnit.SECONDS); try (Channel serverChannel = sshd.getActiveSessions().iterator().next().getService(ServerConnectionService.class).getChannels().iterator().next()) { Window clientLocal = channel.getLocalWindow(); Window clientRemote = channel.getRemoteWindow(); Window serverLocal = serverChannel.getLocalWindow(); Window serverRemote = serverChannel.getRemoteWindow(); final String message = "0123456789\n"; final byte[] bytes = message.getBytes(StandardCharsets.UTF_8); final int nbMessages = 500; IoOutputStream output = channel.getAsyncIn(); IoInputStream input = channel.getAsyncOut(); for (int i = 0; i < nbMessages; i++) { Buffer buffer = new ByteArrayBuffer(bytes); output.write(buffer).verify(5L, TimeUnit.SECONDS); waitForWindowNotEquals(clientLocal, serverRemote, "client local", "server remote", TimeUnit.SECONDS.toMillis(3L)); Buffer buf = new ByteArrayBuffer(16); IoReadFuture future = input.read(buf); future.verify(5L, TimeUnit.SECONDS); assertEquals("Mismatched available data at line #" + i, message.length(), buf.available()); assertEquals("Mismatched data at line #" + i, message, new String(buf.array(), buf.rpos(), buf.available())); waitForWindowEquals(clientLocal, serverRemote, "client local", "server remote", TimeUnit.SECONDS.toMillis(3L)); waitForWindowEquals(clientRemote, serverLocal, "client remote", "server local", TimeUnit.SECONDS.toMillis(3L)); } } } } finally { client.stop(); } }
Example #20
Source File: TtyCommand.java From aesh-readline with Apache License 2.0 | 2 votes |
@Override public void setIoErrorStream(IoOutputStream err) { }
Example #21
Source File: TtyCommand.java From termd with Apache License 2.0 | 2 votes |
@Override public void setIoErrorStream(IoOutputStream err) { }
Example #22
Source File: TtyCommand.java From termd with Apache License 2.0 | 2 votes |
@Override public void setIoErrorStream(IoOutputStream err) { }