use of org.apache.hadoop.hbase.MiniHBaseCluster 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.MiniHBaseCluster in project hbase by apache.
the class TestMasterReplication method rollWALAndWait.
private void rollWALAndWait(final HBaseTestingUtility utility, final TableName table, final byte[] row) throws IOException {
final Admin admin = utility.getAdmin();
final MiniHBaseCluster cluster = utility.getMiniHBaseCluster();
// find the region that corresponds to the given row.
HRegion region = null;
for (HRegion candidate : cluster.getRegions(table)) {
if (HRegion.rowIsInRange(candidate.getRegionInfo(), row)) {
region = candidate;
break;
}
}
assertNotNull("Couldn't find the region for row '" + Arrays.toString(row) + "'", region);
final CountDownLatch latch = new CountDownLatch(1);
// listen for successful log rolls
final WALActionsListener listener = new WALActionsListener.Base() {
@Override
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
latch.countDown();
}
};
region.getWAL().registerWALActionsListener(listener);
// request a roll
admin.rollWALWriter(cluster.getServerHoldingRegion(region.getTableDesc().getTableName(), region.getRegionInfo().getRegionName()));
// wait
try {
latch.await();
} catch (InterruptedException exception) {
LOG.warn("Interrupted while waiting for the wal of '" + region + "' to roll. If later " + "replication tests fail, it's probably because we should still be waiting.");
Thread.currentThread().interrupt();
}
region.getWAL().unregisterWALActionsListener(listener);
}
use of org.apache.hadoop.hbase.MiniHBaseCluster in project cdap by caskdata.
the class HBaseTestBase method forceRegionFlush.
/**
* Force and block on a flush to occur on all regions of table {@code tableName}.
* @param tableName The table whose regions should be flushed.
*/
public void forceRegionFlush(byte[] tableName) throws IOException {
MiniHBaseCluster hbaseCluster = getHBaseCluster();
if (hbaseCluster != null) {
TableName qualifiedTableName = TableName.valueOf(tableName);
for (JVMClusterUtil.RegionServerThread t : hbaseCluster.getRegionServerThreads()) {
List<HRegion> serverRegions = t.getRegionServer().getOnlineRegions(qualifiedTableName);
List<Runnable> flushers = new ArrayList<>();
for (HRegion region : serverRegions) {
flushers.add(createFlushRegion(region));
}
parallelRun(flushers);
LOG.info("RegionServer {}: Flushed {} regions for table {}", t.getRegionServer().getServerName().toString(), serverRegions.size(), Bytes.toStringBinary(tableName));
}
}
}
use of org.apache.hadoop.hbase.MiniHBaseCluster in project cdap by caskdata.
the class HBaseTestBase method forceRegionCompact.
/**
* Force and block on a compaction on all regions of table {@code tableName}.
* @param tableName The table whose regions should be compacted.
* @param majorCompact Whether a major compaction should be requested.
*/
public void forceRegionCompact(byte[] tableName, boolean majorCompact) throws IOException {
MiniHBaseCluster hbaseCluster = getHBaseCluster();
if (hbaseCluster != null) {
TableName qualifiedTableName = TableName.valueOf(tableName);
for (JVMClusterUtil.RegionServerThread t : hbaseCluster.getRegionServerThreads()) {
List<HRegion> serverRegions = t.getRegionServer().getOnlineRegions(qualifiedTableName);
List<Runnable> compacters = new ArrayList<>();
for (HRegion region : serverRegions) {
compacters.add(createCompactRegion(region, majorCompact));
}
parallelRun(compacters);
LOG.info("RegionServer {}: Compacted {} regions for table {}", t.getRegionServer().getServerName().toString(), serverRegions.size(), Bytes.toStringBinary(tableName));
}
}
}
use of org.apache.hadoop.hbase.MiniHBaseCluster in project cdap by caskdata.
the class HBase10CDHTest method forEachRegion.
@Override
public <T> Map<byte[], T> forEachRegion(byte[] tableName, Function<HRegion, T> function) {
MiniHBaseCluster hbaseCluster = getHBaseCluster();
Map<byte[], T> results = new TreeMap<>(Bytes.BYTES_COMPARATOR);
// make sure consumer config cache is updated
for (JVMClusterUtil.RegionServerThread t : hbaseCluster.getRegionServerThreads()) {
List<HRegion> serverRegions = t.getRegionServer().getOnlineRegions(TableName.valueOf(tableName));
for (HRegion region : serverRegions) {
results.put(region.getRegionName(), function.apply(region));
}
}
return results;
}
Aggregations