Class ThrottlingChannelStreamWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.Channel, java.util.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 Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.atomic.AtomicInteger availableCount  
      private org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate  
      static org.apache.sshd.common.Property<java.lang.Integer> MAX_PEND_COUNT
      Max.
      private int maxPendingPackets  
      private long maxWait  
      private java.util.concurrent.atomic.AtomicBoolean open  
      static org.apache.sshd.common.Property<java.time.Duration> WAIT_TIME
      Timeout (seconds) for throttling packet writer to wait for pending packets send
      • Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean

        log
    • Constructor Summary

      Constructors 
      Constructor Description
      ThrottlingChannelStreamWriter​(org.apache.sshd.common.channel.Channel channel)  
      ThrottlingChannelStreamWriter​(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, long maxWait)  
      ThrottlingChannelStreamWriter​(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, java.time.Duration maxWait)  
      ThrottlingChannelStreamWriter​(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, java.util.concurrent.TimeUnit waitUnit, long waitCount)  
      ThrottlingChannelStreamWriter​(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, org.apache.sshd.common.PropertyResolver resolver)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      int getAvailablePacketsCount()  
      org.apache.sshd.common.channel.throttle.ChannelStreamWriter getDelegate()  
      int getMaxPendingPackets()  
      long getMaxWait()  
      boolean isOpen()  
      void operationComplete​(org.apache.sshd.common.io.IoWriteFuture future)  
      java.lang.String toString()  
      org.apache.sshd.common.io.IoWriteFuture writeData​(org.apache.sshd.common.util.buffer.Buffer buffer)  
      • 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
    • Field Detail

      • WAIT_TIME

        public static final org.apache.sshd.common.Property<java.time.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<java.lang.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 java.util.concurrent.atomic.AtomicBoolean open
      • availableCount

        private final java.util.concurrent.atomic.AtomicInteger availableCount
    • Constructor Detail

      • 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,
                                             java.util.concurrent.TimeUnit waitUnit,
                                             long waitCount)
      • ThrottlingChannelStreamWriter

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

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

      • 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 java.nio.channels.Channel
      • writeData

        public org.apache.sshd.common.io.IoWriteFuture writeData​(org.apache.sshd.common.util.buffer.Buffer buffer)
                                                          throws java.io.IOException
        Specified by:
        writeData in interface org.apache.sshd.common.channel.throttle.ChannelStreamWriter
        Throws:
        java.io.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 java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object