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 2022/08/17 16:36:05 UTC

[GitHub] [ignite] NSAmelchev opened a new pull request, #10202: IGNITE-13510 Added snapshot status command to control.sh and JMX.

NSAmelchev opened a new pull request, #10202:
URL: https://github.com/apache/ignite/pull/10202

   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.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] xtern commented on a diff in pull request #10202: IGNITE-13510 Added snapshot status command to control.sh and JMX.

Posted by GitBox <gi...@apache.org>.
xtern commented on code in PR #10202:
URL: https://github.com/apache/ignite/pull/10202#discussion_r948937855


##########
modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotRestoreTask.java:
##########
@@ -25,8 +25,11 @@
 
 /**
  * Visor snapshot restore task.
+ *
+ * @deprecated Use {@link VisorSnapshotStatusTask} instead.
  */
 @GridInternal
+@Deprecated

Review Comment:
   I think we should deprecate only job now.



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] NSAmelchev commented on a diff in pull request #10202: IGNITE-13510 Added snapshot status command to control.sh and JMX.

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on code in PR #10202:
URL: https://github.com/apache/ignite/pull/10202#discussion_r948938452


##########
modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotRestoreTask.java:
##########
@@ -25,8 +25,11 @@
 
 /**
  * Visor snapshot restore task.
+ *
+ * @deprecated Use {@link VisorSnapshotStatusTask} instead.
  */
 @GridInternal
+@Deprecated

Review Comment:
   Fixed, thanks.



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] xtern commented on a diff in pull request #10202: IGNITE-13510 Added snapshot status command to control.sh and JMX.

Posted by GitBox <gi...@apache.org>.
xtern commented on code in PR #10202:
URL: https://github.com/apache/ignite/pull/10202#discussion_r949157044


