hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [2/2] git commit: HBASE-11876 RegionScanner.nextRaw should not update metrics
Date Wed, 03 Sep 2014 16:41:57 GMT
HBASE-11876 RegionScanner.nextRaw should not update metrics


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

Branch: refs/heads/0.98
Commit: cf843b196338cf2f2bd0eafbe88fda7d4386fba2
Parents: c3882ed
Author: Andrew Purtell <apurtell@apache.org>
Authored: Wed Sep 3 08:38:21 2014 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Wed Sep 3 08:38:21 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/HRegion.java      | 21 ++++++++-------
 .../hbase/regionserver/HRegionServer.java       | 27 +++++++++++++-------
 .../hbase/regionserver/RegionScanner.java       |  1 +
 3 files changed, 29 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/cf843b19/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 7169904..524dba6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -3817,7 +3817,16 @@ public class HRegion implements HeapSize { // , Writable{
       startRegionOperation(Operation.SCAN);
       readRequestsCount.increment();
       try {
-        return nextRaw(outResults, limit);
+        boolean returnResult = nextRaw(outResults, limit);
+        if (region != null && region.metricsRegion != null) {
+          long totalSize = 0;
+          for (Cell cell: outResults) {
+            KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
+            totalSize += kv.getLength();
+          }
+          region.metricsRegion.updateScanNext(totalSize);
+        }
+        return returnResult;
       } finally {
         closeRegionOperation(Operation.SCAN);
       }
@@ -3845,19 +3854,9 @@ public class HRegion implements HeapSize { // , Writable{
       if (isFilterDoneInternal()) {
         returnResult = false;
       }
-      if (region != null && region.metricsRegion != null) {
-        long totalSize = 0;
-        for(Cell c:outResults) {
-          // TODO clean up
-          KeyValue kv = KeyValueUtil.ensureKeyValue(c);
-          totalSize += kv.getLength();
-        }
-        region.metricsRegion.updateScanNext(totalSize);
-      }
       return returnResult;
     }
 
-
     private void populateFromJoinedHeap(List<Cell> results, int limit)
         throws IOException {
       assert joinedContinuationRow != null;

http://git-wip-us.apache.org/repos/asf/hbase/blob/cf843b19/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 f904238..392fc70 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
@@ -53,6 +53,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.management.ObjectName;
 
 import com.google.common.annotations.VisibleForTesting;
+
 import org.apache.hadoop.hbase.util.ByteStringer;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -73,6 +74,7 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.HealthCheckChore;
+import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.KeyValueUtil;
 import org.apache.hadoop.hbase.NotServingRegionException;
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
@@ -3186,6 +3188,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
           lease = leases.removeLease(scannerName);
           List<Result> results = new ArrayList<Result>(rows);
           long currentScanResultSize = 0;
+          long totalKvSize = 0;
 
           boolean done = false;
           // Call coprocessor. Get region info from scanner.
@@ -3195,9 +3198,10 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
             if (!results.isEmpty()) {
               for (Result r : results) {
                 if (maxScannerResultSize < Long.MAX_VALUE){
-                  for (Cell kv : r.rawCells()) {
-                    // TODO
-                    currentScanResultSize += KeyValueUtil.ensureKeyValue(kv).heapSize();
+                  for (Cell cell : r.rawCells()) {
+                    KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
+                    currentScanResultSize += kv.heapSize();
+                    totalKvSize += kv.getLength();
                   }
                 }
               }
@@ -3217,15 +3221,19 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
             try {
               int i = 0;
               synchronized(scanner) {
-                for (; i < rows
-                    && currentScanResultSize < maxResultSize; ) {
+                while (i < rows) {
+                  // Stop collecting results if maxScannerResultSize is set and we have exceeded
it
+                  if ((maxScannerResultSize < Long.MAX_VALUE) &&
+                      (currentScanResultSize >= maxResultSize)) {
+                    break;
+                  }
                   // Collect values to be returned here
                   boolean moreRows = scanner.nextRaw(values);
                   if (!values.isEmpty()) {
-                    if (maxScannerResultSize < Long.MAX_VALUE){
-                      for (Cell kv : values) {
-                        currentScanResultSize += KeyValueUtil.ensureKeyValue(kv).heapSize();
-                      }
+                    for (Cell cell : values) {
+                      KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
+                      currentScanResultSize += kv.heapSize();
+                      totalKvSize += kv.getLength();
                     }
                     results.add(Result.create(values));
                     i++;
@@ -3237,6 +3245,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
                 }
               }
               region.readRequestsCount.add(i);
+              region.getMetrics().updateScanNext(totalKvSize);
             } finally {
               region.closeRegionOperation();
             }

http://git-wip-us.apache.org/repos/asf/hbase/blob/cf843b19/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
index 07cbc4c..f75b9a2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java
@@ -69,6 +69,7 @@ public interface RegionScanner extends InternalScanner {
    * to return.
    * This is a special internal method to be called from coprocessor hooks to avoid expensive
setup.
    * Caller must set the thread's readpoint, start and close a region operation, an synchronize
on the scanner object.
+   * Caller should maintain and update metrics.
    * See {@link #nextRaw(List, int)}
    * @param result return output array
    * @return true if more rows exist after this one, false if scanner is done


Mime
View raw message