Skip to content

Commit

Permalink
Add missing javadoc.
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <handalm@amazon.com>
  • Loading branch information
mch2 committed Mar 1, 2023
1 parent 26fd750 commit d172b4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
import org.opensearch.index.shard.ShardId;
import org.opensearch.indices.IndicesService;

/**
* Service responsible for applying backpressure for lagging behind replicas when Segment Replication is enabled.
*
* @opensearch.internal
*/
public class SegmentReplicationPressureService {

public static final Logger logger = LogManager.getLogger(SegmentReplicationPressureService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;

/**
* Tracker responsible for computing SegmentReplicationStats.
*
* @opensearch.internal
*/
public class SegmentReplicationStatsTracker {

private final IndicesService indicesService;
private final Map<ShardId, AtomicLong> rejectionsPerShard;
public static final Logger logger = LogManager.getLogger(SegmentReplicationStatsTracker.class);

public SegmentReplicationStatsTracker(IndicesService indicesService) {
this.indicesService = indicesService;
this.rejectionsPerShard = ConcurrentCollections.newConcurrentMap();
}

public SegmentReplicationStats getStats() {
Expand All @@ -43,7 +46,8 @@ public SegmentReplicationStats getStats() {
indexShard.shardId(),
new SegmentReplicationPerGroupStats(
replicationStats.v2(),
rejectionsPerShard.getOrDefault(indexShard.shardId(), new AtomicLong()).get(),
// TODO: Store rejected counts.
0L,
replicationStats.v1()
)
);
Expand All @@ -52,14 +56,4 @@ public SegmentReplicationStats getStats() {
}
return new SegmentReplicationStats(stats);
}

public void incrementRejectionCount(ShardId shardId) {
rejectionsPerShard.compute(shardId, (k, v) -> {
if (v == null) {
return new AtomicLong(1);
}
v.incrementAndGet();
return v;
});
}
}

0 comments on commit d172b4a

Please sign in to comment.