@Test
  public void testReplicationStatus() throws Exception {
    // This test wants two RS's up. We only run one generally so add one.
    UTIL1.getMiniHBaseCluster().startRegionServer();
    Waiter.waitFor(UTIL1.getConfiguration(), 30000, new Waiter.Predicate<Exception>() {
      @Override
      public boolean evaluate() throws Exception {
        return UTIL1.getMiniHBaseCluster().getLiveRegionServerThreads().size() > 1;
      }
    });
    Admin hbaseAdmin = UTIL1.getAdmin();
    // disable peer <= WHY? I DON'T GET THIS DISABLE BUT TEST FAILS W/O IT.
    hbaseAdmin.disableReplicationPeer(PEER_ID2);
    insertRowsOnSource();
    LOG.info("AFTER PUTS");
    // TODO: Change this wait to a barrier. I tried waiting on replication stats to
    // change but sleeping in main thread seems to mess up background replication.
    // HACK! To address flakeyness.
    Threads.sleep(10000);
    ClusterMetrics metrics = hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS));
    for (JVMClusterUtil.RegionServerThread thread : UTIL1.getHBaseCluster()
      .getRegionServerThreads()) {
      ServerName server = thread.getRegionServer().getServerName();
      assertTrue("" + server, metrics.getLiveServerMetrics().containsKey(server));
      ServerMetrics sm = metrics.getLiveServerMetrics().get(server);
      List<ReplicationLoadSource> rLoadSourceList = sm.getReplicationLoadSourceList();
      ReplicationLoadSink rLoadSink = sm.getReplicationLoadSink();

      // check SourceList only has one entry, because only has one peer
      assertEquals("Failed to get ReplicationLoadSourceList " + rLoadSourceList + ", " + server, 1,
        rLoadSourceList.size());
      assertEquals(PEER_ID2, rLoadSourceList.get(0).getPeerID());

      // check Sink exist only as it is difficult to verify the value on the fly
      assertTrue("failed to get ReplicationLoadSink.AgeOfLastShippedOp ",
        (rLoadSink.getAgeOfLastAppliedOp() >= 0));
      assertTrue("failed to get ReplicationLoadSink.TimeStampsOfLastAppliedOp ",
        (rLoadSink.getTimestampsOfLastAppliedOp() >= 0));
    }

    // Stop rs1, then the queue of rs1 will be transfered to rs0
    HRegionServer hrs = UTIL1.getHBaseCluster().getRegionServer(1);
    hrs.stop("Stop RegionServer");
    while (hrs.isAlive()) {
      Threads.sleep(100);
    }
    // To be sure it dead and references cleaned up. TODO: Change this to a barrier.
    // I tried waiting on replication stats to change but sleeping in main thread
    // seems to mess up background replication.
    Threads.sleep(10000);
    ServerName server = UTIL1.getHBaseCluster().getRegionServer(0).getServerName();
    List<ReplicationLoadSource> rLoadSourceList = waitOnMetricsReport(1, server);
    // The remaining server should now have two queues -- the original and then the one that was
    // added because of failover. The original should still be PEER_ID2 though.
    assertEquals("Failed ReplicationLoadSourceList " + rLoadSourceList, 2, rLoadSourceList.size());
    assertEquals(PEER_ID2, rLoadSourceList.get(0).getPeerID());
  }
Test for HBASE-9531.
<p/>
put a few rows into htable1, which should be replicated to htable2 <br/>
create a ClusterStatus instance 'status' from HBaseAdmin <br/>
test : status.getLoad(server).getReplicationLoadSourceList() <br/>
test : status.getLoad(server).getReplicationLoadSink()
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStatus.java