org.elasticsearch.index.cache.query.QueryCacheStats Java Examples

The following examples show how to use org.elasticsearch.index.cache.query.QueryCacheStats. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClusterStatsIndices.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    indexCount = in.readVInt();
    shards = ShardStats.readShardStats(in);
    docs = DocsStats.readDocStats(in);
    store = StoreStats.readStoreStats(in);
    fieldData = FieldDataStats.readFieldDataStats(in);
    queryCache = QueryCacheStats.readQueryCacheStats(in);
    completion = CompletionStats.readCompletionStats(in);
    segments = SegmentsStats.readSegmentsStats(in);
    percolate = PercolateStats.readPercolateStats(in);
}
 
Example #2
Source File: FieldDataTermsQueryTest.java    From siren-join with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testCaching() throws Exception {
  assertAcked(prepareCreate("index1").addMapping("type", "id", "type=integer"));
  ensureGreen();

  indexRandom(true,
    client().prepareIndex("index1", "type", "1").setSource("id", "1"),
    client().prepareIndex("index1", "type", "3").setSource("id", "3"),
    client().prepareIndex("index1", "type", "7").setSource("id", "7"));
  forceMerge(); // ensure that we have only one segment - needed for cache stats

  QueryCacheStats queryCacheStats = this.getQueryCacheStats("index1");
  assertThat(queryCacheStats.getCacheSize(), is(equalTo(0L)));
  assertThat(queryCacheStats.getHitCount(), is(equalTo(0L)));

  SearchResponse searchResponse = client().prepareSearch("index1").setQuery(
    boolQuery().filter(fieldDataTermsQuery("id", new long[] { 1, 2, 4, 8, 10, 7, 6, 11, 5 }, CACHE_KEY))
  ).get();
  assertHitCount(searchResponse, 2L);

  queryCacheStats = this.getQueryCacheStats("index1");
  assertThat(queryCacheStats.getCacheSize(), is(equalTo(1L)));
  assertThat(queryCacheStats.getHitCount(), is(equalTo(0L)));

  searchResponse = client().prepareSearch("index1").setQuery(
    boolQuery().filter(fieldDataTermsQuery("id", new long[] { 1, 2, 4, 8, 10, 7, 6, 11, 5 }, CACHE_KEY))
  ).get();
  assertHitCount(searchResponse, 2L);

  queryCacheStats = this.getQueryCacheStats("index1");
  assertThat(queryCacheStats.getCacheSize(), is(equalTo(1L)));
  assertThat(queryCacheStats.getHitCount(), is(equalTo(1L)));
}
 
Example #3
Source File: NodeIndicesStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Nullable
public QueryCacheStats getQueryCache() {
    return stats.getQueryCache();
}
 
Example #4
Source File: IndicesQueryCache.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
QueryCacheStats toQueryCacheStats() {
    return new QueryCacheStats(ramBytesUsed, hitCount, missCount, cacheCount, cacheSize);
}
 
Example #5
Source File: IndexShard.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public QueryCacheStats queryCacheStats() {
    return indicesQueryCache.getStats(shardId);
}
 
Example #6
Source File: CommonStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public CommonStats(CommonStatsFlags flags) {
    CommonStatsFlags.Flag[] setFlags = flags.getFlags();

    for (CommonStatsFlags.Flag flag : setFlags) {
        switch (flag) {
            case Docs:
                docs = new DocsStats();
                break;
            case Store:
                store = new StoreStats();
                break;
            case Indexing:
                indexing = new IndexingStats();
                break;
            case Get:
                get = new GetStats();
                break;
            case Search:
                search = new SearchStats();
                break;
            case Merge:
                merge = new MergeStats();
                break;
            case Refresh:
                refresh = new RefreshStats();
                break;
            case Flush:
                flush = new FlushStats();
                break;
            case Warmer:
                warmer = new WarmerStats();
                break;
            case QueryCache:
                queryCache = new QueryCacheStats();
                break;
            case FieldData:
                fieldData = new FieldDataStats();
                break;
            case Completion:
                completion = new CompletionStats();
                break;
            case Segments:
                segments = new SegmentsStats();
                break;
            case Percolate:
                percolate = new PercolateStats();
                break;
            case Translog:
                translog = new TranslogStats();
                break;
            case Suggest:
                suggest = new SuggestStats();
                break;
            case RequestCache:
                requestCache = new RequestCacheStats();
                break;
            case Recovery:
                recoveryStats = new RecoveryStats();
                break;
            case DL:
                dlStats = new DLStats();
                break;
            case Reindex:
                reindexStats = new ReindexStats();
                break;
            default:
                throw new IllegalStateException("Unknown Flag: " + flag);
        }
    }
}
 
