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

Restore shutdown sequence & offload replica sync #20883

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions hazelcast/src/main/java/com/hazelcast/instance/impl/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,6 @@ public void shutdown(final boolean terminate) {
waitIfAlreadyShuttingDown();
return;
}
if (nodeExtension != null) {
nodeExtension.shutdown();
}

if (!terminate) {
int maxWaitSeconds = properties.getSeconds(GRACEFUL_SHUTDOWN_MAX_WAIT);
Expand Down Expand Up @@ -588,6 +585,9 @@ public String toString() {

@SuppressWarnings("checkstyle:npathcomplexity")
private void shutdownServices(boolean terminate) {
if (nodeExtension != null) {
nodeExtension.shutdown();
}
if (textCommandService != null) {
textCommandService.stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.hazelcast.internal.util.BiTuple;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.impl.executionservice.ExecutionService;
import com.hazelcast.spi.impl.operationservice.CallStatus;
import com.hazelcast.spi.impl.operationservice.Offload;
import com.hazelcast.spi.impl.operationservice.Operation;
Expand All @@ -41,6 +42,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.RejectedExecutionException;

import static com.hazelcast.internal.serialization.impl.SerializationUtil.readCollection;
import static com.hazelcast.internal.serialization.impl.SerializationUtil.writeCollection;
Expand Down Expand Up @@ -209,27 +211,33 @@ final class ReplicaSyncRequestOffload extends Offload {

@Override
public void start() throws Exception {
// set partition as migrating to disable mutating
// operations while preparing replication operations
if (!trySetMigratingFlag()) {
sendRetryResponse();
}

try {
// executed on generic operation thread
Integer permits = getPermits();
if (permits == null) {
return;
}
nodeEngine.getExecutionService().execute(ExecutionService.ASYNC_EXECUTOR,
() -> {
// set partition as migrating to disable mutating
// operations while preparing replication operations
if (!trySetMigratingFlag()) {
sendRetryResponse();
}

sendOperationsForNamespaces(permits);
// send retry response for remaining namespaces
if (!namespaces.isEmpty()) {
logNotEnoughPermits();
sendRetryResponse();
}
} finally {
clearMigratingFlag();
try {
Integer permits = getPermits();
if (permits == null) {
return;
}
sendOperationsForNamespaces(permits);
// send retry response for remaining namespaces
if (!namespaces.isEmpty()) {
logNotEnoughPermits();
sendRetryResponse();
}
} finally {
clearMigratingFlag();
}
});
} catch (RejectedExecutionException e) {
// if execution on async executor was rejected, then send retry response
sendRetryResponse();
}
}
}
Expand Down