diff --git a/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java b/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java index 37fba04be57..d1a63819956 100644 --- a/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java @@ -51,7 +51,10 @@ import org.elasticsearch.index.refresh.RefreshStats; import org.elasticsearch.index.search.stats.SearchStats; import org.elasticsearch.index.search.stats.ShardSearchService; import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.*; +import org.elasticsearch.index.shard.DocsStats; +import org.elasticsearch.index.shard.IllegalIndexShardStateException; +import org.elasticsearch.index.shard.IndexShardComponent; +import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.index.suggest.stats.ShardSuggestService; import org.elasticsearch.index.suggest.stats.SuggestStats; @@ -180,8 +183,6 @@ public interface IndexShard extends IndexShardComponent { void readAllowed(Mode mode) throws IllegalIndexShardStateException; - ShardId shardId(); - public enum Mode { READ, WRITE diff --git a/src/main/java/org/elasticsearch/search/SearchService.java b/src/main/java/org/elasticsearch/search/SearchService.java index 0c4060b42f4..be26d54808e 100644 --- a/src/main/java/org/elasticsearch/search/SearchService.java +++ b/src/main/java/org/elasticsearch/search/SearchService.java @@ -51,7 +51,6 @@ import org.elasticsearch.common.util.concurrent.FutureUtils; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.Index; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.fielddata.IndexFieldData; @@ -146,15 +145,6 @@ public class SearchService extends AbstractLifecycleComponent { this.threadPool = threadPool; this.clusterService = clusterService; this.indicesService = indicesService; - indicesService.indicesLifecycle().addListener(new IndicesLifecycle.Listener() { - - @Override - public void afterIndexClosed(Index index) { - // once an index is closed we can just clean up all the pending search context information - // to release memory and let references to the filesystem go etc. - freeAllContextForIndex(index); - } - }); this.indicesWarmer = indicesWarmer; this.scriptService = scriptService; this.pageCacheRecycler = pageCacheRecycler; @@ -573,16 +563,6 @@ public class SearchService extends AbstractLifecycleComponent { return context; } - private void freeAllContextForIndex(Index index) { - assert index != null; - for (SearchContext ctx : activeContexts.values()) { - if (index.equals(ctx.indexShard().shardId().index())) { - freeContext(ctx.id()); - } - } - } - - public boolean freeContext(long id) { final SearchContext context = activeContexts.remove(id); if (context != null) {