Mmuzaf commented on a change in pull request #9113:
URL: https://github.com/apache/ignite/pull/9113#discussion_r653510021
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
##########
@@ -381,22 +393,58 @@ public void onNodeLeft(UUID leftNodeId) {
}
/**
- * Abort the currently running restore procedure (if any).
+ * Cancel the currently running local restore procedure.
+ *
+ * @param reason Interruption reason.
+ * @param snpName Snapshot name.
+ * @return {@code True} if the restore process with the specified snapshot
name has been canceled, {@code False} if
+ * the restore process with the specified snapshot name is not running at
all.
+ */
+ public boolean cancel(Exception reason, String snpName) {
+ SnapshotRestoreContext opCtx0 = opCtx;
+ boolean ctxStop = opCtx0 != null && (snpName == null ||
opCtx0.snpName.equals(snpName));
Review comment:
I think checking for `snpName == null` is unnecessary. We should add an
assertion `snpName != null` instead.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
##########
@@ -443,9 +491,18 @@ private void ensureCacheAbsent(String name) {
}
}
- opCtx = prepareContext(req);
+ SnapshotRestoreContext opCtx0 = opCtx = prepareContext(req);
+ ClusterSnapshotFuture fut0 = fut;
- SnapshotRestoreContext opCtx0 = opCtx;
+ if (fut0 != null) {
+ Exception err = fut0.interruptEx;
Review comment:
Why do we need this check? It seems it affects only the single node
where the `fut` exists.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1995,6 +2051,9 @@ public SnapshotStartDiscoveryMessage(
/** Snapshot finish time. */
volatile long endTime;
+ /** Interrupted exception. */
+ volatile Exception interruptEx;
Review comment:
I think we can downgrade this exception type to the
`IgniteCheckedException` and the same for `cancel` and `interrupt` methods
since the `Exception` has a too broader scope.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteCacheSnapshotManager.java
##########
@@ -49,7 +49,7 @@
/**
* Try to start local snapshot operation if it's required by discovery
event.
- *
+ *private IgniteFuture<Boolean> executeRestoreManagementTask(
Review comment:
Should we revert this change?
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
##########
@@ -381,22 +393,58 @@ public void onNodeLeft(UUID leftNodeId) {
}
/**
- * Abort the currently running restore procedure (if any).
+ * Cancel the currently running local restore procedure.
+ *
+ * @param reason Interruption reason.
+ * @param snpName Snapshot name.
+ * @return {@code True} if the restore process with the specified snapshot
name has been canceled, {@code False} if
+ * the restore process with the specified snapshot name is not running at
all.
+ */
+ public boolean cancel(Exception reason, String snpName) {
+ SnapshotRestoreContext opCtx0 = opCtx;
+ boolean ctxStop = opCtx0 != null && (snpName == null ||
opCtx0.snpName.equals(snpName));
+
+ if (ctxStop)
+ interrupt(opCtx0, reason);
+
+ ClusterSnapshotFuture fut0 = fut;
+
+ if (fut0 != null && (snpName == null || fut0.name.equals(snpName))) {
Review comment:
I think checking for snpName == null is unnecessary.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]