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(
|
serverLoad.addCoprocessors(
|
||||||
Coprocessor.newBuilder().setName(coprocessor).build());
|
Coprocessor.newBuilder().setName(coprocessor).build());
|
||||||
}
|
}
|
||||||
|
RegionLoad.Builder regionLoadBldr = RegionLoad.newBuilder();
|
||||||
|
RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
|
||||||
for (HRegion region : regions) {
|
for (HRegion region : regions) {
|
||||||
serverLoad.addRegionLoads(createRegionLoad(region));
|
serverLoad.addRegionLoads(createRegionLoad(region, regionLoadBldr, regionSpecifier));
|
||||||
}
|
}
|
||||||
serverLoad.setReportStartTime(reportStartTime);
|
serverLoad.setReportStartTime(reportStartTime);
|
||||||
serverLoad.setReportEndTime(reportEndTime);
|
serverLoad.setReportEndTime(reportEndTime);
|
||||||
|
@ -1181,12 +1183,14 @@ public class HRegionServer extends HasThread implements
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param r Region to get RegionLoad for.
|
* @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.
|
* @return RegionLoad instance.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private RegionLoad createRegionLoad(final HRegion r) {
|
private RegionLoad createRegionLoad(final HRegion r, RegionLoad.Builder regionLoadBldr,
|
||||||
|
RegionSpecifier.Builder regionSpecifier) {
|
||||||
byte[] name = r.getRegionName();
|
byte[] name = r.getRegionName();
|
||||||
int stores = 0;
|
int stores = 0;
|
||||||
int storefiles = 0;
|
int storefiles = 0;
|
||||||
|
@ -1223,11 +1227,15 @@ public class HRegionServer extends HasThread implements
|
||||||
(int) (store.getTotalStaticBloomSize() / 1024);
|
(int) (store.getTotalStaticBloomSize() / 1024);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RegionLoad.Builder regionLoad = RegionLoad.newBuilder();
|
if (regionLoadBldr == null) {
|
||||||
RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
|
regionLoadBldr = RegionLoad.newBuilder();
|
||||||
|
}
|
||||||
|
if (regionSpecifier == null) {
|
||||||
|
regionSpecifier = RegionSpecifier.newBuilder();
|
||||||
|
}
|
||||||
regionSpecifier.setType(RegionSpecifierType.REGION_NAME);
|
regionSpecifier.setType(RegionSpecifierType.REGION_NAME);
|
||||||
regionSpecifier.setValue(HBaseZeroCopyByteString.wrap(name));
|
regionSpecifier.setValue(HBaseZeroCopyByteString.wrap(name));
|
||||||
regionLoad.setRegionSpecifier(regionSpecifier.build())
|
regionLoadBldr.setRegionSpecifier(regionSpecifier.build())
|
||||||
.setStores(stores)
|
.setStores(stores)
|
||||||
.setStorefiles(storefiles)
|
.setStorefiles(storefiles)
|
||||||
.setStoreUncompressedSizeMB(storeUncompressedSizeMB)
|
.setStoreUncompressedSizeMB(storeUncompressedSizeMB)
|
||||||
|
@ -1243,7 +1251,7 @@ public class HRegionServer extends HasThread implements
|
||||||
.setCurrentCompactedKVs(currentCompactedKVs)
|
.setCurrentCompactedKVs(currentCompactedKVs)
|
||||||
.setCompleteSequenceId(r.lastFlushSeqId);
|
.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) {
|
public RegionLoad createRegionLoad(final String encodedRegionName) {
|
||||||
HRegion r = null;
|
HRegion r = null;
|
||||||
r = this.onlineRegions.get(encodedRegionName);
|
r = this.onlineRegions.get(encodedRegionName);
|
||||||
return r != null ? createRegionLoad(r) : null;
|
return r != null ? createRegionLoad(r, null, null) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue