You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/05/23 22:47:09 UTC

[GitHub] [ignite] NSAmelchev commented on a change in pull request #7827: IGNITE-12978: add cancel snapshot support

NSAmelchev commented on a change in pull request #7827:
URL: https://github.com/apache/ignite/pull/7827#discussion_r429582705



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -540,10 +542,14 @@ private void processLocalSnapshotStartStageResult(UUID id, Map<UUID, SnapshotOpe
             missed.removeAll(res.keySet());
             missed.removeAll(err.keySet());
 
-            snpReq.hasErr = !F.isEmpty(err) || !missed.isEmpty();
+            boolean cancelled = err.values().stream()
+                .anyMatch(e -> e instanceof IgniteFutureCancelledCheckedException);

Review comment:
       Can be in one line

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -540,10 +542,14 @@ private void processLocalSnapshotStartStageResult(UUID id, Map<UUID, SnapshotOpe
             missed.removeAll(res.keySet());
             missed.removeAll(err.keySet());
 
-            snpReq.hasErr = !F.isEmpty(err) || !missed.isEmpty();
+            boolean cancelled = err.values().stream()
+                .anyMatch(e -> e instanceof IgniteFutureCancelledCheckedException);
 
-            if (snpReq.hasErr) {
-                U.warn(log, "Execution of local snapshot tasks fails or them haven't been executed " +
+            if (cancelled) {
+                snpReq.err = new IgniteFutureCancelledCheckedException("Execution of snapshot tasks " +
+                    "has been cancelled by external process [err=" + err + ", missed=" + missed + ']');
+            } else if (!F.isEmpty(err) || !missed.isEmpty()) {

Review comment:
       `else` should be on a new line.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java
##########
@@ -627,7 +629,7 @@ private Runnable wrapExceptionIfStarted(IgniteThrowableRunner exec) {
 
     /** {@inheritDoc} */
     @Override public boolean cancel() {
-        acceptException(new IgniteCheckedException("Snapshot operation has been cancelled by external process " +
+        acceptException(new IgniteFutureCancelledCheckedException("Snapshot operation has been cancelled by external process " +

Review comment:
       Too long line

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -634,6 +642,66 @@ public boolean isSnapshotCreating() {
         }
     }
 
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> cancelSnapshot(String name) {
+        A.notNullOrEmpty(name, "Snapshot name must be not empty or null");
+
+        IgniteInternalFuture<Void> fut0 = cctx.kernalContext().closure()
+            .broadcast(new CancelSnapshotClosure(),

Review comment:
       Suppose that next processes in the cluster will happen simultaneously:
   1. The `END_SNAPSHOT` DP will be at the finish stage and only part of nodes processed their 'this::processLocalSnapshotEndStageResult'
   2. Part of nodes executes broadcasted closure `cancelLocalSnapshotTask`
   
   They are processed by different threads. Can we get a situation when part of nodes finish `clusterSnpFut` successfully and other ones with error? It's ok?

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotCancelTask.java
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.visor.snapshot;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSnapshot;
+import org.apache.ignite.internal.commandline.snapshot.SnapshotCommand;
+import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotMXBeanImpl;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+
+/**
+ * @see SnapshotCommand
+ * @see IgniteSnapshot#cancelSnapshot(String)
+ */
+@GridInternal
+public class VisorSnapshotCancelTask extends VisorOneNodeTask<String, String> {
+    /** Serial version uid. */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<String, String> job(String arg) {
+        return new VisorSnapshotCancelJob(arg, debug);
+    }
+
+    /** */
+    private static class VisorSnapshotCancelJob extends VisorJob<String, String> {
+        /** Serial version uid. */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param name Snapshot name.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSnapshotCancelJob(String name, boolean debug) {
+            super(name, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected String run(String name) throws IgniteException {
+            new SnapshotMXBeanImpl(ignite.context()).cancelSnapshot(name);
+
+            return "Snapshot operation cancelled.";

Review comment:
       Can we print `The cancel command has no effect. Snapshot already created.`  if cancel will have no effect?




----------------------------------------------------------------
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:
users@infra.apache.org