Search in sources :

Example 1 with SegmentsStats

use of org.elasticsearch.index.engine.SegmentsStats in project elasticsearch by elastic.

the class RestIndicesActionTests method randomIndicesStatsResponse.

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());
}
Also used : StoreStats(org.elasticsearch.index.store.StoreStats) UnassignedInfo(org.elasticsearch.cluster.routing.UnassignedInfo) RefreshStats(org.elasticsearch.index.refresh.RefreshStats) ArrayList(java.util.ArrayList) Index(org.elasticsearch.index.Index) GetStats(org.elasticsearch.index.get.GetStats) SegmentsStats(org.elasticsearch.index.engine.SegmentsStats) ShardId(org.elasticsearch.index.shard.ShardId) CommonStats(org.elasticsearch.action.admin.indices.stats.CommonStats) FlushStats(org.elasticsearch.index.flush.FlushStats) ShardPath(org.elasticsearch.index.shard.ShardPath) QueryCacheStats(org.elasticsearch.index.cache.query.QueryCacheStats) DocsStats(org.elasticsearch.index.shard.DocsStats) FieldDataStats(org.elasticsearch.index.fielddata.FieldDataStats) ShardStats(org.elasticsearch.action.admin.indices.stats.ShardStats) Path(java.nio.file.Path) ShardPath(org.elasticsearch.index.shard.ShardPath) IndexingStats(org.elasticsearch.index.shard.IndexingStats) WarmerStats(org.elasticsearch.index.warmer.WarmerStats) SearchStats(org.elasticsearch.index.search.stats.SearchStats) MergeStats(org.elasticsearch.index.merge.MergeStats) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) RequestCacheStats(org.elasticsearch.index.cache.request.RequestCacheStats) CompletionStats(org.elasticsearch.search.suggest.completion.CompletionStats)

Example 2 with SegmentsStats

use of org.elasticsearch.index.engine.SegmentsStats in project elasticsearch by elastic.

the class CommonStats method add.