Example #7
Source File: CommonStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Nullable
public QueryCacheStats getQueryCache() {
    return this.queryCache;
}
 
Example #8
Source File: CommonStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    if (in.readBoolean()) {
        docs = DocsStats.readDocStats(in);
    }
    if (in.readBoolean()) {
        store = StoreStats.readStoreStats(in);
    }
    if (in.readBoolean()) {
        indexing = IndexingStats.readIndexingStats(in);
    }
    if (in.readBoolean()) {
        get = GetStats.readGetStats(in);
    }
    if (in.readBoolean()) {
        search = SearchStats.readSearchStats(in);
    }
    if (in.readBoolean()) {
        merge = MergeStats.readMergeStats(in);
    }
    if (in.readBoolean()) {
        refresh = RefreshStats.readRefreshStats(in);
    }
    if (in.readBoolean()) {
        flush = FlushStats.readFlushStats(in);
    }
    if (in.readBoolean()) {
        warmer = WarmerStats.readWarmerStats(in);
    }
    if (in.readBoolean()) {
        queryCache = QueryCacheStats.readQueryCacheStats(in);
    }
    if (in.readBoolean()) {
        fieldData = FieldDataStats.readFieldDataStats(in);
    }
    if (in.readBoolean()) {
        percolate = PercolateStats.readPercolateStats(in);
    }
    if (in.readBoolean()) {
        completion = CompletionStats.readCompletionStats(in);
    }
    if (in.readBoolean()) {
        segments = SegmentsStats.readSegmentsStats(in);
    }
    if (in.readBoolean()) {
        dlStats = DLStats.readDLStats(in);
    }
    if (in.readBoolean()) {
        reindexStats = ReindexStats.readReindexStats(in);
    }
    translog = in.readOptionalStreamable(new TranslogStats());
    suggest = in.readOptionalStreamable(new SuggestStats());
    requestCache = in.readOptionalStreamable(new RequestCacheStats());
    recoveryStats = in.readOptionalStreamable(new RecoveryStats());
}
 
Example #9
Source File: ClusterStatsIndices.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public ClusterStatsIndices(ClusterStatsNodeResponse[] nodeResponses) {
    ObjectObjectHashMap<String, ShardStats> countsPerIndex = new ObjectObjectHashMap<>();

    this.docs = new DocsStats();
    this.store = new StoreStats();
    this.fieldData = new FieldDataStats();
    this.queryCache = new QueryCacheStats();
    this.completion = new CompletionStats();
    this.segments = new SegmentsStats();
    this.percolate = new PercolateStats();

    for (ClusterStatsNodeResponse r : nodeResponses) {
        for (org.elasticsearch.action.admin.indices.stats.ShardStats shardStats : r.shardsStats()) {
            ShardStats indexShardStats = countsPerIndex.get(shardStats.getShardRouting().getIndex());
            if (indexShardStats == null) {
                indexShardStats = new ShardStats();
                countsPerIndex.put(shardStats.getShardRouting().getIndex(), indexShardStats);
            }

            indexShardStats.total++;

            CommonStats shardCommonStats = shardStats.getStats();

            if (shardStats.getShardRouting().primary()) {
                indexShardStats.primaries++;
                docs.add(shardCommonStats.docs);
            }
            store.add(shardCommonStats.store);
            fieldData.add(shardCommonStats.fieldData);
            queryCache.add(shardCommonStats.queryCache);
            completion.add(shardCommonStats.completion);
            segments.add(shardCommonStats.segments);
            percolate.add(shardCommonStats.percolate);
        }
    }

    shards = new ShardStats();
    indexCount = countsPerIndex.size();
    for (ObjectObjectCursor<String, ShardStats> indexCountsCursor : countsPerIndex) {
        shards.addIndexShardCount(indexCountsCursor.value);
    }
}
 
Example #10
Source File: ClusterStatsIndices.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public QueryCacheStats getQueryCache() {
    return queryCache;
}
 
Example #11
Source File: FieldDataTermsQueryTest.java    From siren-join with GNU Affero General Public License v3.0 4 votes vote down vote up
private QueryCacheStats getQueryCacheStats(String index) {
  IndicesStatsResponse statsResponse = client().admin().indices().prepareStats(index).setQueryCache(true).setRefresh(true).get();
  return statsResponse.getIndex(index).getTotal().getQueryCache();
}
 
Example #12
Source File: IndicesQueryCache.java    From crate with Apache License 2.0 4 votes vote down vote up
QueryCacheStats toQueryCacheStats() {
    return new QueryCacheStats(ramBytesUsed, hitCount, missCount, cacheCount, cacheSize);
}