Class ThrottlingChannelStreamWriter

    • Field Detail

      • WAIT_TIME

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

        public static final Property<java.lang.Integer> MAX_PEND_COUNT
        Max. pending packets count
      • 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​(Channel channel)
      • ThrottlingChannelStreamWriter

        public ThrottlingChannelStreamWriter​(ChannelStreamWriter delegate,
                                             int maxPendingPackets,
                                             java.util.concurrent.TimeUnit waitUnit,
                                             long waitCount)
      • ThrottlingChannelStreamWriter

        public ThrottlingChannelStreamWriter​(ChannelStreamWriter delegate,
                                             int maxPendingPackets,
                                             java.time.Duration maxWait)
      • ThrottlingChannelStreamWriter

        public ThrottlingChannelStreamWriter​(ChannelStreamWriter delegate,
                                             int maxPendingPackets,
                                             long maxWait)
    • Method Detail

      • 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 IoWriteFuture writeData​(Buffer buffer)
                                throws java.io.IOException
        Description copied from interface: ChannelStreamWriter
        Encode and send the given data packet buffer. Note: the buffer has to have 5 bytes free at the beginning to allow the encoding to take place. Also, the write position of the buffer has to be set to the position of the last byte to write.
        Specified by:
        writeData in interface ChannelStreamWriter
        Parameters:
        buffer - the buffer to encode and send. 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 packet has actually been sent
        Throws:
        java.io.IOException - if an error occurred when encoding or sending the packet
      • 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