Skip to content

Commit

Permalink
IGNITE-24201 Remove GridClient from control.sh (#11804)
Browse files Browse the repository at this point in the history
  • Loading branch information
NSAmelchev authored Jan 23, 2025
1 parent 718bfac commit fce02b4
Show file tree
Hide file tree
Showing 67 changed files with 164 additions and 1,279 deletions.
2 changes: 0 additions & 2 deletions docs/_docs/tools/control-script.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ If you want to connect to a node that is running on a remove machine, specify th

| --user USER | The user name. |
| --password PASSWORD |The user password. |
| --ping-interval PING_INTERVAL | The ping interval. | 5000
| --ping-timeout PING_TIMEOUT | Ping response timeout. | 30000
| --ssl-protocol PROTOCOL1, PROTOCOL2... | A list of SSL protocols to try when connecting to the cluster. link:https://docs.oracle.com/en/java/javase/11/security/java-security-overview1.html#GUID-FCF419A7-B856-46DD-A36F-C6F88F9AF37F[Supported protocols,window=_blank]. | `TLS`
| --ssl-cipher-suites CIPHER1,CIPHER2... | A list of SSL ciphers. link:https://docs.oracle.com/en/java/javase/11/docs/specs/security/standard-names.html#jsse-cipher-suite-names[Supported ciphers,window=_blank]. |
| --ssl-key-algorithm ALG | The SSL key algorithm. | `SunX509`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.function.Consumer;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.internal.client.GridClientConfiguration;
import org.apache.ignite.internal.commandline.argument.parser.CLIArgument;
import org.apache.ignite.internal.commandline.argument.parser.CLIArgumentParser;
import org.apache.ignite.internal.dto.IgniteDataTransferObject;
Expand All @@ -48,13 +47,9 @@
import org.apache.ignite.ssl.SslContextFactory;

import static org.apache.ignite.IgniteSystemProperties.IGNITE_ENABLE_EXPERIMENTAL_COMMAND;
import static org.apache.ignite.configuration.ConnectorConfiguration.DFLT_TCP_PORT;
import static org.apache.ignite.internal.client.GridClientConfiguration.DFLT_PING_INTERVAL;
import static org.apache.ignite.internal.client.GridClientConfiguration.DFLT_PING_TIMEOUT;
import static org.apache.ignite.internal.commandline.CommandHandler.DFLT_HOST;
import static org.apache.ignite.internal.commandline.CommandHandler.DFLT_PORT;
import static org.apache.ignite.internal.commandline.CommandHandler.UTILITY_NAME;
import static org.apache.ignite.internal.commandline.CommandHandler.useConnectorConnection;
import static org.apache.ignite.internal.commandline.argument.parser.CLIArgument.optionalArg;
import static org.apache.ignite.internal.management.api.CommandUtils.CMD_WORDS_DELIM;
import static org.apache.ignite.internal.management.api.CommandUtils.NAME_PREFIX;
Expand Down Expand Up @@ -98,12 +93,6 @@ public class ArgumentParser {
/** Option is used for auto confirmation. */
public static final String CMD_AUTO_CONFIRMATION = "--yes";

/** Ping interval for grid client. See {@link GridClientConfiguration#getPingInterval()}. */
static final String CMD_PING_INTERVAL = "--ping-interval";

/** Ping timeout for grid client. See {@link GridClientConfiguration#getPingTimeout()}. */
static final String CMD_PING_TIMEOUT = "--ping-timeout";

/** Verbose mode. */
public static final String CMD_VERBOSE = "--verbose";

Expand Down Expand Up @@ -151,12 +140,6 @@ public class ArgumentParser {
throw new IllegalArgumentException("Invalid value for " + name + ": " + val);
};

/** */
private static final BiConsumer<String, Long> POSITIVE_LONG = (name, val) -> {
if (val <= 0)
throw new IllegalArgumentException("Invalid value for " + name + ": " + val);
};

/** */
private final List<CLIArgument<?>> common = new ArrayList<>();

Expand Down Expand Up @@ -186,11 +169,9 @@ public ArgumentParser(IgniteLogger log, IgniteCommandRegistry registry) {
"Whenever possible, use interactive prompt for password (just discard %s option).", name, name));

arg(CMD_HOST, "HOST_OR_IP", String.class, DFLT_HOST);
arg(CMD_PORT, "PORT", Integer.class, useConnectorConnection() ? DFLT_TCP_PORT : DFLT_PORT, PORT_VALIDATOR);
arg(CMD_PORT, "PORT", Integer.class, DFLT_PORT, PORT_VALIDATOR);
arg(CMD_USER, "USER", String.class, null);
arg(CMD_PASSWORD, "PASSWORD", String.class, null, (BiConsumer<String, String>)securityWarn);
arg(CMD_PING_INTERVAL, "PING_INTERVAL", Long.class, DFLT_PING_INTERVAL, POSITIVE_LONG);
arg(CMD_PING_TIMEOUT, "PING_TIMEOUT", Long.class, DFLT_PING_TIMEOUT, POSITIVE_LONG);
arg(CMD_VERBOSE, CMD_VERBOSE, boolean.class, false);
arg(CMD_SSL_PROTOCOL, "SSL_PROTOCOL[, SSL_PROTOCOL_2, ..., SSL_PROTOCOL_N]", String[].class, new String[] {DFLT_SSL_PROTOCOL});
arg(CMD_SSL_CIPHER_SUITES, "SSL_CIPHER_1[, SSL_CIPHER_2, ..., SSL_CIPHER_N]", String[].class, null);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,21 @@
import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.ClientConfiguration;
import org.apache.ignite.internal.client.GridClientNode;
import org.apache.ignite.internal.client.GridClientNodeStateBeforeStart;
import org.apache.ignite.internal.client.thin.TcpIgniteClient;
import org.apache.ignite.internal.dto.IgniteDataTransferObject;
import org.apache.ignite.internal.management.api.BeforeNodeStartCommand;
import org.apache.ignite.internal.management.api.Command;
import org.apache.ignite.internal.management.api.CommandInvoker;
import org.apache.ignite.internal.management.api.CommandUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;

import static org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.MANAGEMENT_CLIENT_ATTR;
import static org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLIENT_LISTENER_PORT;

/**
* Adapter of new management API command for {@code control.sh} execution flow.
*/
public class CliIgniteClientInvoker<A extends IgniteDataTransferObject> extends CommandInvoker<A> implements CloseableCliCommandInvoker {
public class CliIgniteClientInvoker<A extends IgniteDataTransferObject> extends CommandInvoker<A> implements AutoCloseable {
/** Client configuration. */
private final ClientConfiguration cfg;

Expand All @@ -56,21 +52,21 @@ public CliIgniteClientInvoker(Command<A, ?> cmd, A arg, ClientConfiguration cfg)
}

/** {@inheritDoc} */
@Override protected GridClientNode defaultNode() {
@Override protected ClusterNode defaultNode() {
String[] addr = cfg.getAddresses()[0].split(":");

String host = addr[0];
String port = addr[1];

Collection<ClusterNode> nodes = igniteClient().cluster().nodes();

return CommandUtils.clusterToClientNode(F.find(nodes, U.oldest(nodes, null), node ->
return F.find(nodes, U.oldest(nodes, null), node ->
(node.hostNames().contains(host) || node.addresses().contains(host))
&& port.equals(node.attribute(CLIENT_LISTENER_PORT).toString())));
&& port.equals(node.attribute(CLIENT_LISTENER_PORT).toString()));
}

/** {@inheritDoc} */
@Override protected @Nullable IgniteClient igniteClient() {
@Override protected IgniteClient igniteClient() {
if (client == null) {
if (cmd instanceof BeforeNodeStartCommand) {
cfg.setUserAttributes(F.asMap(MANAGEMENT_CLIENT_ATTR, Boolean.TRUE.toString()));
Expand All @@ -83,18 +79,14 @@ public CliIgniteClientInvoker(Command<A, ?> cmd, A arg, ClientConfiguration cfg)
return client;
}

/** {@inheritDoc} */
@Override public String confirmationPrompt() {
/** @return Message text to show user for. {@code null} means that confirmantion is not required. */
public String confirmationPrompt() {
return cmd.confirmationPrompt(arg);
}

/** {@inheritDoc} */
@Override public <R> R invokeBeforeNodeStart(Consumer<String> printer) throws Exception {
return ((BeforeNodeStartCommand<A, R>)cmd).execute(new GridClientNodeStateBeforeStart() {
@Override public void stopWarmUp() {
((TcpIgniteClient)igniteClient()).stopWarmUp();
}
}, arg, printer);
/** */
public <R> R invokeBeforeNodeStart(Consumer<String> printer) throws Exception {
return ((BeforeNodeStartCommand<A, R>)cmd).execute((TcpIgniteClient)igniteClient(), arg, printer);
}

/** {@inheritDoc} */
Expand Down
Loading

0 comments on commit fce02b4

Please sign in to comment.