Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Segment Replication] Add Segment Replication backpressure rejection stats to _nodes/stats #10656

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address comments on PR.
Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>
  • Loading branch information
Rishikesh1159 committed Oct 20, 2023
commit 5765b25beed5e04d3dc66a05ffd2512a5fcc8f29
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,12 @@ public SegmentReplicationStatsTracker(IndicesService indicesService) {
rejectionCount = ConcurrentCollections.newConcurrentMap();
}

public SegmentReplicationRejectionStats getRejectionStats() {
long rejectionCount = 0;
for (IndexService indexService : indicesService) {
if (indexService.getIndexSettings().isSegRepEnabled()) {
for (IndexShard indexShard : indexService) {
if (indexShard.indexSettings().isSegRepEnabled() && indexShard.routingEntry().primary()) {
rejectionCount += getStatsForShard(indexShard).getRejectedRequestCount();
}
}
}
}
return new SegmentReplicationRejectionStats(rejectionCount);
public SegmentReplicationRejectionStats getTotalRejectionStats() {
return new SegmentReplicationRejectionStats(this.rejectionCount.values().stream().mapToInt(AtomicInteger::get).sum());
}

protected Map<ShardId, AtomicInteger> getRejectionCount() {
return rejectionCount;
}

public SegmentReplicationStats getStats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public NodeStats stats(
fileCacheStats && fileCache != null ? fileCache.fileCacheStats() : null,
taskCancellation ? this.taskCancellationMonitoringService.stats() : null,
searchPipelineStats ? this.searchPipelineService.stats() : null,
segmentReplicationTrackerStats ? this.segmentReplicationStatsTracker.getRejectionStats() : null,
segmentReplicationTrackerStats ? this.segmentReplicationStatsTracker.getTotalRejectionStats() : null,
repositoriesStats ? this.repositoriesService.getRepositoriesStats() : null
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.index;

import org.opensearch.indices.IndicesService;
import org.opensearch.test.OpenSearchTestCase;

import static org.mockito.Mockito.mock;

public class SegmentReplicationStatsTrackerTests extends OpenSearchTestCase {

private IndicesService indicesService = mock(IndicesService.class);

public void testRejectedCountWhenEmpty() {
Rishikesh1159 marked this conversation as resolved.
Show resolved Hide resolved
SegmentReplicationStatsTracker segmentReplicationStatsTracker = new SegmentReplicationStatsTracker(indicesService);

// Verify that total rejection count is 0 on an empty rejectionCount map in statsTracker.
assertTrue(segmentReplicationStatsTracker.getRejectionCount().isEmpty());
assertEquals(segmentReplicationStatsTracker.getTotalRejectionStats().getTotalRejectionCount(), 0L);
}

}