From 7874291c0ee2a7498d926e947abba62bdd7c962d Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 14 Apr 2011 19:13:14 +0300 Subject: [PATCH] fix wrong initialization of mem evictions counter --- .../elasticsearch/index/cache/filter/soft/SoftFilterCache.java | 3 ++- .../elasticsearch/index/cache/filter/weak/WeakFilterCache.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/soft/SoftFilterCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/soft/SoftFilterCache.java index f62ba235233..8e4f8dea3a2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/soft/SoftFilterCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/soft/SoftFilterCache.java @@ -46,7 +46,7 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements private final TimeValue expire; private final AtomicLong evictions = new AtomicLong(); - private final AtomicLong memEvictions = new AtomicLong(); + private AtomicLong memEvictions; @Inject public SoftFilterCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); @@ -55,6 +55,7 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements } @Override protected ConcurrentMap buildCache() { + memEvictions = new AtomicLong(); // we need to init it here, since its called from the super constructor // better to have soft on the whole ReaderValue, simpler on the GC to clean it MapMaker mapMaker = new MapMaker().weakKeys().softValues(); mapMaker.evictionListener(new CacheMapEvictionListener(memEvictions)); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/weak/WeakFilterCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/weak/WeakFilterCache.java index efbc153b4bd..62dd7006390 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/weak/WeakFilterCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/weak/WeakFilterCache.java @@ -46,7 +46,7 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements private final TimeValue expire; private final AtomicLong evictions = new AtomicLong(); - private final AtomicLong memEvictions = new AtomicLong(); + private AtomicLong memEvictions; @Inject public WeakFilterCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); @@ -55,6 +55,7 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements } @Override protected ConcurrentMap buildCache() { + memEvictions = new AtomicLong(); // we need to init it here, since its called from the super constructor // better to have weak on the whole ReaderValue, simpler on the GC to clean it MapMaker mapMaker = new MapMaker().weakKeys().softValues(); mapMaker.evictionListener(new CacheMapEvictionListener(memEvictions));