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));
}
}
}
}
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));
}
}
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();
}
}
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;
}
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);
}
}
Aggregations