You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2017/03/06 11:02:08 UTC
[04/15] lucene-solr:feature/autoscaling: SOLR-10225: fix BlockCache
evictions metric to not count explicit removal
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/4990eed1
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4990eed1
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4990eed1
Branch: refs/heads/feature/autoscaling
Commit: 4990eed1b3aef3fb8bf98fa5427f12a96c029d03
Parents: fbc844d
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:33 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/4990eed1/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index fa4d33b..2659155 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -196,6 +196,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/4990eed1/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();
}