Search in sources :

Example 61 with HRegionServer

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

the class HBaseTestingUtil method assertRegionOnlyOnServer.

/**
 * Check to make sure the region is open on the specified region server, but not on any other one.
 */
public void assertRegionOnlyOnServer(final RegionInfo hri, final ServerName server, final long timeout) throws IOException, InterruptedException {
    long timeoutTime = EnvironmentEdgeManager.currentTime() + timeout;
    while (true) {
        List<RegionInfo> regions = getAdmin().getRegions(server);
        if (regions.stream().anyMatch(r -> RegionInfo.COMPARATOR.compare(r, hri) == 0)) {
            List<JVMClusterUtil.RegionServerThread> rsThreads = getHBaseCluster().getLiveRegionServerThreads();
            for (JVMClusterUtil.RegionServerThread rsThread : rsThreads) {
                HRegionServer rs = rsThread.getRegionServer();
                if (server.equals(rs.getServerName())) {
                    continue;
                }
                Collection<HRegion> hrs = rs.getOnlineRegionsLocalContext();
                for (HRegion r : hrs) {
                    assertTrue("Region should not be double assigned", r.getRegionInfo().getRegionId() != hri.getRegionId());
                }
            }
            // good, we are happy
            return;
        }
        long now = EnvironmentEdgeManager.currentTime();
        if (now > timeoutTime)
            break;
        Thread.sleep(10);
    }
    fail("Could not find region " + hri.getRegionNameAsString() + " on server " + server);
}
Also used : HRegion(org.apache.hadoop.hbase.regionserver.HRegion) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) RegionServerThread(org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) RegionServerThread(org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 62 with HRegionServer

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

the class TestChangingEncoding method compactAndWait.

private void compactAndWait() throws IOException, InterruptedException {
    LOG.debug("Compacting table " + tableName);
    HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
    Admin admin = TEST_UTIL.getAdmin();
    admin.majorCompact(tableName);
    // Waiting for the compaction to start, at least .5s.
    final long maxWaitime = EnvironmentEdgeManager.currentTime() + 500;
    boolean cont;
    do {
        cont = rs.getCompactSplitThread().getCompactionQueueSize() == 0;
        Threads.sleep(1);
    } while (cont && EnvironmentEdgeManager.currentTime() < maxWaitime);
    while (rs.getCompactSplitThread().getCompactionQueueSize() > 0) {
        Threads.sleep(1);
    }
    LOG.debug("Compaction queue size reached 0, continuing");
}
Also used : Admin(org.apache.hadoop.hbase.client.Admin) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 63 with HRegionServer

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

the class TestLoadAndSwitchEncodeOnDisk method loadTest.

@Override
@Test
public void loadTest() throws Exception {
    Admin admin = TEST_UTIL.getAdmin();
    // used for table setup
    compression = Compression.Algorithm.GZ;
    super.loadTest();
    ColumnFamilyDescriptor hcd = getColumnDesc(admin);
    System.err.println("\nDisabling encode-on-disk. Old column descriptor: " + hcd + "\n");
    Table t = TEST_UTIL.getConnection().getTable(TABLE);
    assertAllOnLine(t);
    admin.disableTable(TABLE);
    admin.modifyColumnFamily(TABLE, hcd);
    System.err.println("\nRe-enabling table\n");
    admin.enableTable(TABLE);
    System.err.println("\nNew column descriptor: " + getColumnDesc(admin) + "\n");
    // The table may not have all regions on line yet.  Assert online before
    // moving to major compact.
    assertAllOnLine(t);
    System.err.println("\nCompacting the table\n");
    admin.majorCompact(TABLE);
    // Wait until compaction completes
    Threads.sleepWithoutInterrupt(5000);
    HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
    while (rs.getCompactSplitThread().getCompactionQueueSize() > 0) {
        Threads.sleep(50);
    }
    System.err.println("\nDone with the test, shutting down the cluster\n");
}
Also used : Table(org.apache.hadoop.hbase.client.Table) Admin(org.apache.hadoop.hbase.client.Admin) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 64 with HRegionServer

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

the class TestSlowLogAccessor method setUp.

@Before
public void setUp() throws Exception {
    HRegionServer hRegionServer = HBASE_TESTING_UTILITY.getMiniHBaseCluster().getRegionServer(0);
    this.namedQueueRecorder = hRegionServer.getNamedQueueRecorder();
}
Also used : HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Before(org.junit.Before)

Example 65 with HRegionServer

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

the class TestAsyncRegionAdminApi method testFlushTableAndRegion.

@Test
public void testFlushTableAndRegion() throws Exception {
    RegionInfo hri = createTableAndGetOneRegion(tableName);
    ServerName serverName = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().getRegionStates().getRegionServerOfRegion(hri);
    HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getLiveRegionServerThreads().stream().map(rsThread -> rsThread.getRegionServer()).filter(rs -> rs.getServerName().equals(serverName)).findFirst().get();
    // write a put into the specific region
    ASYNC_CONN.getTable(tableName).put(new Put(hri.getStartKey()).addColumn(FAMILY, FAMILY_0, Bytes.toBytes("value-1"))).join();
    assertTrue(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreDataSize() > 0);
    // flush region and wait flush operation finished.
    LOG.info("flushing region: " + Bytes.toStringBinary(hri.getRegionName()));
    admin.flushRegion(hri.getRegionName()).get();
    LOG.info("blocking until flush is complete: " + Bytes.toStringBinary(hri.getRegionName()));
    Threads.sleepWithoutInterrupt(500);
    while (regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreDataSize() > 0) {
        Threads.sleep(50);
    }
    // check the memstore.
    assertEquals(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreDataSize(), 0);
    // write another put into the specific region
    ASYNC_CONN.getTable(tableName).put(new Put(hri.getStartKey()).addColumn(FAMILY, FAMILY_0, Bytes.toBytes("value-2"))).join();
    assertTrue(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreDataSize() > 0);
    admin.flush(tableName).get();
    Threads.sleepWithoutInterrupt(500);
    while (regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreDataSize() > 0) {
        Threads.sleep(50);
    }
    // check the memstore.
    assertEquals(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreDataSize(), 0);
}
Also used : TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) ClientTests(org.apache.hadoop.hbase.testclassification.ClientTests) ServerManager(org.apache.hadoop.hbase.master.ServerManager) ArrayList(java.util.ArrayList) RegionState(org.apache.hadoop.hbase.master.RegionState) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Configuration(org.apache.hadoop.conf.Configuration) Assert.fail(org.junit.Assert.fail) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ClassRule(org.junit.ClassRule) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) ServerName(org.apache.hadoop.hbase.ServerName) Threads(org.apache.hadoop.hbase.util.Threads) Parameterized(org.junit.runners.Parameterized) Bytes(org.apache.hadoop.hbase.util.Bytes) TableName(org.apache.hadoop.hbase.TableName) RegionStates(org.apache.hadoop.hbase.master.assignment.RegionStates) Assert.assertTrue(org.junit.Assert.assertTrue) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) CompactionConfiguration(org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration) LargeTests(org.apache.hadoop.hbase.testclassification.LargeTests) IOException(java.io.IOException) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) ExecutionException(java.util.concurrent.ExecutionException) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) List(java.util.List) Region(org.apache.hadoop.hbase.regionserver.Region) Assert.assertFalse(org.junit.Assert.assertFalse) EnvironmentEdgeManager(org.apache.hadoop.hbase.util.EnvironmentEdgeManager) HMaster(org.apache.hadoop.hbase.master.HMaster) Assert.assertEquals(org.junit.Assert.assertEquals) ServerName(org.apache.hadoop.hbase.ServerName) 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