Search in sources :

Example 1 with CommitStats

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

the class InternalTestCluster method assertSameSyncIdSameDocs.

private void assertSameSyncIdSameDocs() {
    Map<String, Long> docsOnShards = new HashMap<>();
    final Collection<NodeAndClient> nodesAndClients = nodes.values();
    for (NodeAndClient nodeAndClient : nodesAndClients) {
        IndicesService indexServices = getInstance(IndicesService.class, nodeAndClient.name);
        for (IndexService indexService : indexServices) {
            for (IndexShard indexShard : indexService) {
                CommitStats commitStats = indexShard.commitStats();
                if (commitStats != null) {
                    // null if the engine is closed or if the shard is recovering
                    String syncId = commitStats.getUserData().get(Engine.SYNC_COMMIT_ID);
                    if (syncId != null) {
                        long liveDocsOnShard = commitStats.getNumDocs();
                        if (docsOnShards.get(syncId) != null) {
                            assertThat("sync id is equal but number of docs does not match on node " + nodeAndClient.name + ". expected " + docsOnShards.get(syncId) + " but got " + liveDocsOnShard, docsOnShards.get(syncId), equalTo(liveDocsOnShard));
                        } else {
                            docsOnShards.put(syncId, liveDocsOnShard);
                        }
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) IndexService(org.elasticsearch.index.IndexService) CommitStats(org.elasticsearch.index.engine.CommitStats) IndexShard(org.elasticsearch.index.shard.IndexShard) IndicesService(org.elasticsearch.indices.IndicesService)

Example 2 with CommitStats

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

the class RestShardsAction method buildTable.

private Table buildTable(RestRequest request, ClusterStateResponse state, IndicesStatsResponse stats) {
    Table table = getTableWithHeader(request);
    for (ShardRouting shard : state.getState().routingTable().allShards()) {
        ShardStats shardStats = stats.asMap().get(shard);
        CommonStats commonStats = null;
        CommitStats commitStats = null;
        if (shardStats != null) {
            commonStats = shardStats.getStats();
            commitStats = shardStats.getCommitStats();
        }
        table.startRow();
        table.addCell(shard.getIndexName());
        table.addCell(shard.id());
        IndexMetaData indexMeta = state.getState().getMetaData().getIndexSafe(shard.index());
        boolean usesShadowReplicas = false;
        if (indexMeta != null) {
            usesShadowReplicas = indexMeta.isIndexUsingShadowReplicas();
        }
        if (shard.primary()) {
            table.addCell("p");
        } else {
            if (usesShadowReplicas) {
                table.addCell("s");
            } else {
                table.addCell("r");
            }
        }
        table.addCell(shard.state());
        table.addCell(commonStats == null ? null : commonStats.getDocs().getCount());
        table.addCell(commonStats == null ? null : commonStats.getStore().getSize());
        if (shard.assignedToNode()) {
            String ip = state.getState().nodes().get(shard.currentNodeId()).getHostAddress();
            String nodeId = shard.currentNodeId();
            StringBuilder name = new StringBuilder();
            name.append(state.getState().nodes().get(shard.currentNodeId()).getName());
            if (shard.relocating()) {
                String reloIp = state.getState().nodes().get(shard.relocatingNodeId()).getHostAddress();
                String reloNme = state.getState().nodes().get(shard.relocatingNodeId()).getName();
                String reloNodeId = shard.relocatingNodeId();
                name.append(" -> ");
                name.append(reloIp);
                name.append(" ");
                name.append(reloNodeId);
                name.append(" ");
                name.append(reloNme);
            }
            table.addCell(ip);
            table.addCell(nodeId);
            table.addCell(name);
        } else {
            table.addCell(null);
            table.addCell(null);
            table.addCell(null);
        }
        table.addCell(commitStats == null ? null : commitStats.getUserData().get(Engine.SYNC_COMMIT_ID));
        if (shard.unassignedInfo() != null) {
            table.addCell(shard.unassignedInfo().getReason());
            table.addCell(UnassignedInfo.DATE_TIME_FORMATTER.printer().print(shard.unassignedInfo().getUnassignedTimeInMillis()));
            table.addCell(TimeValue.timeValueMillis(System.currentTimeMillis() - shard.unassignedInfo().getUnassignedTimeInMillis()));
            table.addCell(shard.unassignedInfo().getDetails());
        } else {
            table.addCell(null);
            table.addCell(null);
            table.addCell(null);
            table.addCell(null);
        }
        if (shard.recoverySource() != null) {
            table.addCell(shard.recoverySource().getType().toString().toLowerCase(Locale.ROOT));
        } else {
            table.addCell(null);
        }
        table.addCell(commonStats == null ? null : commonStats.getCompletion().getSize());
        table.addCell(commonStats == null ? null : commonStats.getFieldData().getMemorySize());
        table.addCell(commonStats == null ? null : commonStats.getFieldData().getEvictions());
        table.addCell(commonStats == null ? null : commonStats.getQueryCache().getMemorySize());
        table.addCell(commonStats == null ? null : commonStats.getQueryCache().getEvictions());
        table.addCell(commonStats == null ? null : commonStats.getFlush().getTotal());
        table.addCell(commonStats == null ? null : commonStats.getFlush().getTotalTime());
        table.addCell(commonStats == null ? null : commonStats.getGet().current());
        table.addCell(commonStats == null ? null : commonStats.getGet().getTime());
        table.addCell(commonStats == null ? null : commonStats.getGet().getCount());
        table.addCell(commonStats == null ? null : commonStats.getGet().getExistsTime());
        table.addCell(commonStats == null ? null : commonStats.getGet().getExistsCount());
        table.addCell(commonStats == null ? null : commonStats.getGet().getMissingTime());
        table.addCell(commonStats == null ? null : commonStats.getGet().getMissingCount());
        table.addCell(commonStats == null ? null : commonStats.getIndexing().getTotal().getDeleteCurrent());
        table.addCell(commonStats == null ? null : commonStats.getIndexing().getTotal().getDeleteTime());
        table.addCell(commonStats == null ? null : commonStats.getIndexing().getTotal().getDeleteCount());
        table.addCell(commonStats == null ? null : commonStats.getIndexing().getTotal().getIndexCurrent());
        table.addCell(commonStats == null ? null : commonStats.getIndexing().getTotal().getIndexTime());
        table.addCell(commonStats == null ? null : commonStats.getIndexing().getTotal().getIndexCount());
        table.addCell(commonStats == null ? null : commonStats.getIndexing().getTotal().getIndexFailedCount());
        table.addCell(commonStats == null ? null : commonStats.getMerge().getCurrent());
        table.addCell(commonStats == null ? null : commonStats.getMerge().getCurrentNumDocs());
        table.addCell(commonStats == null ? null : commonStats.getMerge().getCurrentSize());
        table.addCell(commonStats == null ? null : commonStats.getMerge().getTotal());
        table.addCell(commonStats == null ? null : commonStats.getMerge().getTotalNumDocs());
        table.addCell(commonStats == null ? null : commonStats.getMerge().getTotalSize());
        table.addCell(commonStats == null ? null : commonStats.getMerge().getTotalTime());
        table.addCell(commonStats == null ? null : commonStats.getRefresh().getTotal());
        table.addCell(commonStats == null ? null : commonStats.getRefresh().getTotalTime());
        table.addCell(commonStats == null ? null : commonStats.getRefresh().getListeners());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getFetchCurrent());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getFetchTime());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getFetchCount());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getOpenContexts());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getQueryCurrent());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getQueryTime());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getQueryCount());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getScrollCurrent());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getScrollTime());
        table.addCell(commonStats == null ? null : commonStats.getSearch().getTotal().getScrollCount());
        table.addCell(commonStats == null ? null : commonStats.getSegments().getCount());
        table.addCell(commonStats == null ? null : commonStats.getSegments().getMemory());
        table.addCell(commonStats == null ? null : commonStats.getSegments().getIndexWriterMemory());
        table.addCell(commonStats == null ? null : commonStats.getSegments().getVersionMapMemory());
        table.addCell(commonStats == null ? null : commonStats.getSegments().getBitsetMemory());
        table.addCell(shardStats == null || shardStats.getSeqNoStats() == null ? null : shardStats.getSeqNoStats().getMaxSeqNo());
        table.addCell(shardStats == null || shardStats.getSeqNoStats() == null ? null : shardStats.getSeqNoStats().getLocalCheckpoint());
        table.addCell(commitStats == null || shardStats.getSeqNoStats() == null ? null : shardStats.getSeqNoStats().getGlobalCheckpoint());
        table.addCell(commonStats == null ? null : commonStats.getWarmer().current());
        table.addCell(commonStats == null ? null : commonStats.getWarmer().total());
        table.addCell(commonStats == null ? null : commonStats.getWarmer().totalTime());
        table.endRow();
    }
    return table;
}
Also used : ShardStats(org.elasticsearch.action.admin.indices.stats.ShardStats) CommonStats(org.elasticsearch.action.admin.indices.stats.CommonStats) Table(org.elasticsearch.common.Table) CommitStats(org.elasticsearch.index.engine.CommitStats) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData)

