Skip to content

Commit

Permalink
PR feedback.
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <handalm@amazon.com>
  • Loading branch information
mch2 committed Oct 11, 2023
1 parent 355d125 commit 7371161
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.opensearch.index.SegmentReplicationPressureService.AsyncFailStaleReplicaTask.INTERVAL;

/**
* Service responsible for applying backpressure for lagging behind replicas when Segment Replication is enabled.
*
Expand Down Expand Up @@ -98,7 +100,7 @@ public class SegmentReplicationPressureService implements Closeable {
private final SegmentReplicationStatsTracker tracker;
private final ShardStateAction shardStateAction;

private volatile AsyncFailStaleReplicaTask failStaleReplicaTask;
private final AsyncFailStaleReplicaTask failStaleReplicaTask;

@Inject
public SegmentReplicationPressureService(
Expand Down Expand Up @@ -201,14 +203,10 @@ public void setMaxAllowedStaleReplicas(double maxAllowedStaleReplicas) {

public void setReplicationTimeLimitFailReplica(TimeValue replicationTimeLimitFailReplica) {
this.replicationTimeLimitFailReplica = replicationTimeLimitFailReplica;
updateAsyncFailReplicaTask();
}

private synchronized void updateAsyncFailReplicaTask() {
try {
failStaleReplicaTask.close();
} finally {
failStaleReplicaTask = new AsyncFailStaleReplicaTask(this);
if (TimeValue.ZERO.equals(replicationTimeLimitFailReplica)) {
failStaleReplicaTask.setInterval(TimeValue.ZERO);
} else {
failStaleReplicaTask.setInterval(INTERVAL);
}
}

Expand Down

0 comments on commit 7371161

Please sign in to comment.