Search in sources :

Example 1 with RetentionLeaseStats

use of org.elasticsearch.index.seqno.RetentionLeaseStats in project crate by crate.

the class IndexShardRetentionLeaseTests method testRetentionLeaseStats.

@Test
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.leases(), length, minimumRetainingSequenceNumbers, indexShard.getOperationPrimaryTerm(), length + 1);
    } finally {
        closeShards(indexShard);
    }
}
Also used : RetentionLeaseStats(org.elasticsearch.index.seqno.RetentionLeaseStats) Test(org.junit.Test)

Example 2 with RetentionLeaseStats

use of org.elasticsearch.index.seqno.RetentionLeaseStats in project crate by crate.

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());
    }
    CommonStatsFlags flags = new CommonStatsFlags().clear();
    if (request.docs()) {
        flags.set(CommonStatsFlags.Flag.Docs);
    }
    if (request.store()) {
        flags.set(CommonStatsFlags.Flag.Store);
    }
    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 ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indexShard, flags), commitStats, seqNoStats, retentionLeaseStats);
}
Also used : SeqNoStats(org.elasticsearch.index.seqno.SeqNoStats) ShardNotFoundException(org.elasticsearch.index.shard.ShardNotFoundException) IndexService(org.elasticsearch.index.IndexService) CommitStats(org.elasticsearch.index.engine.CommitStats) IndexShard(org.elasticsearch.index.shard.IndexShard) RetentionLeaseStats(org.elasticsearch.index.seqno.RetentionLeaseStats) AlreadyClosedException(org.apache.lucene.store.AlreadyClosedException)

Aggregations

RetentionLeaseStats (org.elasticsearch.index.seqno.RetentionLeaseStats)2 AlreadyClosedException (org.apache.lucene.store.AlreadyClosedException)1 IndexService (org.elasticsearch.index.IndexService)1 CommitStats (org.elasticsearch.index.engine.CommitStats)1 SeqNoStats (org.elasticsearch.index.seqno.SeqNoStats)1 IndexShard (org.elasticsearch.index.shard.IndexShard)1 ShardNotFoundException (org.elasticsearch.index.shard.ShardNotFoundException)1 Test (org.junit.Test)1