public void add(CommonStats stats) {
    if (docs == null) {
        if (stats.getDocs() != null) {
            docs = new DocsStats();
            docs.add(stats.getDocs());
        }
    } else {
        docs.add(stats.getDocs());
    }
    if (store == null) {
        if (stats.getStore() != null) {
            store = new StoreStats();
            store.add(stats.getStore());
        }
    } else {
        store.add(stats.getStore());
    }
    if (indexing == null) {
        if (stats.getIndexing() != null) {
            indexing = new IndexingStats();
            indexing.add(stats.getIndexing());
        }
    } else {
        indexing.add(stats.getIndexing());
    }
    if (get == null) {
        if (stats.getGet() != null) {
            get = new GetStats();
            get.add(stats.getGet());
        }
    } else {
        get.add(stats.getGet());
    }
    if (search == null) {
        if (stats.getSearch() != null) {
            search = new SearchStats();
            search.add(stats.getSearch());
        }
    } else {
        search.add(stats.getSearch());
    }
    if (merge == null) {
        if (stats.getMerge() != null) {
            merge = new MergeStats();
            merge.add(stats.getMerge());
        }
    } else {
        merge.add(stats.getMerge());
    }
    if (refresh == null) {
        if (stats.getRefresh() != null) {
            refresh = new RefreshStats();
            refresh.add(stats.getRefresh());
        }
    } else {
        refresh.add(stats.getRefresh());
    }
    if (flush == null) {
        if (stats.getFlush() != null) {
            flush = new FlushStats();
            flush.add(stats.getFlush());
        }
    } else {
        flush.add(stats.getFlush());
    }
    if (warmer == null) {
        if (stats.getWarmer() != null) {
            warmer = new WarmerStats();
            warmer.add(stats.getWarmer());
        }
    } else {
        warmer.add(stats.getWarmer());
    }
    if (queryCache == null) {
        if (stats.getQueryCache() != null) {
            queryCache = new QueryCacheStats();
            queryCache.add(stats.getQueryCache());
        }
    } else {
        queryCache.add(stats.getQueryCache());
    }
    if (fieldData == null) {
        if (stats.getFieldData() != null) {
            fieldData = new FieldDataStats();
            fieldData.add(stats.getFieldData());
        }
    } else {
        fieldData.add(stats.getFieldData());
    }
    if (completion == null) {
        if (stats.getCompletion() != null) {
            completion = new CompletionStats();
            completion.add(stats.getCompletion());
        }
    } else {
        completion.add(stats.getCompletion());
    }
    if (segments == null) {
        if (stats.getSegments() != null) {
            segments = new SegmentsStats();
            segments.add(stats.getSegments());
        }
    } else {
        segments.add(stats.getSegments());
    }
    if (translog == null) {
        if (stats.getTranslog() != null) {
            translog = new TranslogStats();
            translog.add(stats.getTranslog());
        }
    } else {
        translog.add(stats.getTranslog());
    }
    if (requestCache == null) {
        if (stats.getRequestCache() != null) {
            requestCache = new RequestCacheStats();
            requestCache.add(stats.getRequestCache());
        }
    } else {
        requestCache.add(stats.getRequestCache());
    }
    if (recoveryStats == null) {
        if (stats.getRecoveryStats() != null) {
            recoveryStats = new RecoveryStats();
            recoveryStats.add(stats.getRecoveryStats());
        }
    } else {
        recoveryStats.add(stats.getRecoveryStats());
    }
}
Also used : StoreStats(org.elasticsearch.index.store.StoreStats) RefreshStats(org.elasticsearch.index.refresh.RefreshStats) IndexingStats(org.elasticsearch.index.shard.IndexingStats) WarmerStats(org.elasticsearch.index.warmer.WarmerStats) TranslogStats(org.elasticsearch.index.translog.TranslogStats) GetStats(org.elasticsearch.index.get.GetStats) SearchStats(org.elasticsearch.index.search.stats.SearchStats) RecoveryStats(org.elasticsearch.index.recovery.RecoveryStats) SegmentsStats(org.elasticsearch.index.engine.SegmentsStats) FlushStats(org.elasticsearch.index.flush.FlushStats) QueryCacheStats(org.elasticsearch.index.cache.query.QueryCacheStats) MergeStats(org.elasticsearch.index.merge.MergeStats) DocsStats(org.elasticsearch.index.shard.DocsStats) RequestCacheStats(org.elasticsearch.index.cache.request.RequestCacheStats) FieldDataStats(org.elasticsearch.index.fielddata.FieldDataStats) CompletionStats(org.elasticsearch.search.suggest.completion.CompletionStats)

Example 3 with SegmentsStats

use of org.elasticsearch.index.engine.SegmentsStats in project elasticsearch by elastic.

the class IndexShard method segmentStats.

public SegmentsStats segmentStats(boolean includeSegmentFileSizes) {
    SegmentsStats segmentsStats = getEngine().segmentsStats(includeSegmentFileSizes);
    segmentsStats.addBitsetMemoryInBytes(shardBitsetFilterCache.getMemorySizeInBytes());
    return segmentsStats;
}
Also used : SegmentsStats(org.elasticsearch.index.engine.SegmentsStats)

Example 4 with SegmentsStats

use of org.elasticsearch.index.engine.SegmentsStats in project elasticsearch by elastic.

the class IndicesStatsTests method testSegmentStats.

