当前位置: 首页>>代码示例>>Java>>正文


Java QueryCacheStats类代码示例

本文整理汇总了Java中org.elasticsearch.index.cache.query.QueryCacheStats的典型用法代码示例。如果您正苦于以下问题:Java QueryCacheStats类的具体用法?Java QueryCacheStats怎么用?Java QueryCacheStats使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QueryCacheStats类属于org.elasticsearch.index.cache.query包,在下文中一共展示了QueryCacheStats类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CommonStats

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
public CommonStats(StreamInput in) throws IOException {
    docs = in.readOptionalStreamable(DocsStats::new);
    store = in.readOptionalStreamable(StoreStats::new);
    indexing = in.readOptionalStreamable(IndexingStats::new);
    get = in.readOptionalStreamable(GetStats::new);
    search = in.readOptionalStreamable(SearchStats::new);
    merge = in.readOptionalStreamable(MergeStats::new);
    refresh =  in.readOptionalStreamable(RefreshStats::new);
    flush =  in.readOptionalStreamable(FlushStats::new);
    warmer =  in.readOptionalStreamable(WarmerStats::new);
    queryCache = in.readOptionalStreamable(QueryCacheStats::new);
    fieldData =  in.readOptionalStreamable(FieldDataStats::new);
    completion =  in.readOptionalStreamable(CompletionStats::new);
    segments =  in.readOptionalStreamable(SegmentsStats::new);
    translog = in.readOptionalStreamable(TranslogStats::new);
    requestCache = in.readOptionalStreamable(RequestCacheStats::new);
    recoveryStats = in.readOptionalStreamable(RecoveryStats::new);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:CommonStats.java

示例2: ClusterStatsIndices

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
public ClusterStatsIndices(List<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();

    for (ClusterStatsNodeResponse r : nodeResponses) {
        for (org.elasticsearch.action.admin.indices.stats.ShardStats shardStats : r.shardsStats()) {
            ShardStats indexShardStats = countsPerIndex.get(shardStats.getShardRouting().getIndexName());
            if (indexShardStats == null) {
                indexShardStats = new ShardStats();
                countsPerIndex.put(shardStats.getShardRouting().getIndexName(), 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);
        }
    }

    shards = new ShardStats();
    indexCount = countsPerIndex.size();
    for (ObjectObjectCursor<String, ShardStats> indexCountsCursor : countsPerIndex) {
        shards.addIndexShardCount(indexCountsCursor.value);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:ClusterStatsIndices.java

示例3: assertEquals

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
private void assertEquals(QueryCacheStats stats1, QueryCacheStats stats2) {
    assertEquals(stats1.getCacheCount(), stats2.getCacheCount());
    assertEquals(stats1.getCacheSize(), stats2.getCacheSize());
    assertEquals(stats1.getEvictions(), stats2.getEvictions());
    assertEquals(stats1.getHitCount(), stats2.getHitCount());
    assertEquals(stats2.getMemorySizeInBytes(), stats2.getMemorySizeInBytes());
    assertEquals(stats1.getMissCount(), stats2.getMissCount());
    assertEquals(stats1.getTotalCount(), stats2.getTotalCount());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:IndexStatsIT.java

示例4: assertCumulativeQueryCacheStats

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
private void assertCumulativeQueryCacheStats(IndicesStatsResponse response) {
    assertAllSuccessful(response);
    QueryCacheStats total = response.getTotal().queryCache;
    QueryCacheStats indexTotal = new QueryCacheStats();
    QueryCacheStats shardTotal = new QueryCacheStats();
    for (IndexStats indexStats : response.getIndices().values()) {
        indexTotal.add(indexStats.getTotal().queryCache);
        for (ShardStats shardStats : response.getShards()) {
            shardTotal.add(shardStats.getStats().queryCache);
        }
    }
    assertEquals(total, indexTotal);
    assertEquals(total, shardTotal);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:IndexStatsIT.java

示例5: randomIndicesStatsResponse

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
private IndicesStatsResponse randomIndicesStatsResponse(final Index[] indices) {
    List<ShardStats> shardStats = new ArrayList<>();
    for (final Index index : indices) {
        for (int i = 0; i < 2; i++) {
            ShardId shardId = new ShardId(index, i);
            Path path = createTempDir().resolve("indices").resolve(index.getUUID()).resolve(String.valueOf(i));
            ShardRouting shardRouting = ShardRouting.newUnassigned(shardId, i == 0,
                i == 0 ? StoreRecoverySource.EMPTY_STORE_INSTANCE : PeerRecoverySource.INSTANCE,
                new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null)
                );
            shardRouting = shardRouting.initialize("node-0", null, ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE);
            shardRouting = shardRouting.moveToStarted();
            CommonStats stats = new CommonStats();
            stats.fieldData = new FieldDataStats();
            stats.queryCache = new QueryCacheStats();
            stats.docs = new DocsStats();
            stats.store = new StoreStats();
            stats.indexing = new IndexingStats();
            stats.search = new SearchStats();
            stats.segments = new SegmentsStats();
            stats.merge = new MergeStats();
            stats.refresh = new RefreshStats();
            stats.completion = new CompletionStats();
            stats.requestCache = new RequestCacheStats();
            stats.get = new GetStats();
            stats.flush = new FlushStats();
            stats.warmer = new WarmerStats();
            shardStats.add(new ShardStats(shardRouting, new ShardPath(false, path, path, shardId), stats, null, null));
        }
    }
    return IndicesStatsTests.newIndicesStatsResponse(
        shardStats.toArray(new ShardStats[shardStats.size()]), shardStats.size(), shardStats.size(), 0, emptyList()
    );
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:RestIndicesActionTests.java

示例6: readFrom

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
@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);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:ClusterStatsIndices.java

示例7: testCaching

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
@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)));
}
 
开发者ID:sirensolutions,项目名称:siren-join,代码行数:34,代码来源:FieldDataTermsQueryTest.java

示例8: toQueryCacheStats

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
QueryCacheStats toQueryCacheStats() {
    return new QueryCacheStats(ramBytesUsed, hitCount, missCount, cacheCount, cacheSize);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:IndicesQueryCache.java

示例9: getQueryCache

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
@Nullable
public QueryCacheStats getQueryCache() {
    return stats.getQueryCache();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:NodeIndicesStats.java

示例10: getQueryCache

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
@Nullable
public QueryCacheStats getQueryCache() {
    return this.queryCache;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:CommonStats.java

示例11: getQueryCache

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
public QueryCacheStats getQueryCache() {
    return queryCache;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:ClusterStatsIndices.java

示例12: testBasics

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
public void testBasics() throws IOException {
    Directory dir = newDirectory();
    IndexWriter w = new IndexWriter(dir, newIndexWriterConfig());
    w.addDocument(new Document());
    DirectoryReader r = DirectoryReader.open(w);
    w.close();
    ShardId shard = new ShardId("index", "_na_", 0);
    r = ElasticsearchDirectoryReader.wrap(r, shard);
    IndexSearcher s = new IndexSearcher(r);
    s.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);

    Settings settings = Settings.builder()
            .put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING.getKey(), 10)
            .put(IndicesQueryCache.INDICES_QUERIES_CACHE_ALL_SEGMENTS_SETTING.getKey(), true)
            .build();
    IndicesQueryCache cache = new IndicesQueryCache(settings);
    s.setQueryCache(cache);

    QueryCacheStats stats = cache.getStats(shard);
    assertEquals(0L, stats.getCacheSize());
    assertEquals(0L, stats.getCacheCount());
    assertEquals(0L, stats.getHitCount());
    assertEquals(0L, stats.getMissCount());

    assertEquals(1, s.count(new DummyQuery(0)));

    stats = cache.getStats(shard);
    assertEquals(1L, stats.getCacheSize());
    assertEquals(1L, stats.getCacheCount());
    assertEquals(0L, stats.getHitCount());
    assertEquals(1L, stats.getMissCount());

    for (int i = 1; i < 20; ++i) {
        assertEquals(1, s.count(new DummyQuery(i)));
    }

    stats = cache.getStats(shard);
    assertEquals(10L, stats.getCacheSize());
    assertEquals(20L, stats.getCacheCount());
    assertEquals(0L, stats.getHitCount());
    assertEquals(20L, stats.getMissCount());

    s.count(new DummyQuery(10));

    stats = cache.getStats(shard);
    assertEquals(10L, stats.getCacheSize());
    assertEquals(20L, stats.getCacheCount());
    assertEquals(1L, stats.getHitCount());
    assertEquals(20L, stats.getMissCount());

    IOUtils.close(r, dir);

    // got emptied, but no changes to other metrics
    stats = cache.getStats(shard);
    assertEquals(0L, stats.getCacheSize());
    assertEquals(20L, stats.getCacheCount());
    assertEquals(1L, stats.getHitCount());
    assertEquals(20L, stats.getMissCount());

    cache.onClose(shard);

    // forgot everything
    stats = cache.getStats(shard);
    assertEquals(0L, stats.getCacheSize());
    assertEquals(0L, stats.getCacheCount());
    assertEquals(0L, stats.getHitCount());
    assertEquals(0L, stats.getMissCount());

    cache.close(); // this triggers some assertions
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:71,代码来源:IndicesQueryCacheTests.java

示例13: testStatsOnEviction

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
public void testStatsOnEviction() throws IOException {
    Directory dir1 = newDirectory();
    IndexWriter w1 = new IndexWriter(dir1, newIndexWriterConfig());
    w1.addDocument(new Document());
    DirectoryReader r1 = DirectoryReader.open(w1);
    w1.close();
    ShardId shard1 = new ShardId("index", "_na_", 0);
    r1 = ElasticsearchDirectoryReader.wrap(r1, shard1);
    IndexSearcher s1 = new IndexSearcher(r1);
    s1.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);

    Directory dir2 = newDirectory();
    IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig());
    w2.addDocument(new Document());
    DirectoryReader r2 = DirectoryReader.open(w2);
    w2.close();
    ShardId shard2 = new ShardId("index", "_na_", 1);
    r2 = ElasticsearchDirectoryReader.wrap(r2, shard2);
    IndexSearcher s2 = new IndexSearcher(r2);
    s2.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);

    Settings settings = Settings.builder()
            .put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING.getKey(), 10)
            .put(IndicesQueryCache.INDICES_QUERIES_CACHE_ALL_SEGMENTS_SETTING.getKey(), true)
            .build();
    IndicesQueryCache cache = new IndicesQueryCache(settings);
    s1.setQueryCache(cache);
    s2.setQueryCache(cache);

    assertEquals(1, s1.count(new DummyQuery(0)));

    for (int i = 1; i <= 20; ++i) {
        assertEquals(1, s2.count(new DummyQuery(i)));
    }

    QueryCacheStats stats1 = cache.getStats(shard1);
    assertEquals(0L, stats1.getCacheSize());
    assertEquals(1L, stats1.getCacheCount());

    // this used to fail because we were evicting an empty cache on
    // the segment from r1
    IOUtils.close(r1, dir1);
    cache.onClose(shard1);

    IOUtils.close(r2, dir2);
    cache.onClose(shard2);

    cache.close(); // this triggers some assertions
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:50,代码来源:IndicesQueryCacheTests.java

示例14: queryCacheStats

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
public QueryCacheStats queryCacheStats() {
    return indicesQueryCache.getStats(shardId);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:IndexShard.java

示例15: CommonStats

import org.elasticsearch.index.cache.query.QueryCacheStats; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:71,代码来源:CommonStats.java


注:本文中的org.elasticsearch.index.cache.query.QueryCacheStats类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。