use of org.apache.ignite.internal.visor.defragmentation.VisorDefragmentationTaskResult 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;
}
Aggregations