hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-13072 BucketCache.evictBlock returns true if block does not exist (Duo Zhang)
Date Thu, 19 Feb 2015 16:29:04 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 41d93323f -> 6b44b7340


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/6b44b734
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6b44b734
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6b44b734

Branch: refs/heads/branch-1
Commit: 6b44b734040ea7e6c9bdcf04ee61a738989adcb9
Parents: 41d9332
Author: tedyu <yuzhihong@gmail.com>
Authored: Thu Feb 19 08:28:51 2015 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Thu Feb 19 08:28:51 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/6b44b734/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 c094e45..9435dc8 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;
   }
 


Mime
View raw message