private void calculateGCTimePercentageWithinObservedInterval(
      long intervalStartTsNanos, long intervalEndTsNanos) {
    long gcTimeWithinSleepIntervalNanos =
        intervalEndTsNanos - intervalStartTsNanos - sleepIntervalMs * 1000000;
    long totalGcTimeNanos = curData.totalGcTimeNanos + gcTimeWithinSleepIntervalNanos;

    long gcMonitorRunTimeNanos = intervalEndTsNanos - startTimeNanos;

    endIdx = (endIdx + 1) % bufSize;
    gcDataBuf[endIdx].setValues(intervalEndTsNanos, gcTimeWithinSleepIntervalNanos);

    // Update the observation window so that it covers the last observationWindowNanos
    // period. For that, move startIdx forward until we reach the first buffer entry with
    // timestamp within the observation window.
    long startObsWindowTsNanos = intervalEndTsNanos - observationWindowNanos;
    while (gcDataBuf[startIdx].tsNanos < startObsWindowTsNanos && startIdx != endIdx) {
      startIdx = (startIdx + 1) % bufSize;
    }

    // Calculate total GC time within observationWindowMs.
    // We should be careful about GC time that passed before the first timestamp
    // in our observation window.
    long gcTimeWithinObservationWindowNanos = Math.min(
        gcDataBuf[startIdx].gcPauseNanos, gcDataBuf[startIdx].tsNanos - startObsWindowTsNanos);
    if (startIdx != endIdx) {
      for (int i = (startIdx + 1) % bufSize; i != endIdx;
           i = (i + 1) % bufSize) {
        gcTimeWithinObservationWindowNanos += gcDataBuf[i].gcPauseNanos;
      }
    }

    curData.update(gcMonitorRunTimeNanos, totalGcTimeNanos,
        (int) (gcTimeWithinObservationWindowNanos * 100 /
            Math.min(observationWindowNanos, gcMonitorRunTimeNanos)));
  }
Returns a copy of the most recent data measured by this monitor.
common/src/java/org/apache/hadoop/hive/common/GcTimeMonitor.java