Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@

package org.apache.ignite.internal.cli.commands.connect;

import static org.apache.ignite.internal.cli.commands.Options.Constants.CLUSTER_URL_KEY;
import static org.apache.ignite.internal.cli.commands.Options.Constants.NODE_URL_OR_NAME_DESC;
import static org.apache.ignite.internal.cli.commands.Options.Constants.NODE_URL_OPTION_DESC;

import jakarta.inject.Inject;
import java.net.URL;
import java.util.concurrent.Callable;
import org.apache.ignite.internal.cli.ReplManager;
import org.apache.ignite.internal.cli.call.connect.ConnectCall;
import org.apache.ignite.internal.cli.commands.BaseCommand;
import org.apache.ignite.internal.cli.commands.node.NodeNameOrUrl;
import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline;
import org.apache.ignite.internal.cli.core.call.UrlCallInput;
import org.apache.ignite.internal.cli.core.converters.UrlConverter;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;

/**
* Connects to the Ignite 3 node.
*/
@Command(name = "connect", description = "Connects to Ignite 3 node")
public class ConnectCommand extends BaseCommand implements Runnable {
public class ConnectCommand extends BaseCommand implements Callable<Integer> {

/** Node URL option. */
@Parameters(description = NODE_URL_OR_NAME_DESC, descriptionKey = CLUSTER_URL_KEY)
private NodeNameOrUrl nodeNameOrUrl;
@Parameters(description = NODE_URL_OPTION_DESC, converter = UrlConverter.class)
private URL nodeUrl;

@Inject
private ConnectCall connectCall;
Expand All @@ -48,9 +49,9 @@ public class ConnectCommand extends BaseCommand implements Runnable {

/** {@inheritDoc} */
@Override
public void run() {
public Integer call() {
int exitCode = CallExecutionPipeline.builder(connectCall)
.inputProvider(() -> new UrlCallInput(nodeNameOrUrl.stringUrl()))
.inputProvider(() -> new UrlCallInput(nodeUrl.toString()))
.output(spec.commandLine().getOut())
.errOutput(spec.commandLine().getErr())
.verbose(verbose)
Expand All @@ -59,5 +60,6 @@ public void run() {
if (exitCode == 0) {
replManager.startReplMode();
}
return exitCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.apache.ignite.internal.cli.commands.cluster.topology.LogicalTopologyReplCommand;
import org.apache.ignite.internal.cli.commands.cluster.topology.PhysicalTopologyCommand;
import org.apache.ignite.internal.cli.commands.cluster.topology.PhysicalTopologyReplCommand;
import org.apache.ignite.internal.cli.commands.connect.ConnectCommand;
import org.apache.ignite.internal.cli.commands.connect.ConnectReplCommand;
import org.apache.ignite.internal.cli.commands.node.NodeNameOrUrl;
import org.apache.ignite.internal.cli.commands.node.config.NodeConfigShowCommand;
Expand Down Expand Up @@ -141,7 +142,8 @@ static List<Arguments> cmdClassAndOptionsProvider() {
arguments(UnitUndeployCommand.class, CLUSTER_URL_OPTION, List.of("id", "--version=1.0.0")),
arguments(UnitStatusCommand.class, CLUSTER_URL_OPTION, List.of("id")),
arguments(UnitListCommand.class, CLUSTER_URL_OPTION, List.of()),
arguments(ClusterInitCommand.class, CLUSTER_URL_OPTION, List.of("--cluster-name=cluster", "--meta-storage-node=test"))
arguments(ClusterInitCommand.class, CLUSTER_URL_OPTION, List.of("--cluster-name=cluster", "--meta-storage-node=test")),
arguments(ConnectCommand.class, "", List.of())
// TODO https://issues.apache.org/jira/browse/IGNITE-18378
// Arguments.arguments(ClusterShowCommand.class, CLUSTER_URL_OPTION, List.of()),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ConnectCommandTest extends CliCommandTestBase {

@Override
protected Class<?> getCommandClass() {
return ConnectCommand.class;
return ConnectReplCommand.class;
}

@Test
Expand Down