move the query parser cache to be index level and not node level
This commit is contained in:
parent
33339ae4b1
commit
eef3a95fa6
|
@ -25,7 +25,6 @@ import org.elasticsearch.action.TransportActions;
|
||||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||||
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
|
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
|
||||||
import org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction;
|
import org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction;
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCache;
|
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
|
@ -51,12 +50,9 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio
|
||||||
|
|
||||||
private final IndicesService indicesService;
|
private final IndicesService indicesService;
|
||||||
|
|
||||||
private final QueryParserCache queryParserCache;
|
|
||||||
|
|
||||||
@Inject public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
@Inject public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
TransportService transportService, IndicesService indicesService, QueryParserCache queryParserCache) {
|
TransportService transportService, IndicesService indicesService) {
|
||||||
super(settings, threadPool, clusterService, transportService);
|
super(settings, threadPool, clusterService, transportService);
|
||||||
this.queryParserCache = queryParserCache;
|
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +112,6 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
service.cache().clear();
|
service.cache().clear();
|
||||||
}
|
}
|
||||||
queryParserCache.clear();
|
|
||||||
return new ShardClearIndicesCacheResponse(request.index(), request.shardId());
|
return new ShardClearIndicesCacheResponse(request.index(), request.shardId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.elasticsearch.cache;
|
package org.elasticsearch.cache;
|
||||||
|
|
||||||
import org.elasticsearch.cache.memory.ByteBufferCache;
|
import org.elasticsearch.cache.memory.ByteBufferCache;
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCache;
|
|
||||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterStateListener;
|
import org.elasticsearch.cluster.ClusterStateListener;
|
||||||
|
@ -37,35 +36,22 @@ public class NodeCache extends AbstractComponent implements ClusterStateListener
|
||||||
|
|
||||||
private final ByteBufferCache byteBufferCache;
|
private final ByteBufferCache byteBufferCache;
|
||||||
|
|
||||||
private final QueryParserCache queryParserCache;
|
@Inject public NodeCache(Settings settings, ByteBufferCache byteBufferCache, ClusterService clusterService) {
|
||||||
|
|
||||||
@Inject public NodeCache(Settings settings, ByteBufferCache byteBufferCache, QueryParserCache queryParserCache, ClusterService clusterService) {
|
|
||||||
super(settings);
|
super(settings);
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.byteBufferCache = byteBufferCache;
|
this.byteBufferCache = byteBufferCache;
|
||||||
this.queryParserCache = queryParserCache;
|
|
||||||
clusterService.add(this);
|
clusterService.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
clusterService.remove(this);
|
clusterService.remove(this);
|
||||||
byteBufferCache.close();
|
byteBufferCache.close();
|
||||||
queryParserCache.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteBufferCache byteBuffer() {
|
public ByteBufferCache byteBuffer() {
|
||||||
return byteBufferCache;
|
return byteBufferCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryParserCache queryParser() {
|
|
||||||
return queryParserCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
// listen on cluster change events to invalidate the query parser cache
|
|
||||||
@Override public void clusterChanged(ClusterChangedEvent event) {
|
@Override public void clusterChanged(ClusterChangedEvent event) {
|
||||||
// TODO we can do better by detecting just mappings changes
|
|
||||||
if (event.metaDataChanged()) {
|
|
||||||
queryParserCache.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.elasticsearch.cache;
|
package org.elasticsearch.cache;
|
||||||
|
|
||||||
import org.elasticsearch.cache.memory.ByteBufferCache;
|
import org.elasticsearch.cache.memory.ByteBufferCache;
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCacheModule;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
|
||||||
|
@ -38,7 +37,5 @@ public class NodeCacheModule extends AbstractModule {
|
||||||
@Override protected void configure() {
|
@Override protected void configure() {
|
||||||
bind(NodeCache.class).asEagerSingleton();
|
bind(NodeCache.class).asEagerSingleton();
|
||||||
bind(ByteBufferCache.class).asEagerSingleton();
|
bind(ByteBufferCache.class).asEagerSingleton();
|
||||||
|
|
||||||
new QueryParserCacheModule(settings).configure(binder());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
package org.elasticsearch.index.cache;
|
package org.elasticsearch.index.cache;
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
|
import org.elasticsearch.ElasticSearchException;
|
||||||
|
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||||
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
|
import org.elasticsearch.cluster.ClusterStateListener;
|
||||||
|
import org.elasticsearch.common.component.CloseableComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.AbstractIndexComponent;
|
import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
|
@ -27,27 +32,43 @@ import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||||
import org.elasticsearch.index.cache.id.IdCache;
|
import org.elasticsearch.index.cache.id.IdCache;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.QueryParserCache;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class IndexCache extends AbstractIndexComponent {
|
public class IndexCache extends AbstractIndexComponent implements CloseableComponent, ClusterStateListener {
|
||||||
|
|
||||||
private final FilterCache filterCache;
|
private final FilterCache filterCache;
|
||||||
|
|
||||||
private final FieldDataCache fieldDataCache;
|
private final FieldDataCache fieldDataCache;
|
||||||
|
|
||||||
|
private final QueryParserCache queryParserCache;
|
||||||
|
|
||||||
private final IdCache idCache;
|
private final IdCache idCache;
|
||||||
|
|
||||||
|
private ClusterService clusterService;
|
||||||
|
|
||||||
@Inject public IndexCache(Index index, @IndexSettings Settings indexSettings, FilterCache filterCache, FieldDataCache fieldDataCache,
|
@Inject public IndexCache(Index index, @IndexSettings Settings indexSettings, FilterCache filterCache, FieldDataCache fieldDataCache,
|
||||||
IdCache idCache) {
|
QueryParserCache queryParserCache, IdCache idCache) {
|
||||||
super(index, indexSettings);
|
super(index, indexSettings);
|
||||||
this.filterCache = filterCache;
|
this.filterCache = filterCache;
|
||||||
this.fieldDataCache = fieldDataCache;
|
this.fieldDataCache = fieldDataCache;
|
||||||
|
this.queryParserCache = queryParserCache;
|
||||||
this.idCache = idCache;
|
this.idCache = idCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(optional = true)
|
||||||
|
public void setClusterService(@Nullable ClusterService clusterService) {
|
||||||
|
this.clusterService = clusterService;
|
||||||
|
if (clusterService != null) {
|
||||||
|
clusterService.add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FilterCache filter() {
|
public FilterCache filter() {
|
||||||
return filterCache;
|
return filterCache;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +81,20 @@ public class IndexCache extends AbstractIndexComponent {
|
||||||
return this.idCache;
|
return this.idCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryParserCache queryParserCache() {
|
||||||
|
return this.queryParserCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void close() throws ElasticSearchException {
|
||||||
|
filterCache.close();
|
||||||
|
fieldDataCache.close();
|
||||||
|
idCache.close();
|
||||||
|
queryParserCache.close();
|
||||||
|
if (clusterService != null) {
|
||||||
|
clusterService.remove(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clear(IndexReader reader) {
|
public void clear(IndexReader reader) {
|
||||||
filterCache.clear(reader);
|
filterCache.clear(reader);
|
||||||
fieldDataCache.clear(reader);
|
fieldDataCache.clear(reader);
|
||||||
|
@ -70,6 +105,7 @@ public class IndexCache extends AbstractIndexComponent {
|
||||||
filterCache.clear();
|
filterCache.clear();
|
||||||
fieldDataCache.clear();
|
fieldDataCache.clear();
|
||||||
idCache.clear();
|
idCache.clear();
|
||||||
|
queryParserCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearUnreferenced() {
|
public void clearUnreferenced() {
|
||||||
|
@ -77,4 +113,11 @@ public class IndexCache extends AbstractIndexComponent {
|
||||||
fieldDataCache.clearUnreferenced();
|
fieldDataCache.clearUnreferenced();
|
||||||
idCache.clearUnreferenced();
|
idCache.clearUnreferenced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void clusterChanged(ClusterChangedEvent event) {
|
||||||
|
// clear the query parser cache if the metadata (mappings) changed...
|
||||||
|
if (event.metaDataChanged()) {
|
||||||
|
queryParserCache.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.cache.field.data.FieldDataCacheModule;
|
import org.elasticsearch.index.cache.field.data.FieldDataCacheModule;
|
||||||
import org.elasticsearch.index.cache.filter.FilterCacheModule;
|
import org.elasticsearch.index.cache.filter.FilterCacheModule;
|
||||||
import org.elasticsearch.index.cache.id.IdCacheModule;
|
import org.elasticsearch.index.cache.id.IdCacheModule;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.QueryParserCacheModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
|
@ -40,6 +41,7 @@ public class IndexCacheModule extends AbstractModule {
|
||||||
new FilterCacheModule(settings).configure(binder());
|
new FilterCacheModule(settings).configure(binder());
|
||||||
new FieldDataCacheModule(settings).configure(binder());
|
new FieldDataCacheModule(settings).configure(binder());
|
||||||
new IdCacheModule(settings).configure(binder());
|
new IdCacheModule(settings).configure(binder());
|
||||||
|
new QueryParserCacheModule(settings).configure(binder());
|
||||||
|
|
||||||
bind(IndexCache.class).asEagerSingleton();
|
bind(IndexCache.class).asEagerSingleton();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void close() throws ElasticSearchException {
|
@Override public void close() throws ElasticSearchException {
|
||||||
cache.clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void clear() {
|
@Override public void clear() {
|
||||||
|
|
|
@ -55,11 +55,12 @@ public abstract class AbstractDoubleConcurrentMapFilterCache extends AbstractInd
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void close() {
|
@Override public void close() {
|
||||||
cache.clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void clear() {
|
@Override public void clear() {
|
||||||
cache.clear();
|
cache.clear();
|
||||||
|
weakCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void clear(IndexReader reader) {
|
@Override public void clear(IndexReader reader) {
|
||||||
|
|
|
@ -20,11 +20,12 @@
|
||||||
package org.elasticsearch.index.cache.id;
|
package org.elasticsearch.index.cache.id;
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
|
import org.elasticsearch.common.component.CloseableComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public interface IdCache extends Iterable<IdReaderCache> {
|
public interface IdCache extends CloseableComponent, Iterable<IdReaderCache> {
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.lucene.index.Term;
|
||||||
import org.apache.lucene.index.TermDocs;
|
import org.apache.lucene.index.TermDocs;
|
||||||
import org.apache.lucene.index.TermEnum;
|
import org.apache.lucene.index.TermEnum;
|
||||||
import org.apache.lucene.util.StringHelper;
|
import org.apache.lucene.util.StringHelper;
|
||||||
|
import org.elasticsearch.ElasticSearchException;
|
||||||
import org.elasticsearch.common.BytesWrap;
|
import org.elasticsearch.common.BytesWrap;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.collect.MapMaker;
|
import org.elasticsearch.common.collect.MapMaker;
|
||||||
|
@ -52,6 +53,10 @@ public class SimpleIdCache implements IdCache {
|
||||||
idReaders = new MapMaker().weakKeys().makeMap();
|
idReaders = new MapMaker().weakKeys().makeMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void close() throws ElasticSearchException {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void clear() {
|
@Override public void clear() {
|
||||||
idReaders.clear();
|
idReaders.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,16 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.cache.query.parser;
|
package org.elasticsearch.index.cache.query.parser;
|
||||||
|
|
||||||
import org.apache.lucene.queryParser.QueryParserSettings;
|
import org.apache.lucene.queryParser.QueryParserSettings;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
|
import org.elasticsearch.common.component.CloseableComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public interface QueryParserCache {
|
public interface QueryParserCache extends CloseableComponent {
|
||||||
|
|
||||||
Query get(QueryParserSettings queryString);
|
Query get(QueryParserSettings queryString);
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.cache.query.parser;
|
package org.elasticsearch.index.cache.query.parser;
|
||||||
|
|
||||||
import org.elasticsearch.cache.query.parser.weak.WeakQueryParserCache;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.inject.Scopes;
|
import org.elasticsearch.common.inject.Scopes;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.weak.WeakQueryParserCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
|
@ -37,7 +37,7 @@ public class QueryParserCacheModule extends AbstractModule {
|
||||||
|
|
||||||
@Override protected void configure() {
|
@Override protected void configure() {
|
||||||
bind(QueryParserCache.class)
|
bind(QueryParserCache.class)
|
||||||
.to(settings.getAsClass("cache.query.parser.type", WeakQueryParserCache.class, "org.elasticsearch.cache.query.parser.", "QueryParserCache"))
|
.to(settings.getAsClass("index.cache.query.parser.type", WeakQueryParserCache.class, "org.elasticsearch.index.cache.query.parser.", "QueryParserCache"))
|
||||||
.in(Scopes.SINGLETON);
|
.in(Scopes.SINGLETON);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,12 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.cache.query.parser.none;
|
package org.elasticsearch.index.cache.query.parser.none;
|
||||||
|
|
||||||
import org.apache.lucene.queryParser.QueryParserSettings;
|
import org.apache.lucene.queryParser.QueryParserSettings;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCache;
|
import org.elasticsearch.ElasticSearchException;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.QueryParserCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
|
@ -41,4 +42,7 @@ public class NoneQueryParserCache implements QueryParserCache {
|
||||||
|
|
||||||
@Override public void clear() {
|
@Override public void clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void close() throws ElasticSearchException {
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -17,21 +17,23 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.cache.query.parser.soft;
|
package org.elasticsearch.index.cache.query.parser.soft;
|
||||||
|
|
||||||
import org.apache.lucene.queryParser.QueryParserSettings;
|
import org.apache.lucene.queryParser.QueryParserSettings;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.elasticsearch.cache.query.parser.support.AbstractJvmQueryParserCache;
|
|
||||||
import org.elasticsearch.common.collect.MapMaker;
|
import org.elasticsearch.common.collect.MapMaker;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.index.Index;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.support.AbstractJvmQueryParserCache;
|
||||||
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class SoftQueryParserCache extends AbstractJvmQueryParserCache {
|
public class SoftQueryParserCache extends AbstractJvmQueryParserCache {
|
||||||
|
|
||||||
@Inject public SoftQueryParserCache(Settings settings) {
|
@Inject public SoftQueryParserCache(Index index, @IndexSettings Settings indexSettings) {
|
||||||
super(settings, new MapMaker().softValues().<QueryParserSettings, Query>makeMap());
|
super(index, indexSettings, new MapMaker().softValues().<QueryParserSettings, Query>makeMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,28 +17,35 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.cache.query.parser.support;
|
package org.elasticsearch.index.cache.query.parser.support;
|
||||||
|
|
||||||
import org.apache.lucene.queryParser.QueryParserSettings;
|
import org.apache.lucene.queryParser.QueryParserSettings;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCache;
|
import org.elasticsearch.ElasticSearchException;
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
|
import org.elasticsearch.index.Index;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.QueryParserCache;
|
||||||
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class AbstractJvmQueryParserCache extends AbstractComponent implements QueryParserCache {
|
public class AbstractJvmQueryParserCache extends AbstractIndexComponent implements QueryParserCache {
|
||||||
|
|
||||||
final ConcurrentMap<QueryParserSettings, Query> cache;
|
final ConcurrentMap<QueryParserSettings, Query> cache;
|
||||||
|
|
||||||
protected AbstractJvmQueryParserCache(Settings settings, ConcurrentMap<QueryParserSettings, Query> cache) {
|
protected AbstractJvmQueryParserCache(Index index, @IndexSettings Settings indexSettings, ConcurrentMap<QueryParserSettings, Query> cache) {
|
||||||
super(settings);
|
super(index, indexSettings);
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void close() throws ElasticSearchException {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override public void clear() {
|
@Override public void clear() {
|
||||||
cache.clear();
|
cache.clear();
|
||||||
}
|
}
|
|
@ -17,21 +17,23 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.cache.query.parser.weak;
|
package org.elasticsearch.index.cache.query.parser.weak;
|
||||||
|
|
||||||
import org.apache.lucene.queryParser.QueryParserSettings;
|
import org.apache.lucene.queryParser.QueryParserSettings;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.elasticsearch.cache.query.parser.support.AbstractJvmQueryParserCache;
|
|
||||||
import org.elasticsearch.common.collect.MapMaker;
|
import org.elasticsearch.common.collect.MapMaker;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.index.Index;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.support.AbstractJvmQueryParserCache;
|
||||||
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class WeakQueryParserCache extends AbstractJvmQueryParserCache {
|
public class WeakQueryParserCache extends AbstractJvmQueryParserCache {
|
||||||
|
|
||||||
@Inject public WeakQueryParserCache(Settings settings) {
|
@Inject public WeakQueryParserCache(Index index, @IndexSettings Settings indexSettings) {
|
||||||
super(settings, new MapMaker().weakValues().<QueryParserSettings, Query>makeMap());
|
super(index, indexSettings, new MapMaker().weakValues().<QueryParserSettings, Query>makeMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,13 +24,13 @@ import org.apache.lucene.queryParser.ParseException;
|
||||||
import org.apache.lucene.queryParser.QueryParser;
|
import org.apache.lucene.queryParser.QueryParser;
|
||||||
import org.apache.lucene.queryParser.QueryParserSettings;
|
import org.apache.lucene.queryParser.QueryParserSettings;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCache;
|
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.AbstractIndexComponent;
|
import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.analysis.AnalysisService;
|
import org.elasticsearch.index.analysis.AnalysisService;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.QueryParserCache;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.apache.lucene.queryParser.MultiFieldQueryParserSettings;
|
||||||
import org.apache.lucene.queryParser.ParseException;
|
import org.apache.lucene.queryParser.ParseException;
|
||||||
import org.apache.lucene.queryParser.QueryParser;
|
import org.apache.lucene.queryParser.QueryParser;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCache;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.collect.Lists;
|
import org.elasticsearch.common.collect.Lists;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.AbstractIndexComponent;
|
import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.analysis.AnalysisService;
|
import org.elasticsearch.index.analysis.AnalysisService;
|
||||||
|
import org.elasticsearch.index.cache.query.parser.QueryParserCache;
|
||||||
import org.elasticsearch.index.mapper.AllFieldMapper;
|
import org.elasticsearch.index.mapper.AllFieldMapper;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
|
|
@ -40,8 +40,8 @@ import org.elasticsearch.gateway.Gateway;
|
||||||
import org.elasticsearch.index.*;
|
import org.elasticsearch.index.*;
|
||||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||||
import org.elasticsearch.index.analysis.AnalysisService;
|
import org.elasticsearch.index.analysis.AnalysisService;
|
||||||
|
import org.elasticsearch.index.cache.IndexCache;
|
||||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
|
||||||
import org.elasticsearch.index.engine.IndexEngine;
|
import org.elasticsearch.index.engine.IndexEngine;
|
||||||
import org.elasticsearch.index.engine.IndexEngineModule;
|
import org.elasticsearch.index.engine.IndexEngineModule;
|
||||||
import org.elasticsearch.index.gateway.IndexGateway;
|
import org.elasticsearch.index.gateway.IndexGateway;
|
||||||
|
@ -280,7 +280,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
|
||||||
|
|
||||||
indexService.close(delete);
|
indexService.close(delete);
|
||||||
|
|
||||||
indexInjector.getInstance(FilterCache.class).close();
|
indexInjector.getInstance(IndexCache.class).close();
|
||||||
indexInjector.getInstance(AnalysisService.class).close();
|
indexInjector.getInstance(AnalysisService.class).close();
|
||||||
indexInjector.getInstance(IndexEngine.class).close();
|
indexInjector.getInstance(IndexEngine.class).close();
|
||||||
indexInjector.getInstance(IndexServiceManagement.class).close();
|
indexInjector.getInstance(IndexServiceManagement.class).close();
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.apache.lucene.index.Term;
|
||||||
import org.apache.lucene.search.*;
|
import org.apache.lucene.search.*;
|
||||||
import org.apache.lucene.search.spans.*;
|
import org.apache.lucene.search.spans.*;
|
||||||
import org.apache.lucene.util.NumericUtils;
|
import org.apache.lucene.util.NumericUtils;
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCacheModule;
|
|
||||||
import org.elasticsearch.common.inject.Injector;
|
import org.elasticsearch.common.inject.Injector;
|
||||||
import org.elasticsearch.common.inject.ModulesBuilder;
|
import org.elasticsearch.common.inject.ModulesBuilder;
|
||||||
import org.elasticsearch.common.lucene.search.*;
|
import org.elasticsearch.common.lucene.search.*;
|
||||||
|
@ -78,7 +77,6 @@ public class SimpleIndexQueryParserTests {
|
||||||
Index index = new Index("test");
|
Index index = new Index("test");
|
||||||
Injector injector = new ModulesBuilder().add(
|
Injector injector = new ModulesBuilder().add(
|
||||||
new SettingsModule(settings),
|
new SettingsModule(settings),
|
||||||
new QueryParserCacheModule(settings),
|
|
||||||
new ScriptModule(),
|
new ScriptModule(),
|
||||||
new MapperServiceModule(),
|
new MapperServiceModule(),
|
||||||
new IndexSettingsModule(settings),
|
new IndexSettingsModule(settings),
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.elasticsearch.index.query.xcontent.guice;
|
package org.elasticsearch.index.query.xcontent.guice;
|
||||||
|
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCacheModule;
|
|
||||||
import org.elasticsearch.common.inject.Injector;
|
import org.elasticsearch.common.inject.Injector;
|
||||||
import org.elasticsearch.common.inject.ModulesBuilder;
|
import org.elasticsearch.common.inject.ModulesBuilder;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -58,7 +57,6 @@ public class IndexQueryParserModuleTests {
|
||||||
Index index = new Index("test");
|
Index index = new Index("test");
|
||||||
Injector injector = new ModulesBuilder().add(
|
Injector injector = new ModulesBuilder().add(
|
||||||
new SettingsModule(settings),
|
new SettingsModule(settings),
|
||||||
new QueryParserCacheModule(settings),
|
|
||||||
new ScriptModule(),
|
new ScriptModule(),
|
||||||
new IndexSettingsModule(settings),
|
new IndexSettingsModule(settings),
|
||||||
new IndexCacheModule(settings),
|
new IndexCacheModule(settings),
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.elasticsearch.index.query.xcontent.plugin;
|
package org.elasticsearch.index.query.xcontent.plugin;
|
||||||
|
|
||||||
import org.elasticsearch.cache.query.parser.QueryParserCacheModule;
|
|
||||||
import org.elasticsearch.common.inject.Injector;
|
import org.elasticsearch.common.inject.Injector;
|
||||||
import org.elasticsearch.common.inject.ModulesBuilder;
|
import org.elasticsearch.common.inject.ModulesBuilder;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
|
@ -64,7 +63,6 @@ public class IndexQueryParserPluginTests {
|
||||||
Injector injector = new ModulesBuilder().add(
|
Injector injector = new ModulesBuilder().add(
|
||||||
new SettingsModule(settings),
|
new SettingsModule(settings),
|
||||||
new ScriptModule(),
|
new ScriptModule(),
|
||||||
new QueryParserCacheModule(settings),
|
|
||||||
new IndexSettingsModule(settings),
|
new IndexSettingsModule(settings),
|
||||||
new IndexCacheModule(settings),
|
new IndexCacheModule(settings),
|
||||||
new AnalysisModule(settings),
|
new AnalysisModule(settings),
|
||||||
|
|
Loading…
Reference in New Issue