Example 3 with CommitStats

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

the class IndicesStatsTests method testCommitStats.

public void testCommitStats() throws Exception {
    createIndex("test");
    ensureGreen("test");
    IndicesStatsResponse rsp = client().admin().indices().prepareStats("test").get();
    for (ShardStats shardStats : rsp.getIndex("test").getShards()) {
        final CommitStats commitStats = shardStats.getCommitStats();
        assertNotNull(commitStats);
        assertThat(commitStats.getGeneration(), greaterThan(0L));
        assertThat(commitStats.getId(), notNullValue());
        assertThat(commitStats.getUserData(), hasKey(Translog.TRANSLOG_GENERATION_KEY));
        assertThat(commitStats.getUserData(), hasKey(Translog.TRANSLOG_UUID_KEY));
    }
}
Also used : CommitStats(org.elasticsearch.index.engine.CommitStats)

Aggregations

CommitStats (org.elasticsearch.index.engine.CommitStats)3 HashMap (java.util.HashMap)1 CommonStats (org.elasticsearch.action.admin.indices.stats.CommonStats)1 ShardStats (org.elasticsearch.action.admin.indices.stats.ShardStats)1 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)1 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)1 Table (org.elasticsearch.common.Table)1 IndexService (org.elasticsearch.index.IndexService)1 IndexShard (org.elasticsearch.index.shard.IndexShard)1 IndicesService (org.elasticsearch.indices.IndicesService)1