public class ChannelAsyncOutputStream extends AbstractCloseable implements IoOutputStream, ChannelHolder
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ChannelAsyncOutputStream.BufferedFuture
Marker type to avoid repeated buffering in
writePacket(IoWriteFutureImpl, boolean). |
protected static class |
ChannelAsyncOutputStream.WriteState
Collects state variables; access is always synchronized on the single instance per stream.
|
AbstractCloseable.State| Modifier and Type | Field and Description |
|---|---|
protected AtomicReference<IoWriteFuture> |
lastWrite
The future describing the last executed *buffer* write
writeBuffer(Buffer). |
protected ChannelAsyncOutputStream.WriteState |
writeState
Encapsulates the state of the current write operation.
|
closeFuture, futureLock, statelog| Constructor and Description |
|---|
ChannelAsyncOutputStream(Channel channel,
byte cmd) |
| Modifier and Type | Method and Description |
|---|---|
protected Buffer |
createSendBuffer(Buffer buffer,
Channel channel,
int length) |
protected CloseFuture |
doCloseGracefully() |
protected void |
doCloseImmediately() |
protected void |
doWriteIfPossible(boolean resume) |
Channel |
getChannel() |
byte |
getCommandType() |
void |
onWindowExpanded() |
protected void |
onWritten(IoWriteFutureImpl future,
int total,
int length,
IoWriteFuture f) |
protected void |
preClose() |
protected void |
shutdown() |
protected void |
terminateFuture(IoWriteFutureImpl future) |
String |
toString() |
IoWriteFuture |
writeBuffer(Buffer buffer)
This write operation is asynchronous: if there is not enough window space, it may keep the write pending
or write only part of the buffer and keep the rest pending.
|
protected IoWriteFutureImpl |
writePacket(IoWriteFutureImpl future,
boolean resume)
Try to write as much of the current buffer as possible.
|
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenerdebug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListenerprotected final AtomicReference<IoWriteFuture> lastWrite
writeBuffer(Buffer). Used
for graceful closing.protected final ChannelAsyncOutputStream.WriteState writeState
public ChannelAsyncOutputStream(Channel channel, byte cmd)
channel - The Channel through which the stream is communicatingcmd - Either SSH_MSG_CHANNEL_DATA or
SSH_MSG_CHANNEL_EXTENDED_DATA indicating the
output stream typepublic Channel getChannel()
getChannel in interface ChannelHolderChannel instancepublic byte getCommandType()
SSH_MSG_CHANNEL_DATA or
SSH_MSG_CHANNEL_EXTENDED_DATA indicating the output
stream typepublic IoWriteFuture writeBuffer(Buffer buffer) throws IOException
WritePendingException. Any subsequent write must occur only once the returned future is
fulfilled; for instance triggered via a listener on the returned future. Try to avoid doing a subsequent write
directly in a future listener, though; doing so may lead to deep chains of nested listener calls with deep stack
traces, and may ultimately lead to a stack overflow.writeBuffer in interface IoOutputStreamWritePendingException - if a concurrent write is attemptedIOExceptionprotected void preClose()
preClose in class AbstractCloseableprotected void doCloseImmediately()
doCloseImmediately in class AbstractCloseableprotected void shutdown()
protected void terminateFuture(IoWriteFutureImpl future)
protected CloseFuture doCloseGracefully()
doCloseGracefully in class AbstractCloseablepublic void onWindowExpanded()
throws IOException
IOExceptionprotected void doWriteIfPossible(boolean resume)
protected IoWriteFutureImpl writePacket(IoWriteFutureImpl future, boolean resume)
future - IoWriteFutureImpl for the current writeresume - whether being called in response to a remote window adjustmentnull if all written, or if the rest will be written via a future listener. Otherwise a
future for the remaining writes.protected void onWritten(IoWriteFutureImpl future, int total, int length, IoWriteFuture f)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.