Search in sources :

Example 21 with HRegionServer

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

the class TestRegionLocationFinder method testGetTopBlockLocations.

@Test
public void testGetTopBlockLocations() throws Exception {
    for (int i = 0; i < ServerNum; i++) {
        HRegionServer server = cluster.getRegionServer(i);
        for (Region region : server.getOnlineRegions(tableName)) {
            List<ServerName> servers = finder.getTopBlockLocations(region.getRegionInfo());
            // test table may have empty region
            if (region.getHDFSBlocksDistribution().getUniqueBlocksTotalWeight() == 0) {
                continue;
            }
            List<String> topHosts = region.getHDFSBlocksDistribution().getTopHosts();
            // rs and datanode may have different host in local machine test
            if (!topHosts.contains(server.getServerName().getHostname())) {
                continue;
            }
            for (int j = 0; j < ServerNum; j++) {
                ServerName serverName = cluster.getRegionServer(j).getServerName();
                assertTrue(servers.contains(serverName));
            }
        }
    }
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) Region(org.apache.hadoop.hbase.regionserver.Region) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 22 with HRegionServer

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

the class TestRegionLocationFinder method testMapHostNameToServerName.

@Test
public void testMapHostNameToServerName() throws Exception {
    List<String> topHosts = new ArrayList<>();
    for (int i = 0; i < ServerNum; i++) {
        HRegionServer server = cluster.getRegionServer(i);
        String serverHost = server.getServerName().getHostname();
        if (!topHosts.contains(serverHost)) {
            topHosts.add(serverHost);
        }
    }
    List<ServerName> servers = finder.mapHostNameToServerName(topHosts);
    // mini cluster, all rs in one host
    assertEquals(1, topHosts.size());
    for (int i = 0; i < ServerNum; i++) {
        ServerName server = cluster.getRegionServer(i).getServerName();
        assertTrue(servers.contains(server));
    }
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 23 with HRegionServer

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

the class TestLogRollAbort method testRSAbortWithUnflushedEdits.

/**
   * Tests that RegionServer aborts if we hit an error closing the WAL when
   * there are unsynced WAL edits.  See HBASE-4282.
   */
@Test
public void testRSAbortWithUnflushedEdits() throws Exception {
    LOG.info("Starting testRSAbortWithUnflushedEdits()");
    // When the hbase:meta table can be opened, the region servers are running
    TEST_UTIL.getConnection().getTable(TableName.META_TABLE_NAME).close();
    // Create the test table and open it
    TableName tableName = TableName.valueOf(this.getClass().getSimpleName());
    HTableDescriptor desc = new HTableDescriptor(tableName);
    desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
    admin.createTable(desc);
    Table table = TEST_UTIL.getConnection().getTable(desc.getTableName());
    try {
        HRegionServer server = TEST_UTIL.getRSForFirstRegionInTable(tableName);
        WAL log = server.getWAL(null);
        Put p = new Put(Bytes.toBytes("row2001"));
        p.addColumn(HConstants.CATALOG_FAMILY, Bytes.toBytes("col"), Bytes.toBytes(2001));
        table.put(p);
        log.sync();
        p = new Put(Bytes.toBytes("row2002"));
        p.addColumn(HConstants.CATALOG_FAMILY, Bytes.toBytes("col"), Bytes.toBytes(2002));
        table.put(p);
        dfsCluster.restartDataNodes();
        LOG.info("Restarted datanodes");
        try {
            log.rollWriter(true);
        } catch (FailedLogCloseException flce) {
        // Expected exception.  We used to expect that there would be unsynced appends but this
        // not reliable now that sync plays a roll in wall rolling.  The above puts also now call
        // sync.
        } catch (Throwable t) {
            LOG.fatal("FAILED TEST: Got wrong exception", t);
        }
    } finally {
        table.close();
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Table(org.apache.hadoop.hbase.client.Table) WAL(org.apache.hadoop.hbase.wal.WAL) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Put(org.apache.hadoop.hbase.client.Put) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Example 24 with HRegionServer

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

the class TestFlushWithThroughputController method getStoreWithName.

private Store getStoreWithName(TableName tableName) {
    MiniHBaseCluster cluster = hbtu.getMiniHBaseCluster();
    List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads();
    for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) {
        HRegionServer hrs = rsts.get(i).getRegionServer();
        for (Region region : hrs.getOnlineRegions(tableName)) {
            return region.getStores().iterator().next();
        }
    }
    return null;
}
Also used : MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) Region(org.apache.hadoop.hbase.regionserver.Region) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 25 with HRegionServer

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

the class AbstractTestLogRollPeriod method testNoEdits.

/**
   * Tests that the LogRoller perform the roll even if there are no edits
   */
@Test
public void testNoEdits() throws Exception {
    TableName tableName = TableName.valueOf("TestLogRollPeriodNoEdits");
    TEST_UTIL.createTable(tableName, "cf");
    try {
        Table table = TEST_UTIL.getConnection().getTable(tableName);
        try {
            HRegionServer server = TEST_UTIL.getRSForFirstRegionInTable(tableName);
            WAL log = server.getWAL(null);
            checkMinLogRolls(log, 5);
        } finally {
            table.close();
        }
    } finally {
        TEST_UTIL.deleteTable(tableName);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Table(org.apache.hadoop.hbase.client.Table) WAL(org.apache.hadoop.hbase.wal.WAL) 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