ololo3000 commented on a change in pull request #9760:
URL: https://github.com/apache/ignite/pull/9760#discussion_r808461588



##########
File path: 
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/snapshot/SnapshotRestoreCommand.java
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.visor.snapshot.VisorSnapshotRestoreTask;
+import 
org.apache.ignite.internal.visor.snapshot.VisorSnapshotRestoreTaskAction;
+import org.apache.ignite.internal.visor.snapshot.VisorSnapshotRestoreTaskArg;
+
+import static org.apache.ignite.internal.commandline.CommandList.SNAPSHOT;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static 
org.apache.ignite.internal.commandline.snapshot.SnapshotRestoreCommandOption.GROUPS;
+import static 
org.apache.ignite.internal.commandline.snapshot.SnapshotRestoreCommandOption.SYNC;
+import static 
org.apache.ignite.internal.commandline.snapshot.SnapshotSubcommands.RESTORE;
+
+/**
+ * Sub-command to restore snapshot.
+ */
+public class SnapshotRestoreCommand extends SnapshotSubcommand {
+    /** Default constructor. */
+    protected SnapshotRestoreCommand() {
+        super("restore", VisorSnapshotRestoreTask.class);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger 
log) throws Exception {
+        Object res = super.execute(clientCfg, log);
+
+        log.info(String.valueOf(res));
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void parseArguments(CommandArgIterator argIter) {
+        String snpName = argIter.nextArg("Expected snapshot name.");
+        VisorSnapshotRestoreTaskAction restoreAction = parseAction(argIter);
+        Set<String> grpNames = null;
+        boolean sync = false;
+
+        while (argIter.hasNextSubArg()) {
+            String arg = argIter.nextArg(null);
+
+            if (restoreAction != VisorSnapshotRestoreTaskAction.START)

Review comment:
       I think it worth to move this check after all arguments are parsed and 
change exception message to something like:
   `CANCEL or STATUS snapshot actions are not compatible with --sync or 
--groups arguments.

##########
File path: 
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/snapshot/SnapshotCreateCommand.java
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.util.LinkedHashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.snapshot.VisorSnapshotCreateTask;
+import org.apache.ignite.internal.visor.snapshot.VisorSnapshotCreateTaskArg;
+
+import static org.apache.ignite.internal.commandline.CommandList.SNAPSHOT;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static 
org.apache.ignite.internal.commandline.snapshot.SnapshotCreateCommandOption.SYNC;
+
+/**
+ * Sub-command to create a cluster snapshot.
+ */
+public class SnapshotCreateCommand extends SnapshotSubcommand {
+    /** Default constructor. */
+    protected SnapshotCreateCommand() {
+        super("create", VisorSnapshotCreateTask.class);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void parseArguments(CommandArgIterator argIter) {
+        String snpName = argIter.nextArg("Expected snapshot name.");
+        boolean sync = false;
+
+        if (argIter.hasNextSubArg()) {
+            String arg = argIter.nextArg(null);
+
+            SnapshotCreateCommandOption option = CommandArgUtils.of(arg, 
SnapshotCreateCommandOption.class);
+
+            if (option == null)
+                throw new IllegalArgumentException("Invalid argument: " + arg 
+ ". ");

Review comment:
       Let's mention in the exception message what options are available. As it 
is done for `SnapshotRestoreCommand`.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to