Search in sources :

Example 1 with RetentionLeaseStats

use of org.opensearch.index.seqno.RetentionLeaseStats in project OpenSearch by opensearch-project.

the class TransportClusterStatsAction method nodeOperation.

@Override
protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeRequest) {
    NodeInfo nodeInfo = nodeService.info(true, true, false, true, false, true, false, true, false, false, false);
    NodeStats nodeStats = nodeService.stats(CommonStatsFlags.NONE, true, true, true, false, true, false, false, false, false, false, true, false, false, false, false);
    List<ShardStats> shardsStats = new ArrayList<>();
    for (IndexService indexService : indicesService) {
        for (IndexShard indexShard : indexService) {
            if (indexShard.routingEntry() != null && indexShard.routingEntry().active()) {
                // only report on fully started shards
                CommitStats commitStats;
                SeqNoStats seqNoStats;
                RetentionLeaseStats retentionLeaseStats;
                try {
                    commitStats = indexShard.commitStats();
                    seqNoStats = indexShard.seqNoStats();
                    retentionLeaseStats = indexShard.getRetentionLeaseStats();
                } catch (final AlreadyClosedException e) {
                    // shard is closed - no stats is fine
                    commitStats = null;
                    seqNoStats = null;
                    retentionLeaseStats = null;
                }
                shardsStats.add(new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indicesService.getIndicesQueryCache(), indexShard, SHARD_STATS_FLAGS), commitStats, seqNoStats, retentionLeaseStats));
            }
        }
    }
    ClusterHealthStatus clusterStatus = null;
    if (clusterService.state().nodes().isLocalNodeElectedMaster()) {
        clusterStatus = new ClusterStateHealth(clusterService.state()).getStatus();
    }
    return new ClusterStatsNodeResponse(nodeInfo.getNode(), clusterStatus, nodeInfo, nodeStats, shardsStats.toArray(new ShardStats[shardsStats.size()]));
}
Also used : ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) ClusterStateHealth(org.opensearch.cluster.health.ClusterStateHealth) IndexService(org.opensearch.index.IndexService) IndexShard(org.opensearch.index.shard.IndexShard) RetentionLeaseStats(org.opensearch.index.seqno.RetentionLeaseStats) ArrayList(java.util.ArrayList) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) ClusterHealthStatus(org.opensearch.cluster.health.ClusterHealthStatus) NodeStats(org.opensearch.action.admin.cluster.node.stats.NodeStats) CommonStats(org.opensearch.action.admin.indices.stats.CommonStats) SeqNoStats(org.opensearch.index.seqno.SeqNoStats) NodeInfo(org.opensearch.action.admin.cluster.node.info.NodeInfo) CommitStats(org.opensearch.index.engine.CommitStats)

Example 2 with RetentionLeaseStats

use of org.opensearch.index.seqno.RetentionLeaseStats in project OpenSearch by opensearch-project.

the class IndexShardRetentionLeaseTests method testRetentionLeaseStats.

public void testRetentionLeaseStats() throws IOException {
    final IndexShard indexShard = newStartedShard(true, Settings.builder().put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build());
    try {
        final int length = randomIntBetween(0, 8);
        final long[] minimumRetainingSequenceNumbers = new long[length];
        for (int i = 0; i < length; i++) {
            minimumRetainingSequenceNumbers[i] = randomLongBetween(SequenceNumbers.NO_OPS_PERFORMED, Long.MAX_VALUE);
            indexShard.addRetentionLease(Integer.toString(i), minimumRetainingSequenceNumbers[i], "test-" + i, ActionListener.wrap(() -> {
            }));
        }
        final RetentionLeaseStats stats = indexShard.getRetentionLeaseStats();
        assertRetentionLeases(stats.retentionLeases(), length, minimumRetainingSequenceNumbers, indexShard.getOperationPrimaryTerm(), length + 1);
    } finally {
        closeShards(indexShard);
    }
}
Also used : RetentionLeaseStats(org.opensearch.index.seqno.RetentionLeaseStats)

Example 3 with RetentionLeaseStats

use of org.opensearch.index.seqno.RetentionLeaseStats in project OpenSearch by opensearch-project.

the class IndicesService method indexShardStats.

