Class ChannelAsyncOutputStream

All Implemented Interfaces:
Closeable, AutoCloseable, Channel, ChannelHolder, Closeable, IoOutputStream

public class ChannelAsyncOutputStream extends AbstractCloseable implements IoOutputStream, ChannelHolder
  • Field Details

    • channelInstance

      private final Channel channelInstance
    • packetWriter

      private final ChannelStreamWriter packetWriter
    • cmd

      private final byte cmd
    • pendingWrite

      private final AtomicReference<IoWriteFutureImpl> pendingWrite
    • packetWriteId

      private final Object packetWriteId
    • sendChunkIfRemoteWindowIsSmallerThanPacketSize

      private boolean sendChunkIfRemoteWindowIsSmallerThanPacketSize
  • Constructor Details

    • ChannelAsyncOutputStream

      public ChannelAsyncOutputStream(Channel channel, byte cmd)
      Parameters:
      channel - The Channel through which the stream is communicating
      cmd - Either SSH_MSG_CHANNEL_DATA or SSH_MSG_CHANNEL_EXTENDED_DATA indicating the output stream type
    • ChannelAsyncOutputStream

      public ChannelAsyncOutputStream(Channel channel, byte cmd, boolean sendChunkIfRemoteWindowIsSmallerThanPacketSize)
      Parameters:
      channel - The Channel through which the stream is communicating
      cmd - Either SSH_MSG_CHANNEL_DATA or SSH_MSG_CHANNEL_EXTENDED_DATA indicating the output stream type
      sendChunkIfRemoteWindowIsSmallerThanPacketSize - Determines the chunking behaviour, if the remote window size is smaller than the packet size. Can be used to establish compatibility with certain clients, that wait until the window size is 0 before adjusting it.
      See Also:
  • Method Details

    • getChannel

      public Channel getChannel()
      Specified by:
      getChannel in interface ChannelHolder
      Returns:
      The associated Channel instance
    • getCommandType

      public byte getCommandType()
      Returns:
      Either SSH_MSG_CHANNEL_DATA or SSH_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 interface IoOutputStream
      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 class AbstractCloseable
    • doCloseGracefully

      protected CloseFuture doCloseGracefully()
      Overrides:
      doCloseGracefully in class AbstractCloseable
    • doWriteIfPossible

      protected void doWriteIfPossible(boolean resume)
    • onWritten

      protected void onWritten(IoWriteFutureImpl future, int total, long length, IoWriteFuture f)
    • createSendBuffer

      protected Buffer createSendBuffer(Buffer buffer, Channel channel, long length)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isSendChunkIfRemoteWindowIsSmallerThanPacketSize

      public boolean isSendChunkIfRemoteWindowIsSmallerThanPacketSize()
    • setSendChunkIfRemoteWindowIsSmallerThanPacketSize

      public void setSendChunkIfRemoteWindowIsSmallerThanPacketSize(boolean sendChunkIfRemoteWindowIsSmallerThanPacketSize)