Search in sources :

Example 96 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class TestFromClientSide3 method find.

private static HRegion find(final TableName tableName) throws IOException, InterruptedException {
    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(tableName);
    List<HRegion> regions = rs.getRegions(tableName);
    assertEquals(1, regions.size());
    return regions.get(0);
}
Also used : HRegion(org.apache.hadoop.hbase.regionserver.HRegion) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 97 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class TestFlushFromClient method testFlushRegionServer.

@Test
public void testFlushRegionServer() throws Exception {
    try (Admin admin = TEST_UTIL.getAdmin()) {
        for (HRegionServer rs : TEST_UTIL.getHBaseCluster().getLiveRegionServerThreads().stream().map(JVMClusterUtil.RegionServerThread::getRegionServer).collect(Collectors.toList())) {
            admin.flushRegionServer(rs.getServerName());
            assertFalse(getRegionInfo(rs).stream().anyMatch(r -> r.getMemStoreDataSize() != 0));
        }
    }
}
Also used : Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) LoggerFactory(org.slf4j.LoggerFactory) ClientTests(org.apache.hadoop.hbase.testclassification.ClientTests) TestName(org.junit.rules.TestName) After(org.junit.After) ClassRule(org.junit.ClassRule) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) Bytes(org.apache.hadoop.hbase.util.Bytes) Before(org.junit.Before) TableName(org.apache.hadoop.hbase.TableName) AfterClass(org.junit.AfterClass) Logger(org.slf4j.Logger) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) MediumTests(org.apache.hadoop.hbase.testclassification.MediumTests) HRegion(org.apache.hadoop.hbase.regionserver.HRegion) Assert.assertTrue(org.junit.Assert.assertTrue) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) IOUtils(org.apache.hadoop.io.IOUtils) List(java.util.List) Rule(org.junit.Rule) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertEquals(org.junit.Assert.assertEquals) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 98 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class TestFlushFromClient method testAsyncFlushRegionServer.

@Test
public void testAsyncFlushRegionServer() throws Exception {
    AsyncAdmin admin = asyncConn.getAdmin();
    for (HRegionServer rs : TEST_UTIL.getHBaseCluster().getLiveRegionServerThreads().stream().map(JVMClusterUtil.RegionServerThread::getRegionServer).collect(Collectors.toList())) {
        admin.flushRegionServer(rs.getServerName()).get();
        assertFalse(getRegionInfo(rs).stream().anyMatch(r -> r.getMemStoreDataSize() != 0));
    }
}
Also used : Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) LoggerFactory(org.slf4j.LoggerFactory) ClientTests(org.apache.hadoop.hbase.testclassification.ClientTests) TestName(org.junit.rules.TestName) After(org.junit.After) ClassRule(org.junit.ClassRule) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) Bytes(org.apache.hadoop.hbase.util.Bytes) Before(org.junit.Before) TableName(org.apache.hadoop.hbase.TableName) AfterClass(org.junit.AfterClass) Logger(org.slf4j.Logger) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) MediumTests(org.apache.hadoop.hbase.testclassification.MediumTests) HRegion(org.apache.hadoop.hbase.regionserver.HRegion) Assert.assertTrue(org.junit.Assert.assertTrue) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) IOUtils(org.apache.hadoop.io.IOUtils) List(java.util.List) Rule(org.junit.Rule) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertEquals(org.junit.Assert.assertEquals) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 99 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class TestFavoredStochasticBalancerPickers method getTableRegionsFromServer.

private List<RegionInfo> getTableRegionsFromServer(TableName tableName, ServerName source) throws IOException {
    List<RegionInfo> regionInfos = Lists.newArrayList();
    HRegionServer regionServer = cluster.getRegionServer(source);
    for (Region region : regionServer.getRegions(tableName)) {
        regionInfos.add(region.getRegionInfo());
    }
    return regionInfos;
}
Also used : HRegion(org.apache.hadoop.hbase.regionserver.HRegion) Region(org.apache.hadoop.hbase.regionserver.Region) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 100 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class TestExceptionInAssignRegion method testExceptionInAssignRegion.

@Test
public void testExceptionInAssignRegion() {
    ProcedureExecutor procedureExecutor = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
    JVMClusterUtil.RegionServerThread rsThread = null;
    for (JVMClusterUtil.RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
        if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) {
            rsThread = t;
            break;
        }
    }
    // find the rs and hri of the table
    HRegionServer rs = rsThread.getRegionServer();
    RegionInfo hri = rs.getRegions(TABLE_NAME).get(0).getRegionInfo();
    TransitRegionStateProcedure assignRegionProcedure = TransitRegionStateProcedure.move(UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment(), hri, null);
    RegionStateNode regionNode = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionStates().getOrCreateRegionStateNode(hri);
    regionNode.setProcedure(assignRegionProcedure);
    countDownLatch.countDown();
    long prodId = procedureExecutor.submitProcedure(assignRegionProcedure);
    ProcedureTestingUtility.waitProcedure(procedureExecutor, prodId);
    Assert.assertEquals("Should be two RS since other is aborted", 2, UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size());
    Assert.assertNull("RIT Map doesn't have correct value", getRegionServer(0).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
    Assert.assertNull("RIT Map doesn't have correct value", getRegionServer(1).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
    Assert.assertNull("RIT Map doesn't have correct value", getRegionServer(2).getRegionsInTransitionInRS().get(hri.getEncodedNameAsBytes()));
}
Also used : ProcedureExecutor(org.apache.hadoop.hbase.procedure2.ProcedureExecutor) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Aggregations

HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)253 Test (org.junit.Test)188 TableName (org.apache.hadoop.hbase.TableName)70 Table (org.apache.hadoop.hbase.client.Table)67 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)59 IOException (java.io.IOException)53 Region (org.apache.hadoop.hbase.regionserver.Region)49 Configuration (org.apache.hadoop.conf.Configuration)47 ServerName (org.apache.hadoop.hbase.ServerName)46 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)41 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)41 Put (org.apache.hadoop.hbase.client.Put)39 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)32 RegionServerThread (org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread)32 JVMClusterUtil (org.apache.hadoop.hbase.util.JVMClusterUtil)23 List (java.util.List)22 HMaster (org.apache.hadoop.hbase.master.HMaster)22 ArrayList (java.util.ArrayList)21 HBaseClassTestRule (org.apache.hadoop.hbase.HBaseClassTestRule)21 Waiter (org.apache.hadoop.hbase.Waiter)21