use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RecoverStandbyState.DISPATCH_WALS_VALUE in project hbase by apache.
the class TestRegisterPeerWorkerWhenRestarting method testRestart.
@Test
public void testRestart() throws Exception {
UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.STANDBY);
UTIL1.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.ACTIVE);
UTIL1.getAdmin().disableReplicationPeer(PEER_ID);
write(UTIL1, 0, 100);
Thread.sleep(2000);
// peer is disabled so no data have been replicated
verifyNotReplicatedThroughRegion(UTIL2, 0, 100);
// transit the A to DA first to avoid too many error logs.
UTIL1.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.DOWNGRADE_ACTIVE);
HMaster master = UTIL2.getHBaseCluster().getMaster();
// make sure the transiting can not succeed
FAIL = true;
ProcedureExecutor<MasterProcedureEnv> procExec = master.getMasterProcedureExecutor();
Thread t = new Thread() {
@Override
public void run() {
try {
UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.DOWNGRADE_ACTIVE);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
};
t.start();
// wait until we are in the states where we need to register peer worker when restarting
UTIL2.waitFor(60000, () -> procExec.getProcedures().stream().filter(p -> p instanceof RecoverStandbyProcedure).map(p -> (RecoverStandbyProcedure) p).anyMatch(p -> p.getCurrentStateId() == DISPATCH_WALS_VALUE || p.getCurrentStateId() == UNREGISTER_PEER_FROM_WORKER_STORAGE_VALUE));
// failover to another master
MasterThread mt = UTIL2.getMiniHBaseCluster().getMasterThread();
mt.getMaster().abort("for testing");
mt.join();
FAIL = false;
t.join();
// make sure the new master can finish the transition
UTIL2.waitFor(60000, () -> UTIL2.getAdmin().getReplicationPeerSyncReplicationState(PEER_ID) == SyncReplicationState.DOWNGRADE_ACTIVE);
verify(UTIL2, 0, 100);
}
Aggregations