Skip to content

Commit

Permalink
Rename handler isActive to isReplicating.
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <[email protected]>
  • Loading branch information
mch2 committed Jun 17, 2022
1 parent 990246d commit b016ad9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void startSegmentCopy(GetSegmentFilesRequest request, ActionListener<GetSegmentF
final DiscoveryNode node = request.getTargetNode();
final SegmentReplicationSourceHandler handler = nodesToHandlers.get(node);
if (handler != null) {
if (handler.isActive()) {
if (handler.isReplicating()) {
throw new OpenSearchException(
"Replication to shard {}, on node {} has already started",
request.getCheckpoint().getShardId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SegmentReplicationSourceHandler {
private final ListenableFuture<GetSegmentFilesResponse> future = new ListenableFuture<>();
private final List<Closeable> resources = new CopyOnWriteArrayList<>();
private final Logger logger;
private final AtomicBoolean active = new AtomicBoolean();
private final AtomicBoolean isReplicating = new AtomicBoolean();

/**
* Constructor.
Expand Down Expand Up @@ -99,7 +99,7 @@ class SegmentReplicationSourceHandler {
* @param listener {@link ActionListener} that completes with the list of files sent.
*/
public synchronized void sendFiles(GetSegmentFilesRequest request, ActionListener<GetSegmentFilesResponse> listener) {
if (active.compareAndSet(false, true) == false) {
if (isReplicating.compareAndSet(false, true) == false) {
throw new OpenSearchException("Replication to {} is already running.", shard.shardId());
}
future.addListener(listener, OpenSearchExecutors.newDirectExecutorService());
Expand Down Expand Up @@ -164,7 +164,7 @@ CopyState getCopyState() {
return copyState;
}

public boolean isActive() {
return active.get();
public boolean isReplicating() {
return isReplicating.get();
}
}

0 comments on commit b016ad9

Please sign in to comment.