Revert "[CORE] Free pending search contexts if index is closed"

This reverts commit edc48f39c5.
This commit is contained in:
Simon Willnauer 2014-11-20 00:10:43 +01:00
parent 52b77dad8d
commit 4df867fd17
2 changed files with 4 additions and 23 deletions

View File

@ -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

View File

@ -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<SearchService> {
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<SearchService> {
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) {