IDIEP-81
Author
Sponsor
Created

 

Status

IN PROGRESS


Motivation

The IEP is intended to simplify, standardise, unifies development of Ignite management commands by providing declarative API for arguments and unified command invokers via various protocols - CLI, JMX, REST.

Overview

All of Ignite Cluster management operations are presented as running compute tasks over the cluster. Depending on the management operation required to be executed some of the tasks are running on a single Ignite node only or performing full compute operation overall cluster nodes with reducing the computation result on the originating node.

For instance, single-node operations may look the following:

  • running a built-in internal distributed operations e.g. IndexForceRebuiltTask;
  • cancelling internal operations that are currently being run e.g.  VisorScanQueryCancelTask;

Distributed management compute tasks may look the following:

  • collecting info about internal structures e.g. MetadataInfoTask;
  • custom check operations over the cluster e.g. CheckIndexInlineSizesTask;

Limitations

Command API Exposure

Each time a new management task is added or is required to be added the developer should take into account the following things:

  • a task must be exposed to the Ignite REST API (a new implementation of GridRestCommandHandler must be developed);
  • a task must be exposed to the Ignite JMX API (a new MXBean interfaces and implementations must be added);
  • a task must be exposed to the Ignite CLI (a new extension of AbstractCommand must be implemented);

Without handlers and abstractions mentioned above, a new management task won't be available for a user even if it persists in the node classpath (it's still possible to run it using the ignite thin client). Most of such handlers and abstractions look like a boilerplate code and must be covered by some internal command exposer.

There are no any sufficient abstractions in any protocol and each protocol has (or has no if you lucky) slightly different logic.

Moreover, format of arguments, help messages and other things are not standardized and have different logic from command to command. 

Command Plugin Extension

Ignite plugins have no control over the cluster management operations. The built-in management tasks can't be extended by Ignite running with custom plugins and even more, they can't be available through the standard Ignite's REST, JMX, CLI APIs.

Description

This IEP is primary focused on providing good abstraction for command invocation which includes:

  • Internal framework to declarative command definition.
  • Migration of existing commands to new framework without any changes in public behavior(if possible).
  • Creation of commands registry which provide unified access to all commands known by Ignite. 
  • Creation of invokers for all popular protocols. Each invoker must be able to invoke any of the command based on definition:
    • CLI - control.sh.
    • JMX.
    • REST - Open API bindings and REST endpoint.
  • Automatic documentation creation:
    • Ascii doc during release preparation.
    • man/tldr pages.

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. 

Command Execution

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


IgniteCommand
// 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();

    public Class<A> args();

    public Class<T> task();

    public void printResult(IgniteDataTransferObject arg, Object res, Consumer<String> printer);

    boolean experimental();

    boolean confirmable();

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


BaselineAddCommand.class
@OneOf(value = {"nodeIds", "nodeId", "allNodes"}, optional = true)
public class SystemViewCommandArg extends IgniteDataTransferObject {
    @Positional
    @Argument(description = "Name of the system view which content should be printed." +
        " Both \"SQL\" and \"Java\" styles of system view name are supported" +
        " (e.g. SQL_TABLES and sql.tables will be handled similarly)")
    private String systemViewName;

    @Argument(
        description = "ID of the node to get the system view from (deprecated. Use --node-ids instead). If not set, random node will be chosen",
        optional = true
    )
    private UUID nodeId;

    @Argument(
        description = "Comma-separated list of nodes IDs to get the system view from. If not set, random node will be chosen",
        optional = true
    )
    private UUID[] nodeIds;

    @Argument(
        description = "Get the system view from all nodes. If not set, random node will be chosen",
        optional = true
    )
    private boolean allNodes;


    // The rest of the code.
}

Roadmap

Phase-1

  • internal framework to create commands.
  • 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;
  • migration of all commands to new framework
  • deprecation of existing JMX beans and REST API.

Phase-2

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

Reference Links

[1] https://www.mail-archive.com/dev@ignite.apache.org/msg49612.html

[2] https://jcommander.org/

[3] https://picocli.info/

Tickets

Key Summary T Created Updated Due Assignee Reporter P Status Resolution Fix Version/s
Loading...
Refresh


  • No labels