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());
}
Aggregations