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/10/28 11:50:33 UTC

[GitHub] [ignite] Sega76 opened a new pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Sega76 opened a new pull request #8402:
URL: https://github.com/apache/ignite/pull/8402


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


----------------------------------------------------------------
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



[GitHub] [ignite] Sega76 commented on a change in pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #8402:
URL: https://github.com/apache/ignite/pull/8402#discussion_r524491310



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotStatusTask.java
##########
@@ -0,0 +1,73 @@
+/*
+ * 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 java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSnapshot;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+
+/**
+ * @see IgniteSnapshot#statusSnapshot()
+ */
+@GridInternal
+public class VisorSnapshotStatusTask extends VisorOneNodeTask<Void, String> {
+    /** Serial version uid. */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<Void, String> job(Void arg) {
+        return new VisorSnapshotStatusJob(debug);
+    }
+
+    /** */
+    private static class VisorSnapshotStatusJob extends VisorJob<Void, String> {
+        /** Serial version uid. */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSnapshotStatusJob(boolean debug) {
+            super(null, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected String run(Void arg) throws IgniteException {
+            Set<Object> ids = ignite.context().cache().context().snapshotMgr().statusSnapshot().get().stream()

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [ignite] Sega76 commented on a change in pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #8402:
URL: https://github.com/apache/ignite/pull/8402#discussion_r524493773



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1456,6 +1470,29 @@ public CancelSnapshotCallable(String snpName) {
         }
     }
 
+    /** Get the status of a cluster snapshot operation. */
+    @GridInternal
+    private static class StatusSnapshotCallable implements IgniteClosure<Void, Object> {

Review comment:
       use `VisorMultiNodeTask`




----------------------------------------------------------------
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



[GitHub] [ignite] Sega76 commented on a change in pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #8402:
URL: https://github.com/apache/ignite/pull/8402#discussion_r524487500



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotStatusTask.java
##########
@@ -0,0 +1,73 @@
+/*
+ * 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 java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSnapshot;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+
+/**
+ * @see IgniteSnapshot#statusSnapshot()
+ */
+@GridInternal
+public class VisorSnapshotStatusTask extends VisorOneNodeTask<Void, String> {
+    /** Serial version uid. */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<Void, String> job(Void arg) {
+        return new VisorSnapshotStatusJob(debug);
+    }
+
+    /** */
+    private static class VisorSnapshotStatusJob extends VisorJob<Void, String> {
+        /** Serial version uid. */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSnapshotStatusJob(boolean debug) {
+            super(null, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected String run(Void arg) throws IgniteException {
+            Set<Object> ids = ignite.context().cache().context().snapshotMgr().statusSnapshot().get().stream()
+                    .filter(Objects::nonNull)
+                    .collect(Collectors.toSet());
+
+            if (ids.isEmpty())
+                return "No snapshot operations.";
+
+            StringBuilder sb = new StringBuilder("чSnapshot operation in progress on nodes with Consistent ID:");

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [ignite] Sega76 commented on a change in pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #8402:
URL: https://github.com/apache/ignite/pull/8402#discussion_r524488066



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/snapshot/SnapshotCommand.java
##########
@@ -51,13 +53,18 @@
     /** {@inheritDoc} */
     @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
         try (GridClient client = Command.startClient(clientCfg)) {
-            return executeTaskByNameOnNode(
-                client,
-                taskName,
-                taskArgs,
-                null,
-                clientCfg
+            Object res = executeTaskByNameOnNode(
+                    client,
+                    taskName,
+                    taskArgs,
+                    null,
+                    clientCfg
             );
+
+            if (taskName.equals(VisorSnapshotStatusTask.class.getName()))

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [ignite] Sega76 commented on a change in pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #8402:
URL: https://github.com/apache/ignite/pull/8402#discussion_r524487750



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1456,6 +1470,29 @@ public CancelSnapshotCallable(String snpName) {
         }
     }
 
+    /** Get the status of a cluster snapshot operation. */
+    @GridInternal
+    private static class StatusSnapshotCallable implements IgniteClosure<Void, Object> {
+        /** Serial version UID. */
+        private static final long serialVersionUID = 0L;
+
+        /** Auto-injected grid instance. */
+        @IgniteInstanceResource
+        private transient IgniteEx ignite;
+
+        /** */
+        public StatusSnapshotCallable() {
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object apply(Void unused) {
+            if (ignite.context().cache().context().snapshotMgr().isSnapshotCreating())

Review comment:
       fixed

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotMXBeanImpl.java
##########
@@ -47,4 +50,11 @@ public SnapshotMXBeanImpl(GridKernalContext ctx) {
     @Override public void cancelSnapshot(String snpName) {
         mgr.cancelSnapshot(snpName).get();
     }
+
+    /** {@inheritDoc} */
+    @Override public Collection<Object> statusSnapshot() {
+        return mgr.statusSnapshot().get().stream()

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [ignite] Sega76 commented on a change in pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #8402:
URL: https://github.com/apache/ignite/pull/8402#discussion_r524488550



##########
File path: modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
##########
@@ -2293,6 +2293,41 @@ public void testClusterSnapshotCreate() throws Exception {
         assertTrue("Snapshot must contains cache data [left=" + range + ']', range.isEmpty());
     }
 
+    /** @throws Exception If failed. */
+    @Test
+    public void testClusterSnapshotStatus() throws Exception {
+        int keysCnt = 100;
+        String snpName = "snapshot_02052020";
+
+        IgniteEx ig = startGrid(0);
+        ig.cluster().state(ACTIVE);
+
+        createCacheAndPreload(ig, keysCnt);
+
+        CommandHandler h = new CommandHandler();
+
+        assertEquals(EXIT_CODE_OK, execute(h, "--snapshot", "status"));
+
+        assertTrue(h.getLastOperationResult().toString().contains("No snapshot operations."));
+
+        assertEquals(EXIT_CODE_OK, execute(h, "--snapshot", "create", snpName));
+
+        assertEquals(EXIT_CODE_OK, execute(h, "--snapshot", "status"));
+
+        assertTrue(h.getLastOperationResult().toString()
+                .contains("Snapshot operation in progress on nodes with Consistent ID:"));

Review comment:
       added assert




----------------------------------------------------------------
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



[GitHub] [ignite] Sega76 commented on a change in pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #8402:
URL: https://github.com/apache/ignite/pull/8402#discussion_r527130915



##########
File path: modules/core/src/main/java/org/apache/ignite/IgniteSnapshot.java
##########
@@ -48,4 +49,11 @@
      * @return Future which will be completed when cancel operation finished.
      */
     public IgniteFuture<Void> cancelSnapshot(String name);
+
+    /**
+     * Status snapshot operation.

Review comment:
       It's enough?




----------------------------------------------------------------
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



[GitHub] [ignite] Sega76 commented on a change in pull request #8402: IGNITE-13510: Getting status of snapshot execution via command line and jmx.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #8402:
URL: https://github.com/apache/ignite/pull/8402#discussion_r528210832



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/snapshot/SnapshotSubcommand.java
##########
@@ -29,7 +29,10 @@
     CREATE("create"),
 
     /** Sub-command to cancel running snapshot. */
-    CANCEL("cancel");
+    CANCEL("cancel"),
+
+    /** Sub-command to get consistent IDs of the nodes on which the snapshot operation is in progress. */

Review comment:
       or 
   Sub-command to checks running snapshot operation is in progress on the nodes?




----------------------------------------------------------------
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