##########
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/snapshot/SnapshotStatusCommand.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.commandline.snapshot;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.systemview.SystemViewCommand;
+import org.apache.ignite.internal.util.GridStringBuilder;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.snapshot.VisorSnapshotStatusTask;
+import org.apache.ignite.internal.visor.snapshot.VisorSnapshotStatusTask.SnapshotStatus;
+
+import static org.apache.ignite.internal.commandline.CommandList.SNAPSHOT;
+import static org.apache.ignite.internal.commandline.snapshot.SnapshotSubcommands.STATUS;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleType.STRING;
+
+/**
+ * Command to get the status of the current snapshot operation in the cluster.
+ */
+public class SnapshotStatusCommand extends SnapshotSubcommand {
+    /** */
+    protected SnapshotStatusCommand() {
+        super("status", VisorSnapshotStatusTask.class);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void printResult(Object res, Logger log) {
+        if (res == null) {
+            log.info("There is no create or restore snapshot operation in progress.");
+
+            return;
+        }
+
+        SnapshotStatus status = (SnapshotStatus)res;
+
+        boolean isCreating = status.operation() == VisorSnapshotStatusTask.SnapshotOperation.CREATE;
+
+        GridStringBuilder s = new GridStringBuilder();
+
+        if (isCreating)
+            s.a("Create snapshot operation is in progress.").nl();
+        else
+            s.a("Restore snapshot operation is in progress.").nl();
+
+        s.a("Snapshot name: ").a(status.name()).nl();
+        s.a("Operation ID: ").a(status.requestId()).nl();
+        s.a("Started at: ").a(DateFormat.getDateTimeInstance().format(new Date(status.startTime()))).nl();
+        s.a("Duration: ").a(X.timeSpan2DHMSM(System.currentTimeMillis() - status.startTime())).nl()
+                .nl();
+        s.a("Estimated operation progress:").nl();
+
+        log.info(s.toString());
+
+        List<String> titles = isCreating ? F.asList("Node ID", "Processed, bytes", "Total, bytes", "Percent") :
+                F.asList("Node ID", "Processed, partitions", "Total, partitions", "Percent");
+
+        List<List<?>> rows = status.progress().entrySet().stream().sorted(Map.Entry.comparingByKey()).map(e -> {
+            UUID nodeId = e.getKey();
+            long processed = e.getValue().get1();
+            long total = e.getValue().get2();
+
+            if (total <= 0)
+                return F.asList(nodeId, "unknown", "unknown", "unknown");
+
+            String percent = (int)(processed * 100 / total) + "%";
+
+            if (isCreating)
+                return F.asList(nodeId, U.humanReadableByteCount(processed), U.humanReadableByteCount(total), percent);
+            else
+                return F.asList(nodeId, processed, total, percent);
+        }).collect(Collectors.toList());
+
+        SystemViewCommand.printTable(titles, F.asList(STRING, NUMBER, NUMBER, NUMBER),
+                rows, log);
+
+        log.info(U.nl());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void parseArguments(CommandArgIterator argIter) {
+        // No-op.

Review Comment:
   ```suggestion
           if (argIter.hasNextSubArg())
               throw new IllegalArgumentException("Unexpected argument: " + argIter.peekNextArg() + '.');
   ```



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] NSAmelchev commented on a diff in pull request #10202: IGNITE-13510 Added snapshot status command to control.sh and JMX.

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on code in PR #10202:
URL: https://github.com/apache/ignite/pull/10202#discussion_r949174364


##########
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/snapshot/SnapshotStatusCommand.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.commandline.snapshot;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.systemview.SystemViewCommand;
+import org.apache.ignite.internal.util.GridStringBuilder;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.snapshot.VisorSnapshotStatusTask;
+import org.apache.ignite.internal.visor.snapshot.VisorSnapshotStatusTask.SnapshotStatus;
+
+import static org.apache.ignite.internal.commandline.CommandList.SNAPSHOT;
+import static org.apache.ignite.internal.commandline.snapshot.SnapshotSubcommands.STATUS;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleType.STRING;
+
+/**
+ * Command to get the status of the current snapshot operation in the cluster.
+ */
+public class SnapshotStatusCommand extends SnapshotSubcommand {
+    /** */
+    protected SnapshotStatusCommand() {
+        super("status", VisorSnapshotStatusTask.class);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void printResult(Object res, Logger log) {
+        if (res == null) {
+            log.info("There is no create or restore snapshot operation in progress.");
+
+            return;
+        }
+
+        SnapshotStatus status = (SnapshotStatus)res;
+
+        boolean isCreating = status.operation() == VisorSnapshotStatusTask.SnapshotOperation.CREATE;
+
+        GridStringBuilder s = new GridStringBuilder();
+
+        if (isCreating)
+            s.a("Create snapshot operation is in progress.").nl();
+        else
+            s.a("Restore snapshot operation is in progress.").nl();
+
+        s.a("Snapshot name: ").a(status.name()).nl();
+        s.a("Operation ID: ").a(status.requestId()).nl();
+        s.a("Started at: ").a(DateFormat.getDateTimeInstance().format(new Date(status.startTime()))).nl();
+        s.a("Duration: ").a(X.timeSpan2DHMSM(System.currentTimeMillis() - status.startTime())).nl()
+                .nl();
+        s.a("Estimated operation progress:").nl();
+
+        log.info(s.toString());
+
+        List<String> titles = isCreating ? F.asList("Node ID", "Processed, bytes", "Total, bytes", "Percent") :
+                F.asList("Node ID", "Processed, partitions", "Total, partitions", "Percent");
+
+        List<List<?>> rows = status.progress().entrySet().stream().sorted(Map.Entry.comparingByKey()).map(e -> {
+            UUID nodeId = e.getKey();
+            long processed = e.getValue().get1();
+            long total = e.getValue().get2();
+
+            if (total <= 0)
+                return F.asList(nodeId, "unknown", "unknown", "unknown");
+
+            String percent = (int)(processed * 100 / total) + "%";
+
+            if (isCreating)
+                return F.asList(nodeId, U.humanReadableByteCount(processed), U.humanReadableByteCount(total), percent);
+            else
+                return F.asList(nodeId, processed, total, percent);
+        }).collect(Collectors.toList());
+
+        SystemViewCommand.printTable(titles, F.asList(STRING, NUMBER, NUMBER, NUMBER),
+                rows, log);
+
+        log.info(U.nl());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void parseArguments(CommandArgIterator argIter) {
+        // No-op.

Review Comment:
   Fixed, thanks



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] NSAmelchev merged pull request #10202: IGNITE-13510 Added snapshot status command to control.sh and JMX.

Posted by GitBox <gi...@apache.org>.
NSAmelchev merged PR #10202:
URL: https://github.com/apache/ignite/pull/10202


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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org