Class ThrottledInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class ThrottledInputStream
    extends CountingInputStream
    Provides bandwidth throttling on a specified InputStream. It is implemented as a wrapper on top of another InputStream instance. The throttling works by examining the number of bytes read from the underlying InputStream from the beginning, and sleep()ing for a time interval if the byte-transfer is found exceed the specified tolerable maximum. (Thus, while the read-rate might exceed the maximum for a short interval, the average tends towards the specified maximum, overall.)

    To build an instance, see ThrottledInputStream.Builder

    Inspired by Apache HBase's class of the same name.

    Since:
    2.16.0
    See Also:
    ThrottledInputStream.Builder