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

This commit is contained in:
tedyu 2016-06-02 06:33:04 -07:00
parent 36bb496e48
commit 37bb8a5f69
1 changed files with 7 additions and 1 deletions

View File

@ -128,7 +128,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();
@ -192,6 +194,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();
}
}