You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2015/02/19 17:28:23 UTC

hbase git commit: HBASE-13072 BucketCache.evictBlock returns true if block does not exist (Duo Zhang)

Repository: hbase
Updated Branches:
  refs/heads/master 31f17b17f -> 18402cc85


HBASE-13072 BucketCache.evictBlock returns true if block does not exist (Duo Zhang)


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

Branch: refs/heads/master
Commit: 18402cc850b143bc6f88d90e62c42b9ef4131ca6
Parents: 31f17b1
Author: tedyu <yu...@gmail.com>
Authored: Thu Feb 19 08:28:13 2015 -0800
Committer: tedyu <yu...@gmail.com>
Committed: Thu Feb 19 08:28:13 2015 -0800

----------------------------------------------------------------------
 .../hbase/io/hfile/bucket/BucketCache.java      | 46 +++++++++++---------
 1 file changed, 26 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/18402cc8/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
index d3b303a..7dda0e6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
@@ -451,30 +451,36 @@ public class BucketCache implements BlockCache, HeapSize {
       this.heapSize.addAndGet(-1 * removedBlock.getData().heapSize());
     }
     BucketEntry bucketEntry = backingMap.get(cacheKey);
-    if (bucketEntry != null) {
-      IdLock.Entry lockEntry = null;
-      try {
-        lockEntry = offsetLock.getLockEntry(bucketEntry.offset());
-        if (bucketEntry.equals(backingMap.remove(cacheKey))) {
-          bucketAllocator.freeBlock(bucketEntry.offset());
-          realCacheSize.addAndGet(-1 * bucketEntry.getLength());
-          blocksByHFile.remove(cacheKey.getHfileName(), cacheKey);
-          if (removedBlock == null) {
-            this.blockNumber.decrementAndGet();
-          }
-        } else {
-          return false;
-        }
-      } catch (IOException ie) {
-        LOG.warn("Failed evicting block " + cacheKey);
+    if (bucketEntry == null) {
+      if (removedBlock != null) {
+        cacheStats.evicted(0);
+        return true;
+      } else {
         return false;
-      } finally {
-        if (lockEntry != null) {
-          offsetLock.releaseLockEntry(lockEntry);
+      }
+    }
+    IdLock.Entry lockEntry = null;
+    try {
+      lockEntry = offsetLock.getLockEntry(bucketEntry.offset());
+      if (bucketEntry.equals(backingMap.remove(cacheKey))) {
+        bucketAllocator.freeBlock(bucketEntry.offset());
+        realCacheSize.addAndGet(-1 * bucketEntry.getLength());
+        blocksByHFile.remove(cacheKey.getHfileName(), cacheKey);
+        if (removedBlock == null) {
+          this.blockNumber.decrementAndGet();
         }
+      } else {
+        return false;
+      }
+    } catch (IOException ie) {
+      LOG.warn("Failed evicting block " + cacheKey);
+      return false;
+    } finally {
+      if (lockEntry != null) {
+        offsetLock.releaseLockEntry(lockEntry);
       }
     }
-    cacheStats.evicted(bucketEntry == null? 0: bucketEntry.getCachedTime());
+    cacheStats.evicted(bucketEntry.getCachedTime());
     return true;
   }