use of org.apache.hadoop.hbase.HDFSBlocksDistribution in project hbase by apache.
the class HRegion method getHDFSBlocksDistribution.
@Override
public HDFSBlocksDistribution getHDFSBlocksDistribution() {
HDFSBlocksDistribution hdfsBlocksDistribution = new HDFSBlocksDistribution();
synchronized (this.stores) {
for (Store store : this.stores.values()) {
Collection<StoreFile> storeFiles = store.getStorefiles();
if (storeFiles == null)
continue;
for (StoreFile sf : storeFiles) {
HDFSBlocksDistribution storeFileBlocksDistribution = sf.getHDFSBlockDistribution();
hdfsBlocksDistribution.add(storeFileBlocksDistribution);
}
}
}
return hdfsBlocksDistribution;
}
use of org.apache.hadoop.hbase.HDFSBlocksDistribution in project hbase by apache.
the class TestRegionLocationFinder method testInternalGetTopBlockLocation.
@Test
public void testInternalGetTopBlockLocation() throws Exception {
for (int i = 0; i < ServerNum; i++) {
HRegionServer server = cluster.getRegionServer(i);
for (Region region : server.getOnlineRegions(tableName)) {
// get region's hdfs block distribution by region and RegionLocationFinder,
// they should have same result
HDFSBlocksDistribution blocksDistribution1 = region.getHDFSBlocksDistribution();
HDFSBlocksDistribution blocksDistribution2 = finder.getBlockDistribution(region.getRegionInfo());
assertEquals(blocksDistribution1.getUniqueBlocksTotalWeight(), blocksDistribution2.getUniqueBlocksTotalWeight());
if (blocksDistribution1.getUniqueBlocksTotalWeight() != 0) {
assertEquals(blocksDistribution1.getTopHosts().get(0), blocksDistribution2.getTopHosts().get(0));
}
}
}
}
Aggregations