Search in sources :

Example 1 with DisablePeerProcedure

use of org.apache.hadoop.hbase.master.replication.DisablePeerProcedure in project hbase by apache.

the class TestRefreshPeerWhileRegionServerRestarts method testRestart.

@Test
public void testRestart() throws Exception {
    UTIL1.getMiniHBaseCluster().getConfiguration().setClass(HConstants.REGION_SERVER_IMPL, RegionServerForTest.class, HRegionServer.class);
    CountDownLatch arrive = new CountDownLatch(1);
    ARRIVE = arrive;
    RESUME = new CountDownLatch(1);
    // restart a new region server, and wait until it finish initialization and want to call
    // regionServerReport, so it will load the peer state to peer cache.
    Future<HRegionServer> regionServerFuture = ForkJoinPool.commonPool().submit(() -> UTIL1.getMiniHBaseCluster().startRegionServer().getRegionServer());
    ARRIVE.await();
    // change the peer state, wait until it reach the last state, where we have already get the
    // region server list for refreshing
    Future<Void> future = hbaseAdmin.disableReplicationPeerAsync(PEER_ID2);
    try {
        UTIL1.waitFor(30000, () -> {
            for (Procedure<?> proc : UTIL1.getMiniHBaseCluster().getMaster().getProcedures()) {
                if (proc instanceof DisablePeerProcedure) {
                    return ((DisablePeerProcedure) proc).getCurrentStateId() == MasterProcedureProtos.PeerModificationState.POST_PEER_MODIFICATION_VALUE;
                }
            }
            return false;
        });
    } finally {
        // let the new region server go
        RESUME.countDown();
    }
    // wait the disable peer operation to finish
    future.get();
    // assert that the peer cache on the new region server has also been refreshed
    ReplicationPeer peer = regionServerFuture.get().getReplicationSourceService().getReplicationPeers().getPeer(PEER_ID2);
    assertEquals(PeerState.DISABLED, peer.getPeerState());
}
Also used : DisablePeerProcedure(org.apache.hadoop.hbase.master.replication.DisablePeerProcedure) CountDownLatch(java.util.concurrent.CountDownLatch) ReplicationPeer(org.apache.hadoop.hbase.replication.ReplicationPeer) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 DisablePeerProcedure (org.apache.hadoop.hbase.master.replication.DisablePeerProcedure)1 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)1 ReplicationPeer (org.apache.hadoop.hbase.replication.ReplicationPeer)1 Test (org.junit.Test)1