Class ThrottlingChannelStreamWriter

java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.contrib.common.channel.throttle.ThrottlingChannelStreamWriter
All Implemented Interfaces:
Closeable, AutoCloseable, Channel, EventListener, org.apache.sshd.common.channel.throttle.ChannelStreamWriter, org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoWriteFuture>, org.apache.sshd.common.util.SshdEventListener

public class ThrottlingChannelStreamWriter extends org.apache.sshd.common.util.logging.AbstractLoggingBean implements org.apache.sshd.common.channel.throttle.ChannelStreamWriter, org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoWriteFuture>
A ChannelStreamWriter delegate implementation that "throttles" the output by having a limit on the outstanding packets that have not been sent yet. The writePacket implementation make sure that the limit has not been exceeded - if so, then it waits until pending packets have been successfully sent before sending the next packet. Note: closing the throttler does not close the delegate writer
  • Field Details

    • WAIT_TIME

      public static final org.apache.sshd.common.Property<Duration> WAIT_TIME
      Timeout (seconds) for throttling packet writer to wait for pending packets send
    • MAX_PEND_COUNT

      public static final org.apache.sshd.common.Property<Integer> MAX_PEND_COUNT
      Max. pending packets count
    • delegate

      private final org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate
    • maxPendingPackets

      private final int maxPendingPackets
    • maxWait

      private final long maxWait
    • open

      private final AtomicBoolean open
    • availableCount

      private final AtomicInteger availableCount
  • Constructor Details

    • ThrottlingChannelStreamWriter

      public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.Channel channel)
    • ThrottlingChannelStreamWriter

      public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, org.apache.sshd.common.PropertyResolver resolver)
    • ThrottlingChannelStreamWriter

      public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, TimeUnit waitUnit, long waitCount)
    • ThrottlingChannelStreamWriter

      public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, Duration maxWait)
    • ThrottlingChannelStreamWriter

      public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, long maxWait)
  • Method Details

    • getDelegate

      public org.apache.sshd.common.channel.throttle.ChannelStreamWriter getDelegate()
    • getMaxPendingPackets

      public int getMaxPendingPackets()
    • getAvailablePacketsCount

      public int getAvailablePacketsCount()
    • getMaxWait

      public long getMaxWait()
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface Channel
    • writeData

      public org.apache.sshd.common.io.IoWriteFuture writeData(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException
      Specified by:
      writeData in interface org.apache.sshd.common.channel.throttle.ChannelStreamWriter
      Throws:
      IOException
    • operationComplete

      public void operationComplete(org.apache.sshd.common.io.IoWriteFuture future)
      Specified by:
      operationComplete in interface org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoWriteFuture>
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object