diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/IndexCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/IndexCache.java index 86689da31e0..47968f8023f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/IndexCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/IndexCache.java @@ -122,13 +122,6 @@ public class IndexCache extends AbstractIndexComponent implements CloseableCompo bloomCache.clear(); } - public void clearUnreferenced() { - filterCache.clearUnreferenced(); - fieldDataCache.clearUnreferenced(); - idCache.clearUnreferenced(); - bloomCache.clearUnreferenced(); - } - @Override public void clusterChanged(ClusterChangedEvent event) { // clear the query parser cache if the metadata (mappings) changed... if (event.metaDataChanged()) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/BloomCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/BloomCache.java index 323c823f21b..07b4f5a237a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/BloomCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/BloomCache.java @@ -39,8 +39,6 @@ public interface BloomCache extends IndexComponent, CloseableComponent { void clear(IndexReader reader); - void clearUnreferenced(); - long sizeInBytes(); long sizeInBytes(String fieldName); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/none/NonBloomCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/none/NonBloomCache.java index a5ec82b99fc..8ef886113a8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/none/NonBloomCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/none/NonBloomCache.java @@ -53,9 +53,6 @@ public class NonBloomCache extends AbstractIndexComponent implements BloomCache @Override public void clear(IndexReader reader) { } - @Override public void clearUnreferenced() { - } - @Override public long sizeInBytes() { return 0; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java index 54fb856d1a8..d6065769da4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java @@ -90,10 +90,6 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac } } - @Override public void clearUnreferenced() { - // nothing to do here... - } - @Override public long sizeInBytes() { // the overhead of the map is not really relevant... long sizeInBytes = 0; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java index 4495c51902f..09e4c76a488 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java @@ -40,8 +40,6 @@ public interface FieldDataCache extends IndexComponent, CloseableComponent { void clear(IndexReader reader); - void clearUnreferenced(); - long evictions(); long sizeInBytes(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java index 75942420bbc..11aab174ac4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java @@ -56,9 +56,6 @@ public class NoneFieldDataCache extends AbstractIndexComponent implements FieldD @Override public void clear(IndexReader reader) { } - @Override public void clearUnreferenced() { - } - @Override public void close() throws ElasticSearchException { } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java index 107ff5e04b5..c13272fab1e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java @@ -70,10 +70,6 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC } } - @Override public void clearUnreferenced() { - // nothing to do here... - } - @Override public long sizeInBytes() { // the overhead of the map is not really relevant... long sizeInBytes = 0; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java index d13ce6585c4..52b7392ce6d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java @@ -39,11 +39,6 @@ public interface FilterCache extends IndexComponent, CloseableComponent { void clear(); - /** - * Clears unreferenced filters. - */ - void clearUnreferenced(); - long count(); long sizeInBytes(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java index 5b82f1420cd..0092249a238 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java @@ -62,10 +62,6 @@ public class NoneFilterCache extends AbstractIndexComponent implements FilterCac // nothing to do here } - @Override public void clearUnreferenced() { - // nothing to do here - } - @Override public long count() { return 0; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java index b74e44124aa..d03323623dd 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java @@ -68,26 +68,6 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp } } - @Override public void clearUnreferenced() { - // can't do this, since we cache on cacheKey... -// int totalCount = cache.size(); -// int cleaned = 0; -// for (Iterator readerIt = cache.keySet().iterator(); readerIt.hasNext();) { -// IndexReader reader = readerIt.next(); -// if (reader.getRefCount() <= 0) { -// readerIt.remove(); -// cleaned++; -// } -// } -// if (logger.isDebugEnabled()) { -// if (cleaned > 0) { -// logger.debug("Cleaned [{}] out of estimated total [{}]", cleaned, totalCount); -// } -// } else if (logger.isTraceEnabled()) { -// logger.trace("Cleaned [{}] out of estimated total [{}]", cleaned, totalCount); -// } - } - @Override public long sizeInBytes() { long sizeInBytes = 0; for (ConcurrentMap map : cache.values()) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/id/IdCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/id/IdCache.java index 67ca5263bde..25499a1a837 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/id/IdCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/id/IdCache.java @@ -32,11 +32,6 @@ public interface IdCache extends IndexComponent, CloseableComponent, Iterable shardIds = shardIds(); - final CountDownLatch latch = new CountDownLatch(shardIds.size()); - for (final int shardId : shardIds) { - threadPool.cached().execute(new Runnable() { - @Override public void run() { - try { - deleteShard(shardId, delete, !delete, delete, reason); - } catch (Exception e) { - logger.warn("failed to close shard, delete [{}]", e, delete); - } finally { - latch.countDown(); - } + Set shardIds = shardIds(); + final CountDownLatch latch = new CountDownLatch(shardIds.size()); + for (final int shardId : shardIds) { + threadPool.cached().execute(new Runnable() { + @Override public void run() { + try { + deleteShard(shardId, delete, !delete, delete, reason); + } catch (Exception e) { + logger.warn("failed to close shard, delete [{}]", e, delete); + } finally { + latch.countDown(); } - }); - } - try { - latch.await(); - } catch (InterruptedException e) { - throw new ElasticSearchInterruptedException("interrupted closing index [ " + index().name() + "]", e); - } - } finally { - indicesLifecycle.removeListener(cleanCacheOnIndicesLifecycleListener); + } + }); + } + try { + latch.await(); + } catch (InterruptedException e) { + throw new ElasticSearchInterruptedException("interrupted closing index [ " + index().name() + "]", e); } } @@ -419,15 +410,4 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde FileSystemUtils.deleteRecursively(nodeEnv.shardLocation(sId)); } } - - class CleanCacheOnIndicesLifecycleListener extends IndicesLifecycle.Listener { - - @Override public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, boolean delete) { - indexCache.clearUnreferenced(); - } - - @Override public void afterIndexShardClosed(ShardId shardId, boolean delete) { - indexCache.clearUnreferenced(); - } - } } \ No newline at end of file