private void checkLag(Table table, int rlen, int vlen, int rows) throws IOException {
    byte[] family = Bytes.toBytes(FAMILY_NAME);
    byte[] qualifier = Bytes.toBytes(QUALIFIER_NAME);
    LOG.info("Test replication lag on table {} with {} rows", table.getName(), rows);
    for (int i = 0; i < rows; i++) {
      byte[] row = new byte[rlen];
      Bytes.random(row);
      byte[] value = new byte[vlen];
      Bytes.random(value);
      table.put(new Put(row).addColumn(family, qualifier, value));
      // get from secondary replica
      Get get = new Get(row).setConsistency(Consistency.TIMELINE).setReplicaId(1);
      long startNs = System.nanoTime();
      for (int retry = 0;; retry++) {
        Result result = table.get(get);
        byte[] gotValue = result.getValue(family, qualifier);
        if (Arrays.equals(value, gotValue)) {
          break;
        }
        long pauseTimeMs = Math.min(ConnectionUtils.getPauseTime(1, retry), 1000);
        Threads.sleepWithoutInterrupt(pauseTimeMs);
      }
      long lagMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);
      histogram.add(lagMs, 1);
    }
    LOG.info("Test finished, min lag {} ms, max lag {} ms, mean lag {} ms", histogram.getMin(),
      histogram.getMax(), histogram.getMean());
    long[] q = histogram.getQuantiles(FastLongHistogram.DEFAULT_QUANTILES);
    for (int i = 0; i < q.length; i++) {
      LOG.info("{}% lag: {} ms", FastLongHistogram.DEFAULT_QUANTILES[i] * 100, q[i]);
    }
  }
A tool to evaluating the lag between primary replica and secondary replica.
<p/>
It simply adds a row to the primary replica, and then check how long before we can read it from
the secondary replica.
hbase-server/src/test/java/org/apache/hadoop/hbase/RegionReplicationLagEvaluation.java