@Override
    public void preScannerOpen(final ObserverContext<? extends RegionCoprocessorEnvironment> e,
      final Scan scan) throws IOException {

      int replicaId = e.getEnvironment().getRegion().getRegionInfo().getReplicaId();

      // Slow down with the primary meta region scan
      if (e.getEnvironment().getRegion().getRegionInfo().isMetaRegion() && (replicaId == 0)) {
        if (slowDownPrimaryMetaScan) {
          LOG.info("Scan with primary meta region, slow down a bit");
          try {
            Thread.sleep(META_SCAN_TIMEOUT_IN_MILLISEC - 50);
          } catch (InterruptedException ie) {
            // Ingore
          }
        }

        // Fail for the primary replica
        if (throwException) {
          LOG.info("Scan, throw Region Server Stopped Exceptoin for replica "
            + e.getEnvironment().getRegion().getRegionInfo());

          throw new RegionServerStoppedException(
            "Server " + e.getEnvironment().getServerName() + " not running");
        } else {
          LOG.info("Scan, We're replica region " + replicaId);
        }
      } else {
        LOG.info("Scan, We're replica region " + replicaId);
      }
    }
This copro is used to slow down the primary meta region scan a bit
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicaWithCluster.java