Search in sources :

Example 1 with DEFRAGMENTATION

use of org.apache.ignite.internal.commandline.CommandList.DEFRAGMENTATION in project ignite by apache.

the class DefragmentationCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
    try (GridClient client = Command.startClient(clientCfg)) {
        Optional<GridClientNode> firstNodeOpt = client.compute().nodes().stream().filter(GridClientNode::connectable).findFirst();
        if (firstNodeOpt.isPresent()) {
            VisorDefragmentationTaskResult res;
            if (args.nodeIds() == null) {
                res = TaskExecutor.executeTaskByNameOnNode(client, VisorDefragmentationTask.class.getName(), convertArguments(), // Use node from clientCfg.
                null, clientCfg);
            } else {
                VisorTaskArgument<?> visorArg = new VisorTaskArgument<>(client.compute().nodes().stream().filter(node -> args.nodeIds().contains(node.consistentId().toString())).map(GridClientNode::nodeId).collect(Collectors.toList()), convertArguments(), false);
                res = client.compute().projection(firstNodeOpt.get()).execute(VisorDefragmentationTask.class.getName(), visorArg);
            }
            printResult(res, log);
        } else
            log.warning("No nodes found in topology, command won't be executed.");
    } catch (Throwable t) {
        log.severe("Failed to execute defragmentation command='" + args.subcommand().text() + "'");
        log.severe(CommandLogger.errorMessage(t));
        throw t;
    }
    return null;
}
Also used : GridClientNode(org.apache.ignite.internal.client.GridClientNode) SCHEDULE(org.apache.ignite.internal.commandline.defragmentation.DefragmentationSubcommands.SCHEDULE) GridClient(org.apache.ignite.internal.client.GridClient) VisorDefragmentationTask(org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationTask) VisorDefragmentationOperation(org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationOperation) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) DefragmentationSubcommands(org.apache.ignite.internal.commandline.defragmentation.DefragmentationSubcommands) Set(java.util.Set) VisorTaskArgument(org.apache.ignite.internal.visor.VisorTaskArgument) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) CANCEL(org.apache.ignite.internal.commandline.defragmentation.DefragmentationSubcommands.CANCEL) List(java.util.List) VisorDefragmentationTaskArg(org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationTaskArg) Locale(java.util.Locale) DEFRAGMENTATION(org.apache.ignite.internal.commandline.CommandList.DEFRAGMENTATION) Optional(java.util.Optional) VisorDefragmentationTaskResult(org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationTaskResult) DefragmentationArguments(org.apache.ignite.internal.commandline.defragmentation.DefragmentationArguments) GridClientNode(org.apache.ignite.internal.client.GridClientNode) VisorDefragmentationTaskResult(org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationTaskResult) VisorTaskArgument(org.apache.ignite.internal.visor.VisorTaskArgument) GridClient(org.apache.ignite.internal.client.GridClient)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Locale (java.util.Locale)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 GridClient (org.apache.ignite.internal.client.GridClient)1 GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)1 GridClientNode (org.apache.ignite.internal.client.GridClientNode)1 DEFRAGMENTATION (org.apache.ignite.internal.commandline.CommandList.DEFRAGMENTATION)1 DefragmentationArguments (org.apache.ignite.internal.commandline.defragmentation.DefragmentationArguments)1 DefragmentationSubcommands (org.apache.ignite.internal.commandline.defragmentation.DefragmentationSubcommands)1 CANCEL (org.apache.ignite.internal.commandline.defragmentation.DefragmentationSubcommands.CANCEL)1 SCHEDULE (org.apache.ignite.internal.commandline.defragmentation.DefragmentationSubcommands.SCHEDULE)1 VisorTaskArgument (org.apache.ignite.internal.visor.VisorTaskArgument)1 VisorDefragmentationOperation (org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationOperation)1 VisorDefragmentationTask (org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationTask)1 VisorDefragmentationTaskArg (org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationTaskArg)1 VisorDefragmentationTaskResult (org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationTaskResult)1