Class BandwidthThrottlerImpl

  • All Implemented Interfaces:
    BandwidthThrottler

    public class BandwidthThrottlerImpl
    extends Object
    implements BandwidthThrottler
    A bandwidth throttler for output stream (i.e. upload).

    The maximum upstream kbps can be set via setUpstreamKbps(long). Note that, 'byte' will be explicitly called out. Any 'b' or 'B' (in variable names with camel case) will refer to bit.

    TODO: implement for input.

    • Constructor Detail

      • BandwidthThrottlerImpl

        public BandwidthThrottlerImpl​(long maxBps)
    • Method Detail

      • setAbsoluteMaxBps

        public void setAbsoluteMaxBps​(long maxBps)
      • setUpstreamKbps

        public void setUpstreamKbps​(long kbps)
        Description copied from interface: BandwidthThrottler
        Set upload max bandwidth in kilobits per seconds.
        Specified by:
        setUpstreamKbps in interface BandwidthThrottler
        Parameters:
        kbps - max bandwidth in kbps
      • getAllowedBytes

        public int getAllowedBytes​(int len)
        Description copied from interface: BandwidthThrottler
        Get the allowed number of bytes to read from or write to socket.
        Specified by:
        getAllowedBytes in interface BandwidthThrottler
        Parameters:
        len - maximum number of bytes.
        Returns:
        allowed bytes