HBASE-11219 HRegionServer#createRegionLoad() should reuse RegionLoad.Builder instance when called in a loop
This commit is contained in:
parent
c45ffa4986
commit
cb1428ddca
|
@ -982,8 +982,10 @@ public class HRegionServer extends HasThread implements
|
|||
serverLoad.addCoprocessors(
|
||||
Coprocessor.newBuilder().setName(coprocessor).build());
|
||||
}
|
||||
RegionLoad.Builder regionLoadBldr = RegionLoad.newBuilder();
|
||||
RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
|
||||
for (HRegion region : regions) {
|
||||
serverLoad.addRegionLoads(createRegionLoad(region));
|
||||
serverLoad.addRegionLoads(createRegionLoad(region, regionLoadBldr, regionSpecifier));
|
||||
}
|
||||
serverLoad.setReportStartTime(reportStartTime);
|
||||
serverLoad.setReportEndTime(reportEndTime);
|
||||
|
@ -1181,12 +1183,14 @@ public class HRegionServer extends HasThread implements
|
|||
|
||||
/*
|
||||
* @param r Region to get RegionLoad for.
|
||||
*
|
||||
* @param regionLoadBldr the RegionLoad.Builder, can be null
|
||||
* @param regionSpecifier the RegionSpecifier.Builder, can be null
|
||||
* @return RegionLoad instance.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private RegionLoad createRegionLoad(final HRegion r) {
|
||||
private RegionLoad createRegionLoad(final HRegion r, RegionLoad.Builder regionLoadBldr,
|
||||
RegionSpecifier.Builder regionSpecifier) {
|
||||
byte[] name = r.getRegionName();
|
||||
int stores = 0;
|
||||
int storefiles = 0;
|
||||
|
@ -1223,11 +1227,15 @@ public class HRegionServer extends HasThread implements
|
|||
(int) (store.getTotalStaticBloomSize() / 1024);
|
||||
}
|
||||
}
|
||||
RegionLoad.Builder regionLoad = RegionLoad.newBuilder();
|
||||
RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
|
||||
if (regionLoadBldr == null) {
|
||||
regionLoadBldr = RegionLoad.newBuilder();
|
||||
}
|
||||
if (regionSpecifier == null) {
|
||||
regionSpecifier = RegionSpecifier.newBuilder();
|
||||
}
|
||||
regionSpecifier.setType(RegionSpecifierType.REGION_NAME);
|
||||
regionSpecifier.setValue(HBaseZeroCopyByteString.wrap(name));
|
||||
regionLoad.setRegionSpecifier(regionSpecifier.build())
|
||||
regionLoadBldr.setRegionSpecifier(regionSpecifier.build())
|
||||
.setStores(stores)
|
||||
.setStorefiles(storefiles)
|
||||
.setStoreUncompressedSizeMB(storeUncompressedSizeMB)
|
||||
|
@ -1243,7 +1251,7 @@ public class HRegionServer extends HasThread implements
|
|||
.setCurrentCompactedKVs(currentCompactedKVs)
|
||||
.setCompleteSequenceId(r.lastFlushSeqId);
|
||||
|
||||
return regionLoad.build();
|
||||
return regionLoadBldr.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1253,7 +1261,7 @@ public class HRegionServer extends HasThread implements
|
|||
public RegionLoad createRegionLoad(final String encodedRegionName) {
|
||||
HRegion r = null;
|
||||
r = this.onlineRegions.get(encodedRegionName);
|
||||
return r != null ? createRegionLoad(r) : null;
|
||||
return r != null ? createRegionLoad(r, null, null) : null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue