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

INTERNAL: Remove cancelNoneIdempotent arg in MoveOperationTask #878

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Changes from all commits
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
27 changes: 10 additions & 17 deletions src/main/java/net/spy/memcached/MemcachedConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,7 @@ private void updateReplConnections(List<InetSocketAddress> addrs) throws IOExcep
if (!newSlaveAddrs.contains((ArcusReplNodeAddress) oldSlaveNode.getSocketAddress())) {
removeNodes.add(oldSlaveNode);
// move operation slave -> master.
taskList.add(new MoveOperationTask(
oldSlaveNode, oldMasterNode, false));
taskList.add(new MoveOperationTask(oldSlaveNode, oldMasterNode));
// clear the masterCandidate if the removed slave is the masterCandidate.
if (oldGroup.getMasterCandidate() == oldSlaveNode) {
oldGroup.clearMasterCandidate();
Expand All @@ -510,7 +509,7 @@ private void updateReplConnections(List<InetSocketAddress> addrs) throws IOExcep
*/
oldGroup.setMasterCandidateByAddr(newMasterAddr.getIPPort());
taskList.add(new MoveOperationTask(
oldMasterCandidate, oldGroup.getMasterCandidate(), false));
oldMasterCandidate, oldGroup.getMasterCandidate()));
}
changeRoleGroups.add(oldGroup);
} else {
Expand All @@ -523,10 +522,8 @@ private void updateReplConnections(List<InetSocketAddress> addrs) throws IOExcep
delayedSwitchoverGroups.put(oldGroup);
} else {
changeRoleGroups.add(oldGroup);
taskList.add(new MoveOperationTask(
oldMasterNode, oldGroup.getMasterCandidate(), false));
taskList.add(new QueueReconnectTask(
oldMasterNode, ReconnDelay.IMMEDIATE,
taskList.add(new MoveOperationTask(oldMasterNode, oldGroup.getMasterCandidate()));
taskList.add(new QueueReconnectTask(oldMasterNode, ReconnDelay.IMMEDIATE,
"Discarded all pending reading state operation to move operations."));
}
}
Expand All @@ -537,7 +534,7 @@ private void updateReplConnections(List<InetSocketAddress> addrs) throws IOExcep
removeNodes.add(oldMasterNode);
// move operation: master -> slave.
taskList.add(new MoveOperationTask(
oldMasterNode, oldGroup.getMasterCandidate(), true));
oldMasterNode, oldGroup.getMasterCandidate()));
}

// add newly added slave node
Expand All @@ -554,7 +551,7 @@ private void updateReplConnections(List<InetSocketAddress> addrs) throws IOExcep
removeNodes.add(oldSlaveNode);
// move operation slave -> master.
taskList.add(new MoveOperationTask(
oldSlaveNode, oldGroup.getMasterCandidate(), false));
oldSlaveNode, oldGroup.getMasterCandidate()));
}
}
} else {
Expand All @@ -566,13 +563,11 @@ private void updateReplConnections(List<InetSocketAddress> addrs) throws IOExcep
}
removeNodes.add(oldMasterNode);
// move operation: master -> master.
taskList.add(new MoveOperationTask(
oldMasterNode, newMasterNode, true));
taskList.add(new MoveOperationTask(oldMasterNode, newMasterNode));
for (MemcachedNode oldSlaveNode : oldSlaveNodes) {
removeNodes.add(oldSlaveNode);
// move operation slave -> master.
taskList.add(new MoveOperationTask(
oldSlaveNode, newMasterNode, false));
taskList.add(new MoveOperationTask(oldSlaveNode, newMasterNode));
// clear the masterCandidate if the removed slave is the masterCandidate.
if (oldGroup.getMasterCandidate() == oldSlaveNode) {
oldGroup.clearMasterCandidate();
Expand Down Expand Up @@ -1734,16 +1729,14 @@ public void doTask() {
private class MoveOperationTask implements Task {
private final MemcachedNode from;
private final MemcachedNode to;
private final boolean cancelNonIdempotent;

public MoveOperationTask(MemcachedNode from, MemcachedNode to, boolean cancelNonIdempotent) {
public MoveOperationTask(MemcachedNode from, MemcachedNode to) {
this.from = from;
this.to = to;
this.cancelNonIdempotent = cancelNonIdempotent;
}

public void doTask() {
if (from.moveOperations(to, cancelNonIdempotent) > 0) {
if (from.moveOperations(to, true) > 0) {
addedQueue.offer(to);
}
}
Expand Down
Loading