use of org.apache.hadoop.hbase.master.assignment.AssignmentManager in project hbase by apache.
the class ServerCrashProcedure method zkCoordinatedSplitMetaLogs.
/**
* Split hbase:meta logs using 'classic' zk-based coordination.
* Superceded by procedure-based WAL splitting.
* @see #createSplittingWalProcedures(MasterProcedureEnv, boolean)
*/
private void zkCoordinatedSplitMetaLogs(MasterProcedureEnv env) throws IOException {
LOG.debug("Splitting meta WALs {}", this);
MasterWalManager mwm = env.getMasterServices().getMasterWalManager();
AssignmentManager am = env.getMasterServices().getAssignmentManager();
am.getRegionStates().metaLogSplitting(serverName);
mwm.splitMetaLog(serverName);
am.getRegionStates().metaLogSplit(serverName);
LOG.debug("Done splitting meta WALs {}", this);
}
use of org.apache.hadoop.hbase.master.assignment.AssignmentManager in project hbase by apache.
the class HBaseTestingUtil method assignRegion.
/**
* Uses directly the assignment manager to assign the region. and waits until the specified region
* has completed assignment.
* @return true if the region is assigned false otherwise.
*/
public boolean assignRegion(final RegionInfo regionInfo) throws IOException, InterruptedException {
final AssignmentManager am = getHBaseCluster().getMaster().getAssignmentManager();
am.assign(regionInfo);
return AssignmentTestingUtil.waitForAssignment(am, regionInfo);
}
use of org.apache.hadoop.hbase.master.assignment.AssignmentManager in project hbase by apache.
the class TestAsyncRegionAdminApi method testAssignRegionAndUnassignRegion.
@Test
public void testAssignRegionAndUnassignRegion() throws Exception {
createTableWithDefaultConf(tableName);
// assign region.
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
AssignmentManager am = master.getAssignmentManager();
RegionInfo hri = am.getRegionStates().getRegionsOfTable(tableName).get(0);
// assert region on server
RegionStates regionStates = am.getRegionStates();
ServerName serverName = regionStates.getRegionServerOfRegion(hri);
TEST_UTIL.assertRegionOnServer(hri, serverName, 200);
assertTrue(regionStates.getRegionState(hri).isOpened());
// Master should not abort, and region should stay assigned.
try {
admin.assign(hri.getRegionName()).get();
fail("Should fail when assigning an already onlined region");
} catch (ExecutionException e) {
// Expected
assertThat(e.getCause(), instanceOf(DoNotRetryRegionException.class));
}
assertFalse(am.getRegionStates().getRegionStateNode(hri).isInTransition());
assertTrue(regionStates.getRegionState(hri).isOpened());
// unassign region
admin.unassign(hri.getRegionName(), true).get();
assertFalse(am.getRegionStates().getRegionStateNode(hri).isInTransition());
assertTrue(regionStates.getRegionState(hri).isClosed());
}
use of org.apache.hadoop.hbase.master.assignment.AssignmentManager in project hbase by apache.
the class TestFailedMetaReplicaAssigment method testFailedReplicaAssignment.
@Test
public void testFailedReplicaAssignment() throws InterruptedException {
HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
// waiting for master to come up
TEST_UTIL.waitFor(30000, () -> master.isInitialized());
AssignmentManager am = master.getAssignmentManager();
// showing one of the replicas got assigned
RegionInfo metaReplicaHri = RegionReplicaUtil.getRegionInfoForReplica(RegionInfoBuilder.FIRST_META_REGIONINFO, 1);
// we use assignAsync so we need to wait a bit
TEST_UTIL.waitFor(30000, () -> {
RegionStateNode metaReplicaRegionNode = am.getRegionStates().getOrCreateRegionStateNode(metaReplicaHri);
return metaReplicaRegionNode.getRegionLocation() != null;
});
// showing one of the replicas failed to be assigned
RegionInfo metaReplicaHri2 = RegionReplicaUtil.getRegionInfoForReplica(RegionInfoBuilder.FIRST_META_REGIONINFO, 2);
RegionStateNode metaReplicaRegionNode2 = am.getRegionStates().getOrCreateRegionStateNode(metaReplicaHri2);
// wait for several seconds to make sure that it is not assigned
for (int i = 0; i < 3; i++) {
Thread.sleep(2000);
assertNull(metaReplicaRegionNode2.getRegionLocation());
}
// showing master is active and running
assertFalse(master.isStopping());
assertFalse(master.isStopped());
assertTrue(master.isActiveMaster());
}
use of org.apache.hadoop.hbase.master.assignment.AssignmentManager in project hbase by apache.
the class MasterProcedureTestingUtility method restartMasterProcedureExecutor.
public static void restartMasterProcedureExecutor(ProcedureExecutor<MasterProcedureEnv> procExec) throws Exception {
final MasterProcedureEnv env = procExec.getEnvironment();
final HMaster master = (HMaster) env.getMasterServices();
ProcedureTestingUtility.restart(procExec, true, true, // stop services
new Callable<Void>() {
@Override
public Void call() throws Exception {
AssignmentManager am = env.getAssignmentManager();
// try to simulate a master restart by removing the ServerManager states about seqIDs
for (RegionState regionState : am.getRegionStates().getRegionStates()) {
env.getMasterServices().getServerManager().removeRegion(regionState.getRegion());
}
am.stop();
master.setInitialized(false);
return null;
}
}, // setup RIT before starting workers
new Callable<Void>() {
@Override
public Void call() throws Exception {
AssignmentManager am = env.getAssignmentManager();
am.start();
// just follow the same way with HMaster.finishActiveMasterInitialization. See the
// comments there
am.setupRIT(procExec.getActiveProceduresNoCopy().stream().filter(p -> !p.isSuccess()).filter(p -> p instanceof TransitRegionStateProcedure).map(p -> (TransitRegionStateProcedure) p).collect(Collectors.toList()));
return null;
}
}, // restart services
new Callable<Void>() {
@Override
public Void call() throws Exception {
AssignmentManager am = env.getAssignmentManager();
try {
am.joinCluster();
am.wakeMetaLoadedEvent();
master.setInitialized(true);
} catch (Exception e) {
LOG.warn("Failed to load meta", e);
}
return null;
}
});
}
Aggregations