IndexShardStats indexShardStats(final IndicesService indicesService, final IndexShard indexShard, final CommonStatsFlags flags) {
    if (indexShard.routingEntry() == null) {
        return null;
    }
    CommitStats commitStats;
    SeqNoStats seqNoStats;
    RetentionLeaseStats retentionLeaseStats;
    try {
        commitStats = indexShard.commitStats();
        seqNoStats = indexShard.seqNoStats();
        retentionLeaseStats = indexShard.getRetentionLeaseStats();
    } catch (AlreadyClosedException e) {
        // shard is closed - no stats is fine
        commitStats = null;
        seqNoStats = null;
        retentionLeaseStats = null;
    }
    return new IndexShardStats(indexShard.shardId(), new ShardStats[] { new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indicesService.getIndicesQueryCache(), indexShard, flags), commitStats, seqNoStats, retentionLeaseStats) });
}
Also used : IndexShardStats(org.opensearch.action.admin.indices.stats.IndexShardStats) ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) CommonStats(org.opensearch.action.admin.indices.stats.CommonStats) SeqNoStats(org.opensearch.index.seqno.SeqNoStats) CommitStats(org.opensearch.index.engine.CommitStats) RetentionLeaseStats(org.opensearch.index.seqno.RetentionLeaseStats) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException) IndexShardStats(org.opensearch.action.admin.indices.stats.IndexShardStats)

Example 4 with RetentionLeaseStats

use of org.opensearch.index.seqno.RetentionLeaseStats in project OpenSearch by opensearch-project.

the class TransportIndicesStatsAction method shardOperation.

@Override
protected ShardStats shardOperation(IndicesStatsRequest request, ShardRouting shardRouting) {
    IndexService indexService = indicesService.indexServiceSafe(shardRouting.shardId().getIndex());
    IndexShard indexShard = indexService.getShard(shardRouting.shardId().id());
    // if we don't have the routing entry yet, we need it stats wise, we treat it as if the shard is not ready yet
    if (indexShard.routingEntry() == null) {
        throw new ShardNotFoundException(indexShard.shardId());
    }
    CommonStats commonStats = new CommonStats(indicesService.getIndicesQueryCache(), indexShard, request.flags());
    CommitStats commitStats;
    SeqNoStats seqNoStats;
    RetentionLeaseStats retentionLeaseStats;
    try {
        commitStats = indexShard.commitStats();
        seqNoStats = indexShard.seqNoStats();
        retentionLeaseStats = indexShard.getRetentionLeaseStats();
    } catch (final AlreadyClosedException e) {
        // shard is closed - no stats is fine
        commitStats = null;
        seqNoStats = null;
        retentionLeaseStats = null;
    }
    return new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), commonStats, commitStats, seqNoStats, retentionLeaseStats);
}
Also used : SeqNoStats(org.opensearch.index.seqno.SeqNoStats) ShardNotFoundException(org.opensearch.index.shard.ShardNotFoundException) IndexService(org.opensearch.index.IndexService) CommitStats(org.opensearch.index.engine.CommitStats) IndexShard(org.opensearch.index.shard.IndexShard) RetentionLeaseStats(org.opensearch.index.seqno.RetentionLeaseStats) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException)

Aggregations

RetentionLeaseStats (org.opensearch.index.seqno.RetentionLeaseStats)4 AlreadyClosedException (org.apache.lucene.store.AlreadyClosedException)3 CommitStats (org.opensearch.index.engine.CommitStats)3 SeqNoStats (org.opensearch.index.seqno.SeqNoStats)3 CommonStats (org.opensearch.action.admin.indices.stats.CommonStats)2 ShardStats (org.opensearch.action.admin.indices.stats.ShardStats)2 IndexService (org.opensearch.index.IndexService)2 IndexShard (org.opensearch.index.shard.IndexShard)2 ArrayList (java.util.ArrayList)1 NodeInfo (org.opensearch.action.admin.cluster.node.info.NodeInfo)1 NodeStats (org.opensearch.action.admin.cluster.node.stats.NodeStats)1 IndexShardStats (org.opensearch.action.admin.indices.stats.IndexShardStats)1 ClusterHealthStatus (org.opensearch.cluster.health.ClusterHealthStatus)1 ClusterStateHealth (org.opensearch.cluster.health.ClusterStateHealth)1 ShardNotFoundException (org.opensearch.index.shard.ShardNotFoundException)1