hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject git commit: HBASE-11219 HRegionServer#createRegionLoad() should reuse RegionLoad.Builder instance when called in a loop
Date Thu, 22 May 2014 04:41:12 GMT
Repository: hbase
Updated Branches:
  refs/heads/master c45ffa498 -> cb1428ddc


HBASE-11219 HRegionServer#createRegionLoad() should reuse RegionLoad.Builder instance when
called in a loop


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/cb1428dd
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/cb1428dd
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/cb1428dd

Branch: refs/heads/master
Commit: cb1428ddca52d7d980be8432cc9d97cc7c8bd6f2
Parents: c45ffa4
Author: tedyu <tedyu@minotaur.apache.org>
Authored: Thu May 22 04:40:47 2014 +0000
Committer: tedyu <tedyu@minotaur.apache.org>
Committed: Thu May 22 04:40:47 2014 +0000

----------------------------------------------------------------------
 .../hbase/regionserver/HRegionServer.java       | 24 +++++++++++++-------
 1 file changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/cb1428dd/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index d8341d5..8e64414 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -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;
   }
 
   /*


Mime
View raw message