Skip to content

Commit

Permalink
Filter / Id Cache Stats: Add to Indices Stats API, revise node stats API
Browse files Browse the repository at this point in the history
closes #2862
  • Loading branch information
kimchy committed Apr 5, 2013
1 parent 5e7ad98 commit 8467021
Show file tree
Hide file tree
Showing 31 changed files with 790 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ protected ShardClearIndicesCacheResponse shardOperation(ShardClearIndicesCacheRe
termsFilterCache.clear("api");
}
}
service.cache().invalidateStatsCache();
}
return new ShardClearIndicesCacheResponse(request.index(), request.shardId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.cache.filter.FilterCacheStats;
import org.elasticsearch.index.cache.id.IdCacheStats;
import org.elasticsearch.index.flush.FlushStats;
import org.elasticsearch.index.get.GetStats;
import org.elasticsearch.index.indexing.IndexingStats;
Expand Down Expand Up @@ -68,6 +70,12 @@ public class CommonStats implements Streamable, ToXContent {
@Nullable
WarmerStats warmer;

@Nullable
FilterCacheStats filterCache;

@Nullable
IdCacheStats idCache;

public void add(CommonStats stats) {
if (docs == null) {
if (stats.getDocs() != null) {
Expand Down Expand Up @@ -141,6 +149,23 @@ public void add(CommonStats stats) {
} else {
warmer.add(stats.getWarmer());
}
if (filterCache == null) {
if (stats.getFilterCache() != null) {
filterCache = new FilterCacheStats();
filterCache.add(stats.getFilterCache());
}
} else {
filterCache.add(stats.getFilterCache());
}

if (idCache == null) {
if (stats.getIdCache() != null) {
idCache = new IdCacheStats();
idCache.add(stats.getIdCache());
}
} else {
idCache.add(stats.getIdCache());
}
}

@Nullable
Expand Down Expand Up @@ -188,6 +213,16 @@ public WarmerStats getWarmer() {
return this.warmer;
}

@Nullable
public FilterCacheStats getFilterCache() {
return this.filterCache;
}

@Nullable
public IdCacheStats getIdCache() {
return this.idCache;
}

public static CommonStats readCommonStats(StreamInput in) throws IOException {
CommonStats stats = new CommonStats();
stats.readFrom(in);
Expand Down Expand Up @@ -223,6 +258,12 @@ public void readFrom(StreamInput in) throws IOException {
if (in.readBoolean()) {
warmer = WarmerStats.readWarmerStats(in);
}
if (in.readBoolean()) {
filterCache = FilterCacheStats.readFilterCacheStats(in);
}
if (in.readBoolean()) {
idCache = IdCacheStats.readIdCacheStats(in);
}
}

@Override
Expand Down Expand Up @@ -281,6 +322,19 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(true);
warmer.writeTo(out);
}
if (filterCache == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
filterCache.writeTo(out);
}

if (idCache == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
idCache.writeTo(out);
}
}

// note, requires a wrapping object
Expand Down Expand Up @@ -313,6 +367,12 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (warmer != null) {
warmer.toXContent(builder, params);
}
if (filterCache != null) {
filterCache.toXContent(builder, params);
}
if (idCache != null) {
idCache.toXContent(builder, params);
}
return builder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class IndicesStatsRequest extends BroadcastOperationRequest<IndicesStatsR
private boolean refresh = false;
private boolean flush = false;
private boolean warmer = false;
private boolean filterCache = false;
private boolean idCache = false;
private String[] types = null;
private String[] groups = null;

Expand All @@ -61,6 +63,8 @@ public IndicesStatsRequest all() {
refresh = true;
flush = true;
warmer = true;
filterCache = true;
idCache = true;
types = null;
groups = null;
return this;
Expand All @@ -79,6 +83,8 @@ public IndicesStatsRequest clear() {
refresh = false;
flush = false;
warmer = false;
filterCache = false;
idCache = false;
types = null;
groups = null;
return this;
Expand Down Expand Up @@ -195,6 +201,24 @@ public boolean warmer() {
return this.warmer;
}

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

public boolean filterCache() {
return this.filterCache;
}

public IndicesStatsRequest idCache(boolean idCache) {
this.idCache = idCache;
return this;
}

public boolean idCache() {
return this.idCache;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
Expand All @@ -207,6 +231,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(flush);
out.writeBoolean(refresh);
out.writeBoolean(warmer);
out.writeBoolean(filterCache);
out.writeBoolean(idCache);
if (types == null) {
out.writeVInt(0);
} else {
Expand Down Expand Up @@ -237,6 +263,8 @@ public void readFrom(StreamInput in) throws IOException {
flush = in.readBoolean();
refresh = in.readBoolean();
warmer = in.readBoolean();
filterCache = in.readBoolean();
idCache = in.readBoolean();
int size = in.readVInt();
if (size > 0) {
types = new String[size];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ public IndicesStatsRequestBuilder setWarmer(boolean warmer) {
return this;
}

public IndicesStatsRequestBuilder setFilterCache(boolean filterCache) {
request.filterCache(filterCache);
return this;
}

public IndicesStatsRequestBuilder setIdCache(boolean idCache) {
request.idCache(idCache);
return this;
}

@Override
protected void doExecute(ActionListener<IndicesStatsResponse> listener) {
((IndicesAdminClient) client).stats(request, listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
getTotal().toXContent(builder, params);
builder.endObject();

builder.endObject();

builder.startObject(Fields.INDICES);
for (IndexStats indexStats : getIndices().values()) {
builder.startObject(indexStats.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
Expand Down Expand Up @@ -188,7 +190,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}
builder.endObject();

builder.endObject();
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ protected ShardStats shardOperation(IndexShardStatsRequest request) throws Elast
if (request.request.warmer()) {
stats.stats.warmer = indexShard.warmerStats();
}
if (request.request.filterCache()) {
stats.stats.filterCache = indexShard.filterCacheStats();
}
if (request.request.idCache()) {
stats.stats.idCache = indexShard.idCacheStats();
}

return stats;
}
Expand Down
131 changes: 0 additions & 131 deletions src/main/java/org/elasticsearch/index/cache/CacheStats.java

This file was deleted.

Loading

0 comments on commit 8467021

Please sign in to comment.