Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Keeping in mind that command will be described in declarative way all newly created commands will be automatically available and used by all of the features above. 

Design Model

Command Execution

The ComputeTask is a common way for building various cluster management commands with the ability to execute them via Ignite Binary Protocol. Taking into account the current limitations mentioned above the following must be a part of design solution to create a common internal management API:

  1. A ProxyManagementTask - an entry point for each management request through the thin client API.
  2. Input arguments to find the required command by given path.
  3. Input argements to execute the corresponding command with. This is a map of parameters with String  as a key, and String  or String[]  as a value.
  4. The output execution result – BinaryObject. It may be formatted to different string results depending on what type of client is used (e.g. REST, CLI, JMX). 

Command Execution Model

...

Flow of command execution:

  1. Determine specific command.
  2. Parsing of arguments. Design assumes that every agrument will be presented as string.
  3. Filtering nodes based on arguments.
  4. Command execution.
  5. Print results. 

Design

The following design principles are proposed:

  1. Declarative command description:
    1. "path" to execute command derived from class name.
      1. SystemViewCommand resolved to path ./control.sh --system-view ... 
      2. BaselineAddCommand resolved to path ./control.sh --baseline-add ...
    2. Command argument class and fields described with annotations. This allow to fill command argument using reflection.
  2. All arguments received as strings.
  3. Results is human readable string.
  4. Command are stateless.
  5. Each command can have subcommands.
  6. All commands united in command registry.
  7. Command registry is only way to obtain command instance. 

API


...

Command Interface

Management commands are always wrapped with the ProxyManagementTask. The management command may be executed on a single cluster node only or broadcast to all nodes with reducing the execution results.

Code Block
languagejava
titleIgniteCommand
linenumberstrue
collapsetrue
//** */
public interface IgniteCommand<T> extends IgniteCallable<T>, IgniteReducer<T, T> {
    /** {@inheritDoc} */
    @Override public default boolean collect(@Nullable T t) A - argument type.
// R - result type.
// T - task type. Task implements actual command logic.

public interface Command<A extends IgniteDataTransferObject, R, T extends ComputeTask<VisorTaskArgument<A>, R>> {
    public String description();

    return truepublic Class<A> args();

    }public Class<T> task();

     /** {@inheritDoc} */
    @Override public default T reduce() {public void printResult(IgniteDataTransferObject arg, Object res, Consumer<String> printer);

    boolean experimental();

    boolean confirmable();

   return null;
    }Collection<UUID> nodes(Collection<UUID> nodes, A arg);
}


Code Block
languagejava
titleBaselineAddCommand.class
linenumberstrue
collapsetrue
/** */
@Command(name@OneOf(value = {"addnodeIds",
 "nodeId", "allNodes"}, optional commandDescription = "Add nodes to baseline topology."true)
public class BaselineAddCommandSystemViewCommandArg implementsextends IgniteCallable<String>IgniteDataTransferObject {
    /** Auto-injected Ignite instance. */@Positional
    @IgniteInstanceResource
@Argument(description = "Name of privatethe IgniteEx ignite;

    /** Parameter will be injected on command instantiation. Default comma separation. */
    @Parameter(names = {"--nodes", "-n"}, description = "List of baseline nodes to add.")system view which content should be printed." +
        " Both \"SQL\" and \"Java\" styles of system view name are supported" +
    private List<String> consistentIds;

  "  /** {@inheritDoc} */
    @Override public String call() throws Exception {(e.g. SQL_TABLES and sql.tables will be handled similarly)")
    private String systemViewName;

  Collection<BaselineNode> baseline = ignite.cluster().currentBaselineTopology();@Argument(
        Collection<ClusterNode>description srvs= = ignite.cluster().forServers().nodes();

        for (String consistentId : consistentIds) {
       "ID of the node to get the system view from (deprecated. Use --node-ids instead). If not set, random node will be chosen",
     ClusterNode node = F.find(srvs, null, new IgnitePredicate<ClusterNode>() { optional = true
    )
    private UUID nodeId;

      @Override public boolean apply(ClusterNode node) {@Argument(
        description = "Comma-separated list of nodes IDs to get the system  return node.consistentId().toString().equals(consistentId);
        view from. If not set, random node will be chosen",
        }
optional = true
    )
    private UUID[] })nodeIds;

            if (node == null)@Argument(
        description = "Get the system view from all thrownodes. new IllegalArgumentException("Node not found for consistent ID: " + consistentId);

If not set, random node will be chosen",
        optional    baseline.add(node);= true
        })

    private    ignite.cluster().setBaselineTopology(baseline)boolean allNodes;


    // The rest of returnthe consistentIds.toString();
    }code.
}

Roadmap

Phase-1

The following changes must be introduced to allow new command creation and migration processes:

  • internal framework to create commands.
  • command registry
  • annotations to mark up command classes and annotation-based scanner to fill-up the command registry;
  • command registry (available for clients and for server nodes);
  • input string parsers for CLI, REST, JMX interfaces to allow command migration to a new CommandRegistry;proxy compute task for commands management through the GridTaskExecutor;
  • migration of all commands to new framework
  • deprecation of existing JMX beans and REST API.

Phase-2

To be done.

Risks and Assumptions

...

  • ability to register commands provided by plugins. 
  • automatic documentation generation
    • html
    • man pages

Phase-3

  • thin client cli implementation.
  • deprecation of control.sh


Risks and Assumptions


Discussion Links

// Links to discussions on the devlist, if applicable.

...