Search in sources :

Example 31 with HBaseIOException

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);
    }
}
Also used : HashMap(java.util.HashMap) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException)

Example 32 with HBaseIOException

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
    }
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Test(org.junit.Test)

Example 33 with HBaseIOException

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()));
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Test(org.junit.Test)

Example 34 with HBaseIOException

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"));
    }
}
Also used : LoadCounter(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) AssignProcedure(org.apache.hadoop.hbase.master.assignment.AssignProcedure) Test(org.junit.Test)

Example 35 with HBaseIOException

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);
}
Also used : BeforeClass(org.junit.BeforeClass) TimeoutException(java.util.concurrent.TimeoutException) ReportRegionStateTransitionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionResponse) ServerManager(org.apache.hadoop.hbase.master.ServerManager) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) HConstants(org.apache.hadoop.hbase.HConstants) PleaseHoldException(org.apache.hadoop.hbase.PleaseHoldException) Configuration(org.apache.hadoop.conf.Configuration) MasterServices(org.apache.hadoop.hbase.master.MasterServices) ClassRule(org.junit.ClassRule) ServerName(org.apache.hadoop.hbase.ServerName) Bytes(org.apache.hadoop.hbase.util.Bytes) TableName(org.apache.hadoop.hbase.TableName) MasterRegion(org.apache.hadoop.hbase.master.region.MasterRegion) AfterClass(org.junit.AfterClass) ProtobufUtil(org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) MediumTests(org.apache.hadoop.hbase.testclassification.MediumTests) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) IOException(java.io.IOException) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) ReportRegionStateTransitionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) RegionPlan(org.apache.hadoop.hbase.master.RegionPlan) MasterTests(org.apache.hadoop.hbase.testclassification.MasterTests) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) HMaster(org.apache.hadoop.hbase.master.HMaster) RegionPlan(org.apache.hadoop.hbase.master.RegionPlan) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) CountDownLatch(java.util.concurrent.CountDownLatch) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)36 IOException (java.io.IOException)19 ServerName (org.apache.hadoop.hbase.ServerName)17 ArrayList (java.util.ArrayList)13 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)13 List (java.util.List)8 HashMap (java.util.HashMap)7 InterruptedIOException (java.io.InterruptedIOException)5 Map (java.util.Map)5 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)5 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)5 Test (org.junit.Test)5 TreeMap (java.util.TreeMap)4 Configuration (org.apache.hadoop.conf.Configuration)4 NonNull (edu.umd.cs.findbugs.annotations.NonNull)3 ExecutionException (java.util.concurrent.ExecutionException)3 RegionLocations (org.apache.hadoop.hbase.RegionLocations)3 TableName (org.apache.hadoop.hbase.TableName)3 FavoredNodeAssignmentHelper (org.apache.hadoop.hbase.favored.FavoredNodeAssignmentHelper)3 RSGroupAdminEndpoint (org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint)3