Package org.apache.sshd.common.channel
Class ChannelAsyncOutputStream
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.util.closeable.IoBaseCloseable
-
- org.apache.sshd.common.util.closeable.AbstractCloseable
-
- org.apache.sshd.common.channel.ChannelAsyncOutputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,ChannelHolder
,Closeable
,IoOutputStream
public class ChannelAsyncOutputStream extends AbstractCloseable implements IoOutputStream, ChannelHolder
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
AbstractCloseable.State
-
-
Field Summary
-
Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, state
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description ChannelAsyncOutputStream(Channel channel, byte cmd)
ChannelAsyncOutputStream(Channel channel, byte cmd, boolean sendChunkIfRemoteWindowIsSmallerThanPacketSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Buffer
createSendBuffer(Buffer buffer, Channel channel, long length)
protected CloseFuture
doCloseGracefully()
protected void
doWriteIfPossible(boolean resume)
Channel
getChannel()
byte
getCommandType()
boolean
isSendChunkIfRemoteWindowIsSmallerThanPacketSize()
void
onWindowExpanded()
protected void
onWritten(IoWriteFutureImpl future, int total, long length, IoWriteFuture f)
protected void
preClose()
preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately.void
setSendChunkIfRemoteWindowIsSmallerThanPacketSize(boolean sendChunkIfRemoteWindowIsSmallerThanPacketSize)
String
toString()
IoWriteFuture
writeBuffer(Buffer buffer)
Write the given buffer.-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, doCloseImmediately, getFutureLock, isClosed, isClosing, removeCloseFutureListener
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
-
-
-
Constructor Detail
-
ChannelAsyncOutputStream
public ChannelAsyncOutputStream(Channel channel, byte cmd)
- Parameters:
channel
- TheChannel
through which the stream is communicatingcmd
- EitherSSH_MSG_CHANNEL_DATA
orSSH_MSG_CHANNEL_EXTENDED_DATA
indicating the output stream type
-
ChannelAsyncOutputStream
public ChannelAsyncOutputStream(Channel channel, byte cmd, boolean sendChunkIfRemoteWindowIsSmallerThanPacketSize)
- Parameters:
channel
- TheChannel
through which the stream is communicatingcmd
- EitherSSH_MSG_CHANNEL_DATA
orSSH_MSG_CHANNEL_EXTENDED_DATA
indicating the output stream typesendChunkIfRemoteWindowIsSmallerThanPacketSize
- Determines the chunking behaviour, if the remote window size is smaller than the packet size. Can be use to establish compatibility with certain clients, that wait until the window size is 0 before adjusting it.- See Also:
- SSHD-1123
-
-
Method Detail
-
getChannel
public Channel getChannel()
- Specified by:
getChannel
in interfaceChannelHolder
- Returns:
- The associated
Channel
instance
-
getCommandType
public byte getCommandType()
- Returns:
- Either
SSH_MSG_CHANNEL_DATA
orSSH_MSG_CHANNEL_EXTENDED_DATA
indicating the output stream type
-
onWindowExpanded
public void onWindowExpanded() throws IOException
- Throws:
IOException
-
writeBuffer
public IoWriteFuture writeBuffer(Buffer buffer) throws IOException
Description copied from interface:IoOutputStream
Write the given buffer.- Specified by:
writeBuffer
in interfaceIoOutputStream
- Parameters:
buffer
- the data to write. NOTE: the buffer must not be touched until the returned write future is completed.- Returns:
- An
IoWriteFuture
that can be used to check when the data has actually been written. - Throws:
IOException
- if an error occurred when writing the data
-
preClose
protected void preClose()
Description copied from class:AbstractCloseable
preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately. When preClose() is called, isClosing() == true- Overrides:
preClose
in classAbstractCloseable
-
doCloseGracefully
protected CloseFuture doCloseGracefully()
- Overrides:
doCloseGracefully
in classAbstractCloseable
-
doWriteIfPossible
protected void doWriteIfPossible(boolean resume)
-
onWritten
protected void onWritten(IoWriteFutureImpl future, int total, long length, IoWriteFuture f)
-
isSendChunkIfRemoteWindowIsSmallerThanPacketSize
public boolean isSendChunkIfRemoteWindowIsSmallerThanPacketSize()
-
setSendChunkIfRemoteWindowIsSmallerThanPacketSize
public void setSendChunkIfRemoteWindowIsSmallerThanPacketSize(boolean sendChunkIfRemoteWindowIsSmallerThanPacketSize)
-
-