use of org.apache.hadoop.hbase.HBaseIOException in project hbase by apache.
the class FavoredNodeLoadBalancer method randomAssignment.
@Override
public ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws HBaseIOException {
try {
FavoredNodeAssignmentHelper assignmentHelper = new FavoredNodeAssignmentHelper(servers, rackManager);
assignmentHelper.initialize();
ServerName primary = super.randomAssignment(regionInfo, servers);
if (!FavoredNodesManager.isFavoredNodeApplicable(regionInfo) || !assignmentHelper.canPlaceFavoredNodes()) {
return primary;
}
List<ServerName> favoredNodes = fnm.getFavoredNodes(regionInfo);
// server as well (available servers, that is)
if (favoredNodes != null) {
for (ServerName s : favoredNodes) {
ServerName serverWithLegitStartCode = availableServersContains(servers, s);
if (serverWithLegitStartCode != null) {
return serverWithLegitStartCode;
}
}
}
List<RegionInfo> regions = new ArrayList<>(1);
regions.add(regionInfo);
Map<RegionInfo, ServerName> primaryRSMap = new HashMap<>(1);
primaryRSMap.put(regionInfo, primary);
assignSecondaryAndTertiaryNodesForRegion(assignmentHelper, regions, primaryRSMap);
return primary;
} catch (Exception ex) {
LOG.warn("Encountered exception while doing favored-nodes (random)assignment " + ex + " Falling back to regular assignment");
return super.randomAssignment(regionInfo, servers);
}
}
use of org.apache.hadoop.hbase.HBaseIOException in project hbase by apache.
the class TestAssignmentManagerUtil method testCreateUnassignProcedureForSplitFail.
@Test
public void testCreateUnassignProcedureForSplitFail() throws IOException {
RegionInfo region = getPrimaryRegions().get(0);
AM.getRegionStates().getRegionStateNode(region).setProcedure(TransitRegionStateProcedure.unassign(ENV, region));
try {
AssignmentManagerUtil.createUnassignProceduresForSplitOrMerge(ENV, Stream.of(region), REGION_REPLICATION);
fail("Should fail as the region is in transition");
} catch (HBaseIOException e) {
// expected
}
}
use of org.apache.hadoop.hbase.HBaseIOException in project hbase by apache.
the class TestAssignmentManagerUtil method testCreateUnassignProceduresForMergeFail.
@Test
public void testCreateUnassignProceduresForMergeFail() throws IOException {
List<RegionInfo> regions = getPrimaryRegions();
RegionInfo regionA = regions.get(0);
RegionInfo regionB = regions.get(1);
AM.getRegionStates().getRegionStateNode(regionB).setProcedure(TransitRegionStateProcedure.unassign(ENV, regionB));
try {
AssignmentManagerUtil.createUnassignProceduresForSplitOrMerge(ENV, Stream.of(regionA, regionB), REGION_REPLICATION);
fail("Should fail as the region is in transition");
} catch (HBaseIOException e) {
// expected
}
IntStream.range(0, REGION_REPLICATION).mapToObj(i -> RegionReplicaUtil.getRegionInfoForReplica(regionA, i)).map(AM.getRegionStates()::getRegionStateNode).forEachOrdered(rn -> assertFalse("Should have unset the proc for " + rn, rn.isInTransition()));
}
use of org.apache.hadoop.hbase.HBaseIOException in project hbase by apache.
the class TestRegionProcedureStoreMigration method testMigrateWithUnsupportedProcedures.
@Test
public void testMigrateWithUnsupportedProcedures() throws IOException {
AssignProcedure assignProc = new AssignProcedure();
assignProc.setProcId(1L);
assignProc.setRegionInfo(RegionInfoBuilder.newBuilder(TableName.valueOf("table")).build());
walStore.insert(assignProc, null);
walStore.stop(true);
try {
store = RegionProcedureStoreTestHelper.createStore(server, region, new LoadCounter());
fail("Should fail since AssignProcedure is not supported");
} catch (HBaseIOException e) {
assertThat(e.getMessage(), startsWith("Unsupported"));
}
}
use of org.apache.hadoop.hbase.HBaseIOException in project hbase by apache.
the class TestReportRegionStateTransitionFromDeadServer method test.
@Test
public void test() throws HBaseIOException, InterruptedException, ExecutionException {
RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(NAME).get(0).getRegionInfo();
AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
RegionStateNode rsn = am.getRegionStates().getRegionStateNode(region);
// move from rs0 to rs1, and then kill rs0. Later add rs1 to exclude servers, and at last verify
// that the region should not be on rs1 and rs2 both.
HRegionServer rs0 = UTIL.getMiniHBaseCluster().getRegionServer(rsn.getRegionLocation());
HRegionServer rs1 = UTIL.getOtherRegionServer(rs0);
HRegionServer rs2 = UTIL.getMiniHBaseCluster().getRegionServerThreads().stream().map(t -> t.getRegionServer()).filter(rs -> rs != rs0 && rs != rs1).findAny().get();
RESUME_REPORT = new CountDownLatch(1);
ARRIVE_REPORT = new CountDownLatch(1);
Future<?> future = am.moveAsync(new RegionPlan(region, rs0.getServerName(), rs1.getServerName()));
ARRIVE_REPORT.await();
RESUME_GET_REGIONS = new CountDownLatch(1);
ARRIVE_GET_REGIONS = new CountDownLatch(1);
rs0.abort("For testing!");
ARRIVE_GET_REGIONS.await();
RESUME_REPORT.countDown();
try {
future.get(15, TimeUnit.SECONDS);
} catch (TimeoutException e) {
// after the fix in HBASE-21508 we will get this exception as the TRSP can not be finished any
// more before SCP interrupts it. It's OK.
}
EXCLUDE_SERVERS.add(rs1.getServerName());
RESUME_GET_REGIONS.countDown();
// wait until there are no running procedures, no SCP and no TRSP
UTIL.waitFor(30000, () -> UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getActiveProcIds().isEmpty());
boolean onRS1 = !rs1.getRegions(NAME).isEmpty();
boolean onRS2 = !rs2.getRegions(NAME).isEmpty();
assertNotEquals("should either be on rs1 or rs2, but onRS1 is " + onRS1 + " and on RS2 is " + onRS2, onRS1, onRS2);
}
Aggregations