private void keepConsistent() {
    if (currentPosition < pageStartPosition) {
      pageStartPosition = currentPosition;
      pageEndPosition = pageStartPosition + pageSize;
    } else if (currentPosition > recordsSize - 1) {
      currentPosition = recordsSize - 1;
      pageEndPosition = recordsSize;
      pageStartPosition = pageEndPosition - pageSize;
    } else if (currentPosition > pageEndPosition - 1) {
      pageEndPosition = currentPosition + 1;
      pageStartPosition = pageEndPosition - pageSize;
    }

    if (pageStartPosition < 0) {
      pageStartPosition = 0;
    }

    if (pageEndPosition > recordsSize) {
      pageEndPosition = recordsSize;
      pageStartPosition = pageEndPosition - pageSize;
      if (pageStartPosition < 0) {
        pageStartPosition = 0;
      }
    }
  }
Utility class for paging for the metrics.
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/Paging.java