HBASE-15933 NullPointerException may be thrown from SimpleRegionNormalizer#getRegionSize()

This commit is contained in:
tedyu 2016-06-02 01:55:28 -07:00
parent a0f49c9884
commit cfe868d56e
1 changed files with 7 additions and 1 deletions

View File

@ -140,7 +140,9 @@ public class SimpleRegionNormalizer implements RegionNormalizer {
for (int i = 0; i < tableRegions.size(); i++) {
HRegionInfo hri = tableRegions.get(i);
long regionSize = getRegionSize(hri);
totalSizeMb += regionSize;
if (regionSize > 0) {
totalSizeMb += regionSize;
}
}
double avgRegionSize = totalSizeMb / (double) tableRegions.size();
@ -204,6 +206,10 @@ public class SimpleRegionNormalizer implements RegionNormalizer {
getRegionServerOfRegion(hri);
RegionLoad regionLoad = masterServices.getServerManager().getLoad(sn).
getRegionsLoad().get(hri.getRegionName());
if (regionLoad == null) {
LOG.debug(hri.getRegionNameAsString() + " was not found in RegionsLoad");
return -1;
}
return regionLoad.getStorefileSizeMB();
}
}