You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2017/03/03 17:39:57 UTC

lucene-solr:branch_6x: SOLR-10225: fix BlockCache evictions metric to not count explicit removal

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 1b9197369 -> dd008251f


SOLR-10225: fix BlockCache evictions metric to not count explicit removal


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

Branch: refs/heads/branch_6x
Commit: dd008251f7416f8f35949161cbd209972fee1e89
Parents: 1b91973
Author: yonik <yo...@apache.org>
Authored: Fri Mar 3 12:39:33 2017 -0500
Committer: yonik <yo...@apache.org>
Committed: Fri Mar 3 12:39:52 2017 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                            | 3 +++
 .../java/org/apache/solr/store/blockcache/BlockCache.java   | 9 ++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dd008251/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 607161d..0843fe1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -137,6 +137,9 @@ Bug Fixes
 
 * SOLR-10196: ElectionContext#runLeaderProcess can hit NPE on core close. (Mark Miller)
 
+* SOLR-10225: Fix HDFS BlockCache evictions metric to not count explicit removal
+  due to a directory close. (yonik)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dd008251/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java b/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java
index ad5b2f4..9deef6c 100644
--- a/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java
+++ b/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import com.github.benmanes.caffeine.cache.Cache;
 import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.RemovalCause;
 import com.github.benmanes.caffeine.cache.RemovalListener;
 
 /**
@@ -75,7 +76,7 @@ public class BlockCache {
       lockCounters[i] = new AtomicInteger();
     }
 
-    RemovalListener<BlockCacheKey,BlockCacheLocation> listener = (blockCacheKey, blockCacheLocation, removalCause) -> releaseLocation(blockCacheKey, blockCacheLocation);
+    RemovalListener<BlockCacheKey,BlockCacheLocation> listener = (blockCacheKey, blockCacheLocation, removalCause) -> releaseLocation(blockCacheKey, blockCacheLocation, removalCause);
 
     cache = Caffeine.newBuilder()
         .removalListener(listener)
@@ -88,7 +89,7 @@ public class BlockCache {
     cache.invalidate(key);
   }
   
-  private void releaseLocation(BlockCacheKey blockCacheKey, BlockCacheLocation location) {
+  private void releaseLocation(BlockCacheKey blockCacheKey, BlockCacheLocation location, RemovalCause removalCause) {
     if (location == null) {
       return;
     }
@@ -103,7 +104,9 @@ public class BlockCache {
     for (OnRelease onRelease : onReleases) {
       onRelease.release(blockCacheKey);
     }
-    metrics.blockCacheEviction.incrementAndGet();
+    if (removalCause.wasEvicted()) {
+      metrics.blockCacheEviction.incrementAndGet();
+    }
     metrics.blockCacheSize.decrementAndGet();
   }