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