public long getNextSleepInterval(final int size) {
    if (!this.enabled) {
      return 0;
    }

    long sleepTicks = 0;
    long now = EnvironmentEdgeManager.currentTime();
    // 1. if cyclePushSize exceeds bandwidth, we need to sleep some
    // following cycles to amortize, this case can occur when a single push
    // exceeds the bandwidth
    if ((double) this.cyclePushSize > bandwidth) {
      double cycles = Math.ceil((double) this.cyclePushSize / bandwidth);
      long shouldTillTo = this.cycleStartTick + (long) (cycles * 100);
      if (shouldTillTo > now) {
        sleepTicks = shouldTillTo - now;
      } else {
        // no reset in shipEdits since no sleep, so we need to reset cycleStartTick here!
        this.cycleStartTick = now;
      }
      this.cyclePushSize = 0;
    } else {
      long nextCycleTick = this.cycleStartTick + 100; // a cycle is 100ms
      if (now >= nextCycleTick) {
        // 2. switch to next cycle if the current cycle has passed
        this.cycleStartTick = now;
        this.cyclePushSize = 0;
      } else if (this.cyclePushSize > 0 && (double) (this.cyclePushSize + size) >= bandwidth) {
        // 3. delay the push to next cycle if exceeds throttling bandwidth.
        // enforcing cyclePushSize > 0 to avoid the unnecessary sleep for case
        // where a cycle's first push size(currentSize) > bandwidth
        sleepTicks = nextCycleTick - now;
        this.cyclePushSize = 0;
      }
    }
    return sleepTicks;
  }
Get how long the caller should sleep according to the current size and current cycle's total
push size and start tick, return the sleep interval for throttling control.
@param size is the size of edits to be pushed
@return sleep interval for throttling control
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationThrottler.java