You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "timoninmaxim (via GitHub)" <gi...@apache.org> on 2023/06/06 14:34:16 UTC

[GitHub] [ignite] timoninmaxim commented on a diff in pull request #10675: IGNITE-15629 Management API introduced

timoninmaxim commented on code in PR #10675:
URL: https://github.com/apache/ignite/pull/10675#discussion_r1219739897


##########
modules/core/src/main/java/org/apache/ignite/internal/management/api/Command.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.management.api;
+
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Management command interface.

Review Comment:
   Please use tags like `<p>` for formatting the docs



##########
modules/core/src/main/java/org/apache/ignite/internal/management/api/Command.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.management.api;
+
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Management command interface.
+ * Implementations represent single action to manage Ignite cluster.
+ *
+ * Name of the command that is expected from caller derived from actual command class name.
+ * Name format: all words divided by capital letters except "Command" suffix will form hierarchical command name.
+ * Example: {@code MyUsefullCommand} is name of command so {@code control.sh --my-usefull param1 param2} expected from user.
+ * Other protocols must expose command similarly. Rest API must expect {@code /api-root/my-usefull?param1=value1&param2=value2} URI.
+ *
+ * @param <A> Argument type.
+ * @param <R> Result type.
+ */
+public interface Command<A extends IgniteDataTransferObject, R> {
+    /** */
+    public String CMD_NAME_POSTFIX = "Command";

Review Comment:
   static?



##########
modules/core/src/main/java/org/apache/ignite/internal/management/api/Command.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.management.api;
+
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Management command interface.

Review Comment:
   <img width="840" alt="Снимок экрана 2023-06-06 в 17 16 33" src="https://github.com/apache/ignite/assets/5667421/34165318-15a0-49a6-9d43-b3155635a0ba">
   



##########
modules/core/src/main/java/org/apache/ignite/internal/management/api/CommandsRegistry.java:
##########
@@ -15,41 +15,32 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.commandline.cache.argument;
+package org.apache.ignite.internal.management.api;
 
-import org.apache.ignite.internal.commandline.argument.CommandArg;
-import org.apache.ignite.internal.commandline.cache.CacheIndexesForceRebuild;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
 
 /**
- * Arguments for {@link CacheIndexesForceRebuild} command.
+ * Registry that knows all of its subcommands.
  */
-public enum IndexForceRebuildCommandArg implements CommandArg {
-    /** */
-    NODE_ID("--node-id"),
-
-    /** */
-    GROUP_NAMES("--group-names"),
-
-    /** */
-    CACHE_NAMES("--cache-names");
-
-    /** Argument name. */
-    private final String name;
-
+public interface CommandsRegistry<A extends IgniteDataTransferObject, R> extends Command<A, R> {
     /**
-     * @param name Argument name.
+     * @param name Name of the command.
+     * @return Command instance by name.
      */
-    IndexForceRebuildCommandArg(String name) {
-        this.name = name;
-    }
+    public Command<?, ?> command(String name);

Review Comment:
   Unused method?



##########
modules/core/src/main/java/org/apache/ignite/internal/management/api/Argument.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.management.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Fields marked with this annotation is command arguments.
+ * @see Command
+ * @see CommandsRegistry
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Argument {
+    /** @return {@code True} if argument optional, {@code false} if required. */
+    public boolean optional() default false;
+
+    /** @return Argument description. */
+    public String description() default "";
+
+    /** @return Argument example. If empty string returned then example will be generated automatically. */
+    public String example() default "";
+
+    /**
+     * Required to keep compatibility with existing {@code control.sh} output.
+     *
+     * @return {@code True} if parameter example printed in help message must be formatted in java style.
+     */
+    public boolean javaStyleExample() default false;
+
+    /**
+     * Required to keep compatibility with existing {@code control.sh} output.
+     *
+     * @return {@code True} if paramter name in java style.
+     */
+    public boolean javaStyleName() default false;
+
+    /**
+     * Required to keep compatibility with existing {@code control.sh}.

Review Comment:
   with existing ... output?



##########
modules/core/src/main/java/org/apache/ignite/internal/management/api/WithCliConfirmParameter.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.management.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks commands that must output example of optional {@code --yes} parameter.
+ * Only for compatibility with existing {@code ./control.sh} output.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface WithCliConfirmParameter {

Review Comment:
   Parameter --> Argument? Why we annotate command argument class? Let's mark commands instead (as these docs actually says).
   
   I suppose, in general argument classes can be reused? For example NoArg.class.



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