public void testSegmentStats() throws Exception {
    XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("doc").startObject("properties").startObject("foo").field("type", "keyword").field("doc_values", true).field("store", true).endObject().startObject("bar").field("type", "text").field("term_vector", "with_positions_offsets_payloads").endObject().startObject("baz").field("type", "long").endObject().endObject().endObject().endObject();
    assertAcked(client().admin().indices().prepareCreate("test").addMapping("doc", mapping));
    ensureGreen("test");
    client().prepareIndex("test", "doc", "1").setSource("foo", "bar", "bar", "baz", "baz", 42).get();
    client().admin().indices().prepareRefresh("test").get();
    IndicesStatsResponse rsp = client().admin().indices().prepareStats("test").get();
    SegmentsStats stats = rsp.getIndex("test").getTotal().getSegments();
    assertThat(stats.getTermsMemoryInBytes(), greaterThan(0L));
    assertThat(stats.getStoredFieldsMemoryInBytes(), greaterThan(0L));
    assertThat(stats.getTermVectorsMemoryInBytes(), greaterThan(0L));
    assertThat(stats.getNormsMemoryInBytes(), greaterThan(0L));
    assertThat(stats.getPointsMemoryInBytes(), greaterThan(0L));
    assertThat(stats.getDocValuesMemoryInBytes(), greaterThan(0L));
    // now check multiple segments stats are merged together
    client().prepareIndex("test", "doc", "2").setSource("foo", "bar", "bar", "baz", "baz", 43).get();
    client().admin().indices().prepareRefresh("test").get();
    rsp = client().admin().indices().prepareStats("test").get();
    SegmentsStats stats2 = rsp.getIndex("test").getTotal().getSegments();
    assertThat(stats2.getTermsMemoryInBytes(), greaterThan(stats.getTermsMemoryInBytes()));
    assertThat(stats2.getStoredFieldsMemoryInBytes(), greaterThan(stats.getStoredFieldsMemoryInBytes()));
    assertThat(stats2.getTermVectorsMemoryInBytes(), greaterThan(stats.getTermVectorsMemoryInBytes()));
    assertThat(stats2.getNormsMemoryInBytes(), greaterThan(stats.getNormsMemoryInBytes()));
    assertThat(stats2.getPointsMemoryInBytes(), greaterThan(stats.getPointsMemoryInBytes()));
    assertThat(stats2.getDocValuesMemoryInBytes(), greaterThan(stats.getDocValuesMemoryInBytes()));
}
Also used : SegmentsStats(org.elasticsearch.index.engine.SegmentsStats) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder)

Example 5 with SegmentsStats

use of org.elasticsearch.index.engine.SegmentsStats in project elasticsearch by elastic.

the class IndicesStatsTests method testSegmentStatsEmptyIndex.

public void testSegmentStatsEmptyIndex() {
    createIndex("test");
    IndicesStatsResponse rsp = client().admin().indices().prepareStats("test").get();
    SegmentsStats stats = rsp.getTotal().getSegments();
    assertEquals(0, stats.getTermsMemoryInBytes());
    assertEquals(0, stats.getStoredFieldsMemoryInBytes());
    assertEquals(0, stats.getTermVectorsMemoryInBytes());
    assertEquals(0, stats.getNormsMemoryInBytes());
    assertEquals(0, stats.getPointsMemoryInBytes());
    assertEquals(0, stats.getDocValuesMemoryInBytes());
}
Also used : SegmentsStats(org.elasticsearch.index.engine.SegmentsStats)

Aggregations

SegmentsStats (org.elasticsearch.index.engine.SegmentsStats)8 QueryCacheStats (org.elasticsearch.index.cache.query.QueryCacheStats)3 RequestCacheStats (org.elasticsearch.index.cache.request.RequestCacheStats)3 FieldDataStats (org.elasticsearch.index.fielddata.FieldDataStats)3 FlushStats (org.elasticsearch.index.flush.FlushStats)3 GetStats (org.elasticsearch.index.get.GetStats)3 MergeStats (org.elasticsearch.index.merge.MergeStats)3 RefreshStats (org.elasticsearch.index.refresh.RefreshStats)3 SearchStats (org.elasticsearch.index.search.stats.SearchStats)3 IndexingStats (org.elasticsearch.index.shard.IndexingStats)3 CompletionStats (org.elasticsearch.search.suggest.completion.CompletionStats)3 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)2 ShardStats (org.elasticsearch.action.admin.indices.stats.ShardStats)2 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)2 DocsStats (org.elasticsearch.index.shard.DocsStats)2 StoreStats (org.elasticsearch.index.store.StoreStats)2 WarmerStats (org.elasticsearch.index.warmer.WarmerStats)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1