Search in sources :

Example 16 with HRegionServer

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

the class TestScannerTimeout method test3686b.

/**
   * Make sure that no rows are lost if the scanner timeout is longer on the
   * client than the server, and the scan times out on the server but not the
   * client.
   * @throws Exception
   */
@Test(timeout = 300000)
public void test3686b() throws Exception {
    LOG.info("START ************ test3686b");
    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLE_NAME);
    Scan scan = new Scan();
    scan.setCaching(SCANNER_CACHING);
    // Set a very high timeout, we want to test what happens when a RS
    // fails but the region is recovered before the lease times out.
    // Since the RS is already created, this conf is client-side only for
    // this new table
    Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
    conf.setInt(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, SCANNER_TIMEOUT * 100);
    Connection connection = ConnectionFactory.createConnection(conf);
    Table higherScanTimeoutTable = connection.getTable(TABLE_NAME);
    ResultScanner r = higherScanTimeoutTable.getScanner(scan);
    int count = 1;
    r.next();
    // Sleep, allowing the scan to timeout on the server but not on the client.
    Thread.sleep(SCANNER_TIMEOUT + 2000);
    while (r.next() != null) {
        count++;
    }
    assertEquals(NB_ROWS, count);
    r.close();
    higherScanTimeoutTable.close();
    connection.close();
    LOG.info("END ************ END test3686b");
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 17 with HRegionServer

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

the class TestLoadAndSwitchEncodeOnDisk method loadTest.

@Test(timeout = TIMEOUT_MS)
public void loadTest() throws Exception {
    Admin admin = TEST_UTIL.getAdmin();
    // used for table setup
    compression = Compression.Algorithm.GZ;
    super.loadTest();
    HColumnDescriptor 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.compactSplitThread.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) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Admin(org.apache.hadoop.hbase.client.Admin) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 18 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 = System.currentTimeMillis() + 500;
    boolean cont;
    do {
        cont = rs.compactSplitThread.getCompactionQueueSize() == 0;
        Threads.sleep(1);
    } while (cont && System.currentTimeMillis() < maxWaitime);
    while (rs.compactSplitThread.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 19 with HRegionServer

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

the class TestRegionPlacement method verifyRegionServerUpdated.

/**
   * Verify all the online region servers has been updated to the
   * latest assignment plan
   * @param plan
   * @throws IOException
   */
private void verifyRegionServerUpdated(FavoredNodesPlan plan) throws IOException {
    // Verify all region servers contain the correct favored nodes information
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    for (int i = 0; i < SLAVES; i++) {
        HRegionServer rs = cluster.getRegionServer(i);
        for (Region region : rs.getOnlineRegions(TableName.valueOf("testRegionAssignment"))) {
            InetSocketAddress[] favoredSocketAddress = rs.getFavoredNodesForRegion(region.getRegionInfo().getEncodedName());
            List<ServerName> favoredServerList = plan.getAssignmentMap().get(region.getRegionInfo());
            // except for hbase:meta and ROOT
            if (favoredServerList == null) {
                HTableDescriptor desc = region.getTableDesc();
                // Verify they are ROOT and hbase:meta regions since no favored nodes
                assertNull(favoredSocketAddress);
                assertTrue("User region " + region.getTableDesc().getTableName() + " should have favored nodes", (desc.isRootRegion() || desc.isMetaRegion()));
            } else {
                // For user region, the favored nodes in the region server should be
                // identical to favored nodes in the assignmentPlan
                assertTrue(favoredSocketAddress.length == favoredServerList.size());
                assertTrue(favoredServerList.size() > 0);
                for (int j = 0; j < favoredServerList.size(); j++) {
                    InetSocketAddress addrFromRS = favoredSocketAddress[j];
                    InetSocketAddress addrFromPlan = InetSocketAddress.createUnresolved(favoredServerList.get(j).getHostname(), favoredServerList.get(j).getPort());
                    assertNotNull(addrFromRS);
                    assertNotNull(addrFromPlan);
                    assertTrue("Region server " + rs.getServerName().getHostAndPort() + " has the " + positions[j] + " for region " + region.getRegionInfo().getRegionNameAsString() + " is " + addrFromRS + " which is inconsistent with the plan " + addrFromPlan, addrFromRS.equals(addrFromPlan));
                }
            }
        }
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ServerName(org.apache.hadoop.hbase.ServerName) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) Region(org.apache.hadoop.hbase.regionserver.Region) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 20 with HRegionServer

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

the class TestWarmupRegion method testWarmup.

/**
   * Basic client side validation of HBASE-4536
   */
@Test
public void testWarmup() throws Exception {
    int serverid = 0;
    HRegion region = TEST_UTIL.getMiniHBaseCluster().getRegions(TABLENAME).get(0);
    HRegionInfo info = region.getRegionInfo();
    runwarmup();
    for (int i = 0; i < 10; i++) {
        HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(serverid);
        byte[] destName = Bytes.toBytes(rs.getServerName().toString());
        TEST_UTIL.getMiniHBaseCluster().getMaster().move(info.getEncodedNameAsBytes(), destName);
        serverid = (serverid + 1) % 2;
    }
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) HRegion(org.apache.hadoop.hbase.regionserver.HRegion) HRegion.warmupHRegion(org.apache.hadoop.hbase.regionserver.HRegion.warmupHRegion) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Aggregations

HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)121 Test (org.junit.Test)91 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)48 Table (org.apache.hadoop.hbase.client.Table)38 Region (org.apache.hadoop.hbase.regionserver.Region)33 TableName (org.apache.hadoop.hbase.TableName)32 ServerName (org.apache.hadoop.hbase.ServerName)26 MiniHBaseCluster (org.apache.hadoop.hbase.MiniHBaseCluster)25 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)22 IOException (java.io.IOException)21 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)21 Configuration (org.apache.hadoop.conf.Configuration)19 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)18 RegionServerThread (org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread)18 Ignore (org.junit.Ignore)16 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)15 Put (org.apache.hadoop.hbase.client.Put)14 Waiter (org.apache.hadoop.hbase.Waiter)12 Admin (org.apache.hadoop.hbase.client.Admin)11 ArrayList (java.util.ArrayList)10