static long calSleepTimeMs(long bytesRead, long maxBytesPerSec, long elapsed) {
    assert elapsed > 0 : "The elapsed time should be greater than zero";
    if (bytesRead <= 0 || maxBytesPerSec <= 0) {
      return 0;
    }
    // We use this class to load the single source file, so the bytesRead
    // and maxBytesPerSec aren't greater than Double.MAX_VALUE.
    // We can get the precise sleep time by using the double value.
    long rval = (long) ((((double) bytesRead) / ((double) maxBytesPerSec)) * 1000 - elapsed);
    if (rval <= 0) {
      return 0;
    } else {
      return rval;
    }
  }
Read bytes starting from the specified position. This requires rawStream is an instance of
{@link PositionedReadable}.
@return the number of bytes read
hbase-common/src/main/java/org/apache/hadoop/hbase/io/hadoopbackport/ThrottledInputStream.java