final int NUM_MASTERS = 3;
final int NUM_RS = 3;
// Start the cluster
WaspTestingUtility TEST_UTIL = new WaspTestingUtility(conf);
TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
MiniWaspCluster cluster = TEST_UTIL.getWaspCluster();
// get all the master threads
List<MasterThread> masterThreads = cluster.getMasterThreads();
// wait for each to come online
for (MasterThread mt : masterThreads) {
assertTrue(mt.isAlive());
}
// find the active master
FMaster active = null;
for (int i = 0; i < masterThreads.size(); i++) {
if (masterThreads.get(i).getMaster().isActiveMaster()) {
active = masterThreads.get(i).getMaster();
break;
}
}
assertNotNull(active);
// make sure the other two are backup masters
ClusterStatus status = active.getClusterStatus();
assertEquals(2, status.getBackupMastersSize());
assertEquals(2, status.getBackupMasters().size());
// tell the active master to shutdown the cluster
active.shutdown();
for (int i = NUM_MASTERS - 1; i >= 0; --i) {
cluster.waitOnMaster(i);
}
// make sure all the masters properly shutdown
assertEquals(0, masterThreads.size());
TEST_UTIL.shutdownMiniCluster();
}