Skip to content

Commit

Permalink
Rename caches.
Browse files Browse the repository at this point in the history
In order to be more consistent with what they do, the query cache has been
renamed to request cache and the filter cache has been renamed to query
cache.

A known issue is that package/logger names do no longer match settings names,
please speak up if you think this is an issue.

Here are the settings for which I kept backward compatibility. Note that they
are a bit different from what was discussed on elastic#11569 but putting `cache` before
the name of what is cached has the benefit of making these settings consistent
with the fielddata cache whose size is configured by
`indices.fielddata.cache.size`:
 * index.cache.query.enable -> index.requests.cache.enable
 * indices.cache.query.size -> indices.requests.cache.size
 * indices.cache.filter.size -> indices.queries.cache.size

Close elastic#11569
  • Loading branch information
jpountz committed Jun 29, 2015
1 parent f5f7325 commit 38f5cc2
Show file tree
Hide file tree
Showing 81 changed files with 1,390 additions and 1,341 deletions.
Expand Up @@ -29,7 +29,7 @@
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.index.cache.filter.FilterCacheStats;
import org.elasticsearch.index.cache.query.QueryCacheStats;
import org.elasticsearch.index.engine.SegmentsStats;
import org.elasticsearch.index.fielddata.FieldDataStats;
import org.elasticsearch.index.percolator.stats.PercolateStats;
Expand All @@ -46,7 +46,7 @@ public class ClusterStatsIndices implements ToXContent, Streamable {
private DocsStats docs;
private StoreStats store;
private FieldDataStats fieldData;
private FilterCacheStats filterCache;
private QueryCacheStats queryCache;
private CompletionStats completion;
private SegmentsStats segments;
private PercolateStats percolate;
Expand All @@ -60,7 +60,7 @@ public ClusterStatsIndices(ClusterStatsNodeResponse[] nodeResponses) {
this.docs = new DocsStats();
this.store = new StoreStats();
this.fieldData = new FieldDataStats();
this.filterCache = new FilterCacheStats();
this.queryCache = new QueryCacheStats();
this.completion = new CompletionStats();
this.segments = new SegmentsStats();
this.percolate = new PercolateStats();
Expand All @@ -83,7 +83,7 @@ public ClusterStatsIndices(ClusterStatsNodeResponse[] nodeResponses) {
}
store.add(shardCommonStats.store);
fieldData.add(shardCommonStats.fieldData);
filterCache.add(shardCommonStats.filterCache);
queryCache.add(shardCommonStats.queryCache);
completion.add(shardCommonStats.completion);
segments.add(shardCommonStats.segments);
percolate.add(shardCommonStats.percolate);
Expand Down Expand Up @@ -117,8 +117,8 @@ public FieldDataStats getFieldData() {
return fieldData;
}

public FilterCacheStats getFilterCache() {
return filterCache;
public QueryCacheStats getQueryCache() {
return queryCache;
}

public CompletionStats getCompletion() {
Expand All @@ -140,7 +140,7 @@ public void readFrom(StreamInput in) throws IOException {
docs = DocsStats.readDocStats(in);
store = StoreStats.readStoreStats(in);
fieldData = FieldDataStats.readFieldDataStats(in);
filterCache = FilterCacheStats.readFilterCacheStats(in);
queryCache = QueryCacheStats.readFilterCacheStats(in);
completion = CompletionStats.readCompletionStats(in);
segments = SegmentsStats.readSegmentsStats(in);
percolate = PercolateStats.readPercolateStats(in);
Expand All @@ -153,7 +153,7 @@ public void writeTo(StreamOutput out) throws IOException {
docs.writeTo(out);
store.writeTo(out);
fieldData.writeTo(out);
filterCache.writeTo(out);
queryCache.writeTo(out);
completion.writeTo(out);
segments.writeTo(out);
percolate.writeTo(out);
Expand All @@ -176,7 +176,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
docs.toXContent(builder, params);
store.toXContent(builder, params);
fieldData.toXContent(builder, params);
filterCache.toXContent(builder, params);
queryCache.toXContent(builder, params);
completion.toXContent(builder, params);
segments.toXContent(builder, params);
percolate.toXContent(builder, params);
Expand Down
Expand Up @@ -55,7 +55,7 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
TransportClusterStatsAction.ClusterStatsNodeRequest, ClusterStatsNodeResponse> {

private static final CommonStatsFlags SHARD_STATS_FLAGS = new CommonStatsFlags(CommonStatsFlags.Flag.Docs, CommonStatsFlags.Flag.Store,
CommonStatsFlags.Flag.FieldData, CommonStatsFlags.Flag.FilterCache, CommonStatsFlags.Flag.Completion, CommonStatsFlags.Flag.Segments,
CommonStatsFlags.Flag.FieldData, CommonStatsFlags.Flag.QueryCache, CommonStatsFlags.Flag.Completion, CommonStatsFlags.Flag.Segments,
CommonStatsFlags.Flag.Percolate);

private final NodeService nodeService;
Expand Down
Expand Up @@ -30,10 +30,10 @@
*/
public class ClearIndicesCacheRequest extends BroadcastRequest<ClearIndicesCacheRequest> {

private boolean filterCache = false;
private boolean queryCache = false;
private boolean fieldDataCache = false;
private boolean recycler = false;
private boolean queryCache = false;
private boolean requestCache = false;
private String[] fields = null;


Expand All @@ -44,21 +44,21 @@ public ClearIndicesCacheRequest(String... indices) {
super(indices);
}

public boolean filterCache() {
return filterCache;
public boolean queryCache() {
return queryCache;
}

public ClearIndicesCacheRequest filterCache(boolean filterCache) {
this.filterCache = filterCache;
public ClearIndicesCacheRequest queryCache(boolean queryCache) {
this.queryCache = queryCache;
return this;
}

public boolean queryCache() {
return this.queryCache;
public boolean requestCache() {
return this.requestCache;
}

public ClearIndicesCacheRequest queryCache(boolean queryCache) {
this.queryCache = queryCache;
public ClearIndicesCacheRequest requestCache(boolean requestCache) {
this.requestCache = requestCache;
return this;
}

Expand Down Expand Up @@ -92,20 +92,20 @@ public boolean recycler() {
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
filterCache = in.readBoolean();
queryCache = in.readBoolean();
fieldDataCache = in.readBoolean();
recycler = in.readBoolean();
fields = in.readStringArray();
queryCache = in.readBoolean();
requestCache = in.readBoolean();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeBoolean(filterCache);
out.writeBoolean(queryCache);
out.writeBoolean(fieldDataCache);
out.writeBoolean(recycler);
out.writeStringArrayNullable(fields);
out.writeBoolean(queryCache);
out.writeBoolean(requestCache);
}
}
Expand Up @@ -31,13 +31,13 @@ public ClearIndicesCacheRequestBuilder(ElasticsearchClient client, ClearIndicesC
super(client, action, new ClearIndicesCacheRequest());
}

public ClearIndicesCacheRequestBuilder setFilterCache(boolean filterCache) {
request.filterCache(filterCache);
public ClearIndicesCacheRequestBuilder setQueryCache(boolean queryCache) {
request.queryCache(queryCache);
return this;
}

public ClearIndicesCacheRequestBuilder setQueryCache(boolean queryCache) {
request.queryCache(queryCache);
public ClearIndicesCacheRequestBuilder setRequestCache(boolean requestCache) {
request.requestCache(requestCache);
return this;
}

Expand Down
Expand Up @@ -31,10 +31,10 @@
*/
class ShardClearIndicesCacheRequest extends BroadcastShardRequest {

private boolean filterCache = false;
private boolean queryCache = false;
private boolean fieldDataCache = false;
private boolean recycler;
private boolean queryCache = false;
private boolean requestCache = false;

private String[] fields = null;

Expand All @@ -43,21 +43,21 @@ class ShardClearIndicesCacheRequest extends BroadcastShardRequest {

ShardClearIndicesCacheRequest(ShardId shardId, ClearIndicesCacheRequest request) {
super(shardId, request);
filterCache = request.filterCache();
queryCache = request.queryCache();
fieldDataCache = request.fieldDataCache();
fields = request.fields();
recycler = request.recycler();
queryCache = request.queryCache();
}

public boolean filterCache() {
return filterCache;
requestCache = request.requestCache();
}

public boolean queryCache() {
return queryCache;
}

public boolean requestCache() {
return requestCache;
}

public boolean fieldDataCache() {
return this.fieldDataCache;
}
Expand All @@ -73,20 +73,20 @@ public String[] fields() {
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
filterCache = in.readBoolean();
queryCache = in.readBoolean();
fieldDataCache = in.readBoolean();
recycler = in.readBoolean();
fields = in.readStringArray();
queryCache = in.readBoolean();
requestCache = in.readBoolean();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeBoolean(filterCache);
out.writeBoolean(queryCache);
out.writeBoolean(fieldDataCache);
out.writeBoolean(recycler);
out.writeStringArrayNullable(fields);
out.writeBoolean(queryCache);
out.writeBoolean(requestCache);
}
}
Expand Up @@ -35,7 +35,7 @@
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.indices.cache.query.IndicesQueryCache;
import org.elasticsearch.indices.cache.request.IndicesRequestCache;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;

Expand All @@ -50,16 +50,16 @@
public class TransportClearIndicesCacheAction extends TransportBroadcastAction<ClearIndicesCacheRequest, ClearIndicesCacheResponse, ShardClearIndicesCacheRequest, ShardClearIndicesCacheResponse> {

private final IndicesService indicesService;
private final IndicesQueryCache indicesQueryCache;
private final IndicesRequestCache indicesRequestCache;

@Inject
public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
TransportService transportService, IndicesService indicesService,
IndicesQueryCache indicesQueryCache, ActionFilters actionFilters) {
IndicesRequestCache indicesQueryCache, ActionFilters actionFilters) {
super(settings, ClearIndicesCacheAction.NAME, threadPool, clusterService, transportService, actionFilters,
ClearIndicesCacheRequest.class, ShardClearIndicesCacheRequest.class, ThreadPool.Names.MANAGEMENT);
this.indicesService = indicesService;
this.indicesQueryCache = indicesQueryCache;
this.indicesRequestCache = indicesQueryCache;
}

@Override
Expand Down Expand Up @@ -100,9 +100,9 @@ protected ShardClearIndicesCacheResponse shardOperation(ShardClearIndicesCacheRe
if (service != null) {
IndexShard shard = service.shard(request.shardId().id());
boolean clearedAtLeastOne = false;
if (request.filterCache()) {
if (request.queryCache()) {
clearedAtLeastOne = true;
service.cache().filter().clear("api");
service.cache().query().clear("api");
}
if (request.fieldDataCache()) {
clearedAtLeastOne = true;
Expand All @@ -114,9 +114,9 @@ protected ShardClearIndicesCacheResponse shardOperation(ShardClearIndicesCacheRe
}
}
}
if (request.queryCache()) {
if (request.requestCache()) {
clearedAtLeastOne = true;
indicesQueryCache.clear(shard);
indicesRequestCache.clear(shard);
}
if (request.recycler()) {
logger.debug("Clear CacheRecycler on index [{}]", service.index());
Expand All @@ -132,7 +132,7 @@ protected ShardClearIndicesCacheResponse shardOperation(ShardClearIndicesCacheRe
} else {
service.cache().clear("api");
service.fieldData().clear();
indicesQueryCache.clear(shard);
indicesRequestCache.clear(shard);
}
}
}
Expand Down
Expand Up @@ -170,7 +170,7 @@ public void writeTo(StreamOutput out) throws IOException {
for (IndexWarmersMetaData.Entry warmerEntry : indexEntry.value) {
out.writeString(warmerEntry.name());
out.writeStringArray(warmerEntry.types());
out.writeOptionalBoolean(warmerEntry.queryCache());
out.writeOptionalBoolean(warmerEntry.requestCache());
out.writeBytesReference(warmerEntry.source());
}
}
Expand Down

0 comments on commit 38f5cc2

Please sign in to comment.