use of org.apache.hadoop.hbase.MiniHBaseCluster in project cdap by caskdata.
the class HBase10Test 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;
}
use of org.apache.hadoop.hbase.MiniHBaseCluster in project cdap by caskdata.
the class HBase10CDH550Test 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;
}
use of org.apache.hadoop.hbase.MiniHBaseCluster in project hive by apache.
the class HBaseTestSetup method setUpFixtures.
private void setUpFixtures(HiveConf conf) throws Exception {
/* We are not starting zookeeper server here because
* QTestUtil already starts it.
*/
int zkPort = conf.getInt("hive.zookeeper.client.port", -1);
if ((zkPort == zooKeeperPort) && (hbaseCluster != null)) {
return;
}
zooKeeperPort = zkPort;
String tmpdir = System.getProperty("test.tmp.dir");
this.tearDown();
conf.set("hbase.master", "local");
hbaseRoot = "file:///" + tmpdir + "/hbase";
conf.set("hbase.rootdir", hbaseRoot);
conf.set("hbase.zookeeper.property.clientPort", Integer.toString(zooKeeperPort));
Configuration hbaseConf = HBaseConfiguration.create(conf);
hbaseConf.setInt("hbase.master.port", findFreePort());
hbaseConf.setInt("hbase.master.info.port", -1);
hbaseConf.setInt("hbase.regionserver.port", findFreePort());
hbaseConf.setInt("hbase.regionserver.info.port", -1);
// Fix needed due to dependency for hbase-mapreduce module
System.setProperty("org.apache.hadoop.hbase.shaded.io.netty.packagePrefix", "org.apache.hadoop.hbase.shaded.");
hbaseCluster = new MiniHBaseCluster(hbaseConf, NUM_REGIONSERVERS);
conf.set("hbase.master", hbaseCluster.getMaster().getServerName().getHostAndPort());
hbaseConn = ConnectionFactory.createConnection(hbaseConf);
// opening the META table ensures that cluster is running
Table meta = null;
try {
meta = hbaseConn.getTable(TableName.META_TABLE_NAME);
} finally {
if (meta != null)
meta.close();
}
createHBaseTable();
}
use of org.apache.hadoop.hbase.MiniHBaseCluster in project cdap by caskdata.
the class HBase12CDH570Test 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<Region> serverRegions = t.getRegionServer().getOnlineRegions(TableName.valueOf(tableName));
for (Region region : serverRegions) {
results.put(region.getRegionInfo().getRegionName(), function.apply((HRegion) region));
}
}
return results;
}
use of org.apache.hadoop.hbase.MiniHBaseCluster in project cdap by caskdata.
the class HBase11Test 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<Region> serverRegions = t.getRegionServer().getOnlineRegions(TableName.valueOf(tableName));
for (Region region : serverRegions) {
results.put(region.getRegionInfo().getRegionName(), function.apply((HRegion) region));
}
}
return results;
}
Aggregations