You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sk...@apache.org on 2022/10/23 09:15:19 UTC
[ignite-3] branch ignite-3.0.0-beta1 updated: IGNITE-17773 Removed bootstrap, node start/stop/list commands. Fixes #1138
This is an automated email from the ASF dual-hosted git repository.
sk0x50 pushed a commit to branch ignite-3.0.0-beta1
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/ignite-3.0.0-beta1 by this push:
new 65c1eda8da IGNITE-17773 Removed bootstrap, node start/stop/list commands. Fixes #1138
65c1eda8da is described below
commit 65c1eda8da3fc18ce472c4846e6c22890e622445
Author: Aleksandr Pakhomov <ap...@gmail.com>
AuthorDate: Sun Oct 23 12:06:07 2022 +0300
IGNITE-17773 Removed bootstrap, node start/stop/list commands. Fixes #1138
Signed-off-by: Slava Koptilin <sl...@gmail.com>
(cherry picked from commit 5c94f10311f58dbd8e7cf36342e240d07b8aece8)
---
.../cli/commands/node/NodeVersionCommandTest.java | 2 +-
.../cli/call/node/version/NodeVersionCall.java | 2 +-
.../internal/cli/commands/TopLevelCliCommand.java | 2 -
.../cli/commands/TopLevelCliReplCommand.java | 2 -
.../internal/cli/commands/node/NodeCommand.java | 6 +-
.../cli/commands/node/NodeReplCommand.java | 6 +-
.../commands/node/version/NodeVersionCommand.java | 4 +-
.../node/version/NodeVersionReplCommand.java | 4 +-
.../cli/deprecated/CliPathsConfigLoader.java | 135 -------
.../internal/cli/deprecated/IgnitePaths.java | 203 ----------
.../deprecated/builtins/SystemPathResolver.java | 74 ----
.../builtins/init/InitIgniteCommand.java | 218 -----------
.../cli/deprecated/builtins/init/package-info.java | 22 --
.../builtins/module/MavenArtifactResolver.java | 361 -----------------
.../builtins/module/MavenCoordinates.java | 75 ----
.../deprecated/builtins/module/ModuleManager.java | 300 --------------
.../deprecated/builtins/module/ModuleRegistry.java | 236 -----------
.../deprecated/builtins/module/ResolveResult.java | 48 ---
.../builtins/module/StandardModuleDefinition.java | 66 ----
.../deprecated/builtins/module/package-info.java | 22 --
.../cli/deprecated/builtins/node/NodeManager.java | 432 ---------------------
.../cli/deprecated/builtins/node/package-info.java | 22 --
.../cli/deprecated/builtins/package-info.java | 22 --
.../spec/BootstrapIgniteCommandSpec.java | 50 ---
.../cli/deprecated/spec/NodeCommandSpec.java | 279 -------------
.../cli/deprecated/IgniteCliInterfaceTest.java | 319 ---------------
.../builtins/init/InitIgniteCommandTest.java | 149 -------
.../cli/deprecated/builtins/init/package-info.java | 22 --
modules/runner/build.gradle | 2 +-
...iteCliRunnerTest.java => IgniteRunnerTest.java} | 10 +-
.../{IgniteCliRunner.java => IgniteRunner.java} | 6 +-
packaging/docker/docker-entrypoint.sh | 2 +-
packaging/linux/start.sh | 2 +-
packaging/zip/ignite3db.sh | 4 +-
34 files changed, 21 insertions(+), 3088 deletions(-)
diff --git a/modules/cli/src/integrationTest/java/org/apache/ignite/cli/commands/node/NodeVersionCommandTest.java b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/node/NodeVersionCommandTest.java
similarity index 96%
rename from modules/cli/src/integrationTest/java/org/apache/ignite/cli/commands/node/NodeVersionCommandTest.java
rename to modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/node/NodeVersionCommandTest.java
index f5e80c9c41..a11f3b4085 100644
--- a/modules/cli/src/integrationTest/java/org/apache/ignite/cli/commands/node/NodeVersionCommandTest.java
+++ b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/node/NodeVersionCommandTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.ignite.cli.commands.node;
+package org.apache.ignite.internal.cli.commands.node;
import static org.junit.jupiter.api.Assertions.assertAll;
diff --git a/modules/cli/src/main/java/org/apache/ignite/cli/call/node/version/NodeVersionCall.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/call/node/version/NodeVersionCall.java
similarity index 97%
rename from modules/cli/src/main/java/org/apache/ignite/cli/call/node/version/NodeVersionCall.java
rename to modules/cli/src/main/java/org/apache/ignite/internal/cli/call/node/version/NodeVersionCall.java
index f0bac00da2..619f86ba70 100644
--- a/modules/cli/src/main/java/org/apache/ignite/cli/call/node/version/NodeVersionCall.java
+++ b/modules/cli/src/main/java/org/apache/ignite/internal/cli/call/node/version/NodeVersionCall.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.ignite.cli.call.node.version;
+package org.apache.ignite.internal.cli.call.node.version;
import jakarta.inject.Singleton;
import org.apache.ignite.internal.cli.core.call.Call;
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/TopLevelCliCommand.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/TopLevelCliCommand.java
index 8dd090875e..3c9c0ed9da 100644
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/TopLevelCliCommand.java
+++ b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/TopLevelCliCommand.java
@@ -22,7 +22,6 @@ import org.apache.ignite.internal.cli.commands.cliconfig.CliCommand;
import org.apache.ignite.internal.cli.commands.cluster.ClusterCommand;
import org.apache.ignite.internal.cli.commands.node.NodeCommand;
import org.apache.ignite.internal.cli.commands.sql.SqlCommand;
-import org.apache.ignite.internal.cli.deprecated.spec.BootstrapIgniteCommandSpec;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
@@ -40,7 +39,6 @@ import picocli.CommandLine.Option;
SqlCommand.class,
CommandLine.HelpCommand.class,
CliCommand.class,
- BootstrapIgniteCommandSpec.class,
NodeCommand.class,
ClusterCommand.class
})
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/TopLevelCliReplCommand.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/TopLevelCliReplCommand.java
index acc03c623e..58b4b24ca3 100644
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/TopLevelCliReplCommand.java
+++ b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/TopLevelCliReplCommand.java
@@ -24,7 +24,6 @@ import org.apache.ignite.internal.cli.commands.connect.DisconnectCommand;
import org.apache.ignite.internal.cli.commands.node.NodeReplCommand;
import org.apache.ignite.internal.cli.commands.sql.SqlReplCommand;
import org.apache.ignite.internal.cli.commands.version.VersionCommand;
-import org.apache.ignite.internal.cli.deprecated.spec.BootstrapIgniteCommandSpec;
import picocli.CommandLine;
import picocli.shell.jline3.PicocliCommands;
@@ -39,7 +38,6 @@ import picocli.shell.jline3.PicocliCommands;
CommandLine.HelpCommand.class,
VersionCommand.class,
CliReplCommand.class,
- BootstrapIgniteCommandSpec.class,
ConnectCommand.class,
DisconnectCommand.class,
NodeReplCommand.class,
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeCommand.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeCommand.java
index 6aa9719bbf..bdaa852210 100644
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeCommand.java
+++ b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeCommand.java
@@ -17,19 +17,15 @@
package org.apache.ignite.internal.cli.commands.node;
-import org.apache.ignite.cli.commands.node.version.NodeVersionCommand;
import org.apache.ignite.internal.cli.commands.node.config.NodeConfigCommand;
import org.apache.ignite.internal.cli.commands.node.metric.NodeMetricCommand;
import org.apache.ignite.internal.cli.commands.node.status.NodeStatusCommand;
-import org.apache.ignite.internal.cli.deprecated.spec.NodeCommandSpec;
+import org.apache.ignite.internal.cli.commands.node.version.NodeVersionCommand;
import picocli.CommandLine.Command;
-import picocli.CommandLine.Mixin;
/** Node command. */
@Command(name = "node",
subcommands = {NodeConfigCommand.class, NodeStatusCommand.class, NodeVersionCommand.class, NodeMetricCommand.class},
description = "Node operations")
public class NodeCommand {
- @Mixin
- NodeCommandSpec nodeCommandSpec;
}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeReplCommand.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeReplCommand.java
index 0aa7d751ce..3f880f0732 100644
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeReplCommand.java
+++ b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/NodeReplCommand.java
@@ -17,19 +17,15 @@
package org.apache.ignite.internal.cli.commands.node;
-import org.apache.ignite.cli.commands.node.version.NodeVersionReplCommand;
import org.apache.ignite.internal.cli.commands.node.config.NodeConfigReplCommand;
import org.apache.ignite.internal.cli.commands.node.metric.NodeMetricReplCommand;
import org.apache.ignite.internal.cli.commands.node.status.NodeStatusReplCommand;
-import org.apache.ignite.internal.cli.deprecated.spec.NodeCommandSpec;
+import org.apache.ignite.internal.cli.commands.node.version.NodeVersionReplCommand;
import picocli.CommandLine.Command;
-import picocli.CommandLine.Mixin;
/** Node command in REPL mode. */
@Command(name = "node",
subcommands = {NodeConfigReplCommand.class, NodeStatusReplCommand.class, NodeVersionReplCommand.class, NodeMetricReplCommand.class},
description = "Node operations")
public class NodeReplCommand {
- @Mixin
- NodeCommandSpec nodeCommandSpec;
}
diff --git a/modules/cli/src/main/java/org/apache/ignite/cli/commands/node/version/NodeVersionCommand.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/version/NodeVersionCommand.java
similarity index 93%
rename from modules/cli/src/main/java/org/apache/ignite/cli/commands/node/version/NodeVersionCommand.java
rename to modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/version/NodeVersionCommand.java
index 31874aff42..14387ef28e 100644
--- a/modules/cli/src/main/java/org/apache/ignite/cli/commands/node/version/NodeVersionCommand.java
+++ b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/version/NodeVersionCommand.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.ignite.cli.commands.node.version;
+package org.apache.ignite.internal.cli.commands.node.version;
import jakarta.inject.Inject;
import java.util.concurrent.Callable;
-import org.apache.ignite.cli.call.node.version.NodeVersionCall;
+import org.apache.ignite.internal.cli.call.node.version.NodeVersionCall;
import org.apache.ignite.internal.cli.commands.BaseCommand;
import org.apache.ignite.internal.cli.commands.node.NodeUrlProfileMixin;
import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline;
diff --git a/modules/cli/src/main/java/org/apache/ignite/cli/commands/node/version/NodeVersionReplCommand.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/version/NodeVersionReplCommand.java
similarity index 93%
rename from modules/cli/src/main/java/org/apache/ignite/cli/commands/node/version/NodeVersionReplCommand.java
rename to modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/version/NodeVersionReplCommand.java
index e84489a4a1..326080bea6 100644
--- a/modules/cli/src/main/java/org/apache/ignite/cli/commands/node/version/NodeVersionReplCommand.java
+++ b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/version/NodeVersionReplCommand.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.ignite.cli.commands.node.version;
+package org.apache.ignite.internal.cli.commands.node.version;
import jakarta.inject.Inject;
-import org.apache.ignite.cli.call.node.version.NodeVersionCall;
+import org.apache.ignite.internal.cli.call.node.version.NodeVersionCall;
import org.apache.ignite.internal.cli.commands.BaseCommand;
import org.apache.ignite.internal.cli.commands.node.NodeUrlMixin;
import org.apache.ignite.internal.cli.commands.questions.ConnectToClusterQuestion;
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/CliPathsConfigLoader.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/CliPathsConfigLoader.java
deleted file mode 100644
index 755f569843..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/CliPathsConfigLoader.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated;
-
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Path;
-import java.util.Optional;
-import java.util.Properties;
-import org.apache.ignite.internal.cli.CliVersionInfo;
-import org.apache.ignite.internal.cli.deprecated.builtins.SystemPathResolver;
-
-/**
- * Due to the nature of Ignite CLI tool it can be run in the environment without configuration file at all. This class created to simplify
- * the managing of the different cases:
- * <ul>
- * <li>When user download binary and run it to manage any existence remote cluster</li>
- * <li>When user download binary and run 'init' to deploy Ignite distribution on the current machine</li>
- * <li>When user install it by system package</li>
- * </ul>
- */
-@Singleton
-public class CliPathsConfigLoader {
- /** System paths' resolver. */
- private final SystemPathResolver pathRslvr;
-
- /** Ignite CLI tool version. */
- private final String ver;
-
- /**
- * Creates new loader.
- *
- * @param pathRslvr System paths' resolver.
- * @param cliVerInfo CLI version info provider.
- */
- @Inject
- public CliPathsConfigLoader(
- SystemPathResolver pathRslvr,
- CliVersionInfo cliVerInfo
- ) {
- this.pathRslvr = pathRslvr;
- ver = cliVerInfo.ver;
- }
-
- /**
- * Loads Ignite paths config from file if exists.
- *
- * @return IgnitePaths if config file exists, empty otherwise.
- */
- public Optional<IgnitePaths> loadIgnitePathsConfig() {
- if (configFilePath().toFile().exists()) {
- return Optional.of(readConfigFile(configFilePath(), ver));
- }
-
- return Optional.empty();
- }
-
- /**
- * Loads Ignite paths configuration if config file exists or failed otherwise.
- *
- * @return IgnitePaths or throw exception, if no config file exists.
- */
- public IgnitePaths loadIgnitePathsOrThrowError() {
- Optional<IgnitePaths> ignitePaths = loadIgnitePathsConfig();
-
- if (ignitePaths.isPresent()) {
- if (!ignitePaths.get().validateDirs()) {
- throw new IgniteCliException("Some required directories are absent. "
- + "Try to run 'bootstrap' command to fix the issue.");
- }
-
- return ignitePaths.get();
- } else {
- throw new IgniteCliException("To execute node module/node management commands you must run 'bootstrap' first");
- }
- }
-
- /**
- * Returns path to Ignite CLI configuration file.
- *
- * @return Path to Ignite CLI config file.
- */
- public Path configFilePath() {
- return pathRslvr.osHomeDirectoryPath().resolve(".ignitecfg");
- }
-
- /**
- * Reads Ignite CLI configuration file and prepare {@link IgnitePaths} instance.
- *
- * @param cfgPath Path to config file.
- * @param ver Ignite CLI version.
- * @return IgnitePaths with resolved directories of current Ignite distribution.
- */
- private static IgnitePaths readConfigFile(Path cfgPath, String ver) {
- try (InputStream inputStream = new FileInputStream(cfgPath.toFile())) {
- Properties props = new Properties();
- props.load(inputStream);
-
- if ((props.getProperty("bin") == null)
- || (props.getProperty("work") == null)
- || (props.getProperty("config") == null)
- || (props.getProperty("log") == null)) {
- throw new IgniteCliException("Config file has wrong format. "
- + "It must contain correct paths to bin, work, config and log dirs");
- }
-
- return new IgnitePaths(
- Path.of(props.getProperty("bin")),
- Path.of(props.getProperty("work")),
- Path.of(props.getProperty("config")),
- Path.of(props.getProperty("log")),
- ver);
- } catch (IOException e) {
- throw new IgniteCliException("Can't read config file");
- }
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/IgnitePaths.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/IgnitePaths.java
deleted file mode 100644
index 205fe5fef1..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/IgnitePaths.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated;
-
-import java.io.File;
-import java.nio.file.Path;
-import org.apache.ignite.internal.cli.deprecated.builtins.module.ModuleRegistry;
-
-/**
- * The main resolver of Ignite paths for the current installation (like bin, work and etc. dirs). Current Ignite distributive has the
- * following dirs structure:
- * <ul>
- * <li>bin
- * <ul>
- * <li>${version}
- * <ul>
- * <li>cli</li>
- * <li>libs</li>
- * </ul>
- * </li>
- * </ul>
- * </li>
- * <li>work
- * <ul>
- * <li>config
- * <ul>
- * <li>default-config.xml</li>
- * </ul>
- * </li>
- * <li>cli
- * <ul>
- * <li>pids</li>
- * </ul>
- * </li>
- * <li>modules.json</li>
- * </ul>
- * </li>
- * </ul>
- */
-public class IgnitePaths {
- /**
- * Path to Ignite bin directory. Bin directory contains jar artifacts for Ignite server and CLI modules.
- */
- public final Path binDir;
-
- /** Work directory for Ignite server and CLI operation. */
- public final Path workDir;
-
- /** Directory for storing server node configs. */
- public final Path cfgDir;
-
- /** Directory for server nodes logs. */
- public final Path logDir;
-
- /**
- * Ignite CLI version. Also, the same version will be used for addressing any binaries inside bin dir
- */
- private final String ver;
-
- /**
- * Creates resolved ignite paths instance from Ignite CLI version and base dirs paths.
- *
- * @param binDir Bin directory.
- * @param workDir Work directory.
- * @param cfgDir Config directory.
- * @param logDir Log directory.
- * @param ver Ignite CLI version.
- */
- public IgnitePaths(Path binDir, Path workDir, Path cfgDir, Path logDir, String ver) {
- this.binDir = binDir;
- this.workDir = workDir;
- this.cfgDir = cfgDir;
- this.logDir = logDir;
- this.ver = ver;
- }
-
- /**
- * Returns a path where CLI module artifacts will be placed.
- *
- * @return Path where CLI module artifacts will be placed.
- */
- public Path cliLibsDir() {
- return binDir.resolve(ver).resolve("cli");
- }
-
- /**
- * Returns a path where Ignite server module artifacts will be placed..
- *
- * @return Path where Ignite server module artifacts will be placed.
- */
- public Path libsDir() {
- return binDir.resolve(ver).resolve("libs");
- }
-
- /**
- * Returns a path where Ignite node pid files will be created.
- *
- * @return Path where Ignite node pid files will be created.
- */
- public Path cliPidsDir() {
- return workDir.resolve("cli").resolve("pids");
- }
-
- /**
- * Returns a path to file with registry data for {@link ModuleRegistry}.
- *
- * @return Path to file with registry data for {@link ModuleRegistry}.
- */
- public Path installedModulesFile() {
- return workDir.resolve("modules.json");
- }
-
- /**
- * Returns a path to directory with Ignite nodes configs.
- *
- * @return Path to directory with Ignite nodes configs.
- */
- public Path serverConfigDir() {
- return workDir.resolve("config");
- }
-
- /**
- * Returns a path to the root data directory.
- *
- * @return Path to root directory for data of Ignite nodes.
- */
- public Path nodesBaseWorkDir() {
- return workDir.resolve("data");
- }
-
- /**
- * Returns a path to the default Ignite node config.
- *
- * @return Path to the default Ignite node config.
- */
- public Path serverDefaultConfigFile() {
- return cfgDir.resolve("default-config.xml");
- }
-
- /**
- * Returns a path to logging properties file.
- *
- * @return Path to logging properties file.
- */
- public Path serverJavaUtilLoggingPros() {
- return cfgDir.resolve("ignite.java.util.logging.properties");
- }
-
- /**
- * Init or recovers Ignite distributive directories structure.
- */
- public void initOrRecover() {
- initDirIfNeeded(workDir, "Can't create working directory: " + workDir);
- initDirIfNeeded(binDir, "Can't create bin directory: " + binDir);
- initDirIfNeeded(libsDir(), "Can't create a directory for ignite modules: " + libsDir());
- initDirIfNeeded(cliLibsDir(), "Can't create a directory for cli modules: " + cliLibsDir());
- initDirIfNeeded(cfgDir, "Can't create a directory for server configs: " + cfgDir);
- initDirIfNeeded(logDir, "Can't create a directory for server logs: " + logDir);
- initDirIfNeeded(nodesBaseWorkDir(), "Can't create a nodes work directory: " + nodesBaseWorkDir());
- }
-
- /**
- * Create directory if not exists.
- *
- * @param dir Directory
- * @param exceptionMessage Exception message if directory wasn't created
- */
- private void initDirIfNeeded(Path dir, String exceptionMessage) {
- File dirFile = dir.toFile();
- if (!(dirFile.exists() || dirFile.mkdirs())) {
- throw new IgniteCliException(exceptionMessage);
- }
- }
-
- /**
- * Validates that all Ignite distributive directories is exists.
- *
- * @return true if check passes, false otherwise.
- */
- public boolean validateDirs() {
- return workDir.toFile().exists()
- && binDir.toFile().exists()
- && libsDir().toFile().exists()
- && cliLibsDir().toFile().exists()
- && cfgDir.toFile().exists()
- && logDir.toFile().exists();
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/SystemPathResolver.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/SystemPathResolver.java
deleted file mode 100644
index 5e088bb538..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/SystemPathResolver.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins;
-
-import io.micronaut.core.annotation.Introspected;
-import jakarta.inject.Singleton;
-import java.io.File;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import org.apache.ignite.internal.cli.Main;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-
-/**
- * Interface for resolving different fs paths like home directory.
- */
-public interface SystemPathResolver {
- /**
- * Returns system specific user home directory..
- *
- * @return System specific user home directory.
- */
- Path osHomeDirectoryPath();
-
- /**
- * Returns directory where CLI tool binary placed.
- *
- * @return Directory where CLI tool binary placed.
- */
- Path toolHomeDirectoryPath();
-
- /**
- * Default path resolver.
- */
- @Singleton
- @Introspected
- class DefaultPathResolver implements SystemPathResolver {
- /** {@inheritDoc} */
- @Override
- public Path osHomeDirectoryPath() {
- return Path.of(System.getProperty("user.home"));
- }
-
- /** {@inheritDoc} */
- @Override
- public Path toolHomeDirectoryPath() {
- try {
- var file = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI());
-
- while (!file.isDirectory()) {
- file = file.getParentFile();
- }
-
- return file.toPath();
- } catch (URISyntaxException e) {
- throw new IgniteCliException("Failed to resolve the CLI tool home directory.", e);
- }
- }
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/init/InitIgniteCommand.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/init/InitIgniteCommand.java
deleted file mode 100644
index 9d135cc29e..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/init/InitIgniteCommand.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.init;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.ignite.internal.cli.core.style.AnsiStringSupport.ansi;
-
-import jakarta.inject.Inject;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.Properties;
-import org.apache.ignite.internal.cli.core.style.component.MessageUiComponent;
-import org.apache.ignite.internal.cli.core.style.element.UiElements;
-import org.apache.ignite.internal.cli.deprecated.CliPathsConfigLoader;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-import org.apache.ignite.internal.cli.deprecated.IgnitePaths;
-import org.apache.ignite.internal.cli.deprecated.builtins.SystemPathResolver;
-import org.apache.ignite.internal.cli.deprecated.builtins.module.ModuleManager;
-import org.jetbrains.annotations.NotNull;
-import picocli.CommandLine.Help.ColorScheme;
-
-/**
- * Implementation of command for initializing Ignite distro on the current machine. This process has the following steps:
- * <ul>
- * <li>Initialize configuration file with the needed directories paths (@see {@link IgnitePaths})</li>
- * <li>Create all needed directories for Ignite deployment</li>
- * <li>Download current Ignite distro and prepare it for running</li>
- * </ul>
- */
-public class InitIgniteCommand {
- /** Resolver of paths like home directory and etc. **/
- private final SystemPathResolver pathRslvr;
-
- /** Manager of Ignite server and CLI modules. **/
- private final ModuleManager moduleMgr;
-
- /** Loader of current Ignite distro dirs configuration. **/
- private final CliPathsConfigLoader cliPathsCfgLdr;
-
- /**
- * Creates init command instance.
- *
- * @param pathRslvr Resolver of paths like home directory and etc.
- * @param moduleMgr Manager of Ignite server and CLI modules.
- * @param cliPathsCfgLdr Loader of current Ignite distro dirs configuration.
- */
- @Inject
- public InitIgniteCommand(
- SystemPathResolver pathRslvr,
- ModuleManager moduleMgr,
- CliPathsConfigLoader cliPathsCfgLdr) {
- this.pathRslvr = pathRslvr;
- this.moduleMgr = moduleMgr;
- this.cliPathsCfgLdr = cliPathsCfgLdr;
- }
-
- /**
- * Executes init process with initialization of config file, directories, and download of current Ignite release. Also, it can be used
- * to recover after corruption of node directories structure.
- *
- * @param urls Urls with custom maven repositories for Ignite download.
- * @param out PrintWriter for output user message.
- * @param cs ColorScheme for enriching user outputs with colors.
- */
- public void init(URL[] urls, PrintWriter out, ColorScheme cs) {
- moduleMgr.setOut(out);
-
- Optional<IgnitePaths> ignitePathsOpt = cliPathsCfgLdr.loadIgnitePathsConfig();
-
- if (ignitePathsOpt.isEmpty()) {
- initConfigFile();
- }
-
- IgnitePaths cfg = cliPathsCfgLdr.loadIgnitePathsConfig().get();
-
- cfg.initOrRecover();
-
- out.println(cfg.binDir);
- out.println(cfg.workDir);
- out.println(cfg.cfgDir);
- out.println(cfg.logDir);
- out.println(ansi(UiElements.done().represent()));
-
- installIgnite(cfg, urls);
-
- initDefaultServerConfigs(cfg.serverDefaultConfigFile());
-
- initJavaUtilLoggingPros(cfg.serverJavaUtilLoggingPros());
-
- out.println();
- out.println(
- MessageUiComponent.builder()
- .message("Apache Ignite is successfully initialized")
- .hint("Run the " + cs.commandText("ignite node start") + " command to start a new local node")
- .build()
- .render()
- );
- }
-
- /**
- * Init default server config file.
- *
- * @param srvCfgFile Path to server node config file.
- */
- private void initDefaultServerConfigs(Path srvCfgFile) {
- try {
- if (!srvCfgFile.toFile().exists()) {
- Files.copy(
- InitIgniteCommand.class
- .getResourceAsStream("/default-config.xml"), srvCfgFile);
- }
- } catch (IOException e) {
- throw new IgniteCliException("Can't create default config file for server", e);
- }
- }
-
- /**
- * Init java util logging properties file.
- *
- * @param javaUtilLogProps Path to java util logging properties file.
- */
- private void initJavaUtilLoggingPros(Path javaUtilLogProps) {
- try {
- if (!javaUtilLogProps.toFile().exists()) {
- Files.copy(
- InitIgniteCommand.class
- .getResourceAsStream("/ignite.java.util.logging.properties"), javaUtilLogProps);
- }
- } catch (IOException e) {
- throw new IgniteCliException("Can't create default config file for server", e);
- }
- }
-
- /**
- * Downloads ignite node distro with all needed dependencies.
- *
- * @param ignitePaths Ignite distributive paths (bin, config, etc.).
- * @param urls Urls for custom maven repositories.
- */
- private void installIgnite(IgnitePaths ignitePaths, URL[] urls) {
- moduleMgr.addModule("_server", ignitePaths,
- urls == null ? Collections.emptyList() : Arrays.asList(urls));
- }
-
- /**
- * Init configuration file for CLI utility with Ignite directories (bin, config, etc.) paths.
- *
- * @return Initialized configuration file.
- */
- private File initConfigFile() {
- Path newCfgPath = pathRslvr.osHomeDirectoryPath().resolve(".ignitecfg");
- File newCfgFile = newCfgPath.toFile();
-
- try {
- newCfgFile.createNewFile();
-
- Path binDir = pathRslvr.toolHomeDirectoryPath().resolve("ignite-bin");
- Path workDir = pathRslvr.toolHomeDirectoryPath().resolve("ignite-work");
- Path cfgDir = pathRslvr.toolHomeDirectoryPath().resolve("ignite-config");
- Path logDir = pathRslvr.toolHomeDirectoryPath().resolve("ignite-log");
-
- fillNewConfigFile(newCfgFile, binDir, workDir, cfgDir, logDir);
-
- return newCfgFile;
- } catch (IOException e) {
- throw new IgniteCliException("Can't create configuration file in current directory: " + newCfgPath);
- }
- }
-
- /**
- * Fills config file with bin and work directories paths.
- *
- * @param f Config file.
- * @param binDir Path for bin dir.
- * @param workDir Path for work dir.
- */
- private void fillNewConfigFile(File f,
- @NotNull Path binDir,
- @NotNull Path workDir,
- @NotNull Path cfgDir,
- @NotNull Path logDir
- ) {
- try (FileWriter fileWriter = new FileWriter(f, UTF_8)) {
- Properties props = new Properties();
-
- props.setProperty("bin", binDir.toString());
- props.setProperty("work", workDir.toString());
- props.setProperty("config", cfgDir.toString());
- props.setProperty("log", logDir.toString());
- props.store(fileWriter, "");
- } catch (IOException e) {
- throw new IgniteCliException("Can't write to ignitecfg file");
- }
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/init/package-info.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/init/package-info.java
deleted file mode 100644
index 253e3afcfe..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/init/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Contains classes for Ignite init process.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.init;
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/MavenArtifactResolver.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/MavenArtifactResolver.java
deleted file mode 100644
index b41932300a..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/MavenArtifactResolver.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.module;
-
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.text.ParseException;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-import org.apache.ignite.internal.cli.deprecated.builtins.SystemPathResolver;
-import org.apache.ignite.internal.cli.deprecated.ui.ProgressBar;
-import org.apache.ignite.internal.logger.IgniteLogger;
-import org.apache.ignite.internal.logger.Loggers;
-import org.apache.ivy.Ivy;
-import org.apache.ivy.core.IvyContext;
-import org.apache.ivy.core.event.EventManager;
-import org.apache.ivy.core.event.download.EndArtifactDownloadEvent;
-import org.apache.ivy.core.event.resolve.EndResolveDependencyEvent;
-import org.apache.ivy.core.event.resolve.EndResolveEvent;
-import org.apache.ivy.core.event.retrieve.EndRetrieveArtifactEvent;
-import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
-import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
-import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivy.core.module.id.ModuleRevisionId;
-import org.apache.ivy.core.report.ResolveReport;
-import org.apache.ivy.core.resolve.ResolveOptions;
-import org.apache.ivy.core.retrieve.RetrieveOptions;
-import org.apache.ivy.core.retrieve.RetrieveReport;
-import org.apache.ivy.core.settings.IvySettings;
-import org.apache.ivy.plugins.resolver.ChainResolver;
-import org.apache.ivy.plugins.resolver.IBiblioResolver;
-import org.apache.ivy.util.AbstractMessageLogger;
-import org.apache.ivy.util.Message;
-import org.jline.terminal.Terminal;
-
-/**
- * Resolver of maven artifacts with Ivy.
- */
-@Singleton
-public class MavenArtifactResolver {
- /** Pattern for naming artifact files. **/
- private static final String FILE_ARTIFACT_PATTERN = "[artifact](-[classifier]).[revision].[ext]";
-
- /** Resolver of system paths. **/
- private final SystemPathResolver pathRslvr;
-
- /** System terminal instance, needed for receiving info about terminal settings. **/
- private final Terminal terminal;
-
- /** Console writer for output user messages. **/
- private PrintWriter out;
-
- /**
- * Creates a new resolver.
- *
- * @param pathRslvr Resolver of system paths like home directory and etc.
- * @param terminal User system terminal.
- */
- @Inject
- public MavenArtifactResolver(SystemPathResolver pathRslvr, Terminal terminal) {
- this.pathRslvr = pathRslvr;
- this.terminal = terminal;
- }
-
- /**
- * Sets writer for user messages.
- *
- * @param out PrintWriter
- */
- public void setOut(PrintWriter out) {
- this.out = out;
- }
-
- /**
- * Downloads and copies artifact and its dependencies to {mavenRoot}.
- *
- * @param mavenRoot Path where artifacts will be copied to.
- * @param grpId Maven group id of the artifact.
- * @param artifactId Maven artifact id of the artifact.
- * @param ver Maven version of the artifact.
- * @param customRepositories Urls with custom maven repositories to resolve artifact.
- * @return Result of resolving with files' paths of resolved artifact + dependencies.
- * @throws IOException if connection issues occurred during resolving or if r/w issues occurred during the retrieving of artifacts
- */
- public ResolveResult resolve(
- Path mavenRoot,
- String grpId,
- String artifactId,
- String ver,
- List<URL> customRepositories
- ) throws IOException {
- Ivy ivy = ivyInstance(customRepositories); // needed for init right output logger before any operations
-
- out.println("Installing " + String.join(":", grpId, artifactId, ver) + "...");
-
- try (ProgressBar bar = new ProgressBar(out, 100, terminal.getWidth())) {
- ivy.getEventManager().addIvyListener(event -> {
- if (event instanceof EndResolveEvent) {
- int cnt = ((EndResolveEvent) event).getReport().getArtifacts().size();
-
- bar.setMax(cnt * 3);
- } else if (event instanceof EndArtifactDownloadEvent
- || event instanceof EndResolveDependencyEvent
- || event instanceof EndRetrieveArtifactEvent) {
- bar.step();
- }
- });
-
- ModuleDescriptor md = rootModuleDescriptor(grpId, artifactId, ver);
-
- // Step 1: you always need to resolve before you can retrieve
- //
- ResolveOptions ro = new ResolveOptions();
- // this seems to have no impact, if you resolve by module descriptor
- //
- // (in contrast to resolve by ModuleRevisionId)
- ro.setTransitive(true);
- // if set to false, nothing will be downloaded
- ro.setDownload(true);
-
- try {
- // now resolve
- ResolveReport rr = ivy.resolve(md, ro);
-
- if (rr.hasError()) {
- throw new IgniteCliException(rr.getAllProblemMessages().toString());
- }
-
- // Step 2: retrieve
- ModuleDescriptor m = rr.getModuleDescriptor();
-
- RetrieveReport retrieveReport = ivy.retrieve(
- m.getModuleRevisionId(),
- new RetrieveOptions()
- // this is from the envelop module
- .setConfs(new String[]{"default"})
- .setDestArtifactPattern(
- mavenRoot.resolve("[artifact](-[classifier]).[revision].[ext]").toFile().getAbsolutePath())
- );
-
- return new ResolveResult(
- retrieveReport.getRetrievedFiles().stream().map(File::toPath).collect(Collectors.toList())
- );
- } catch (ParseException e) {
- throw new IOException(e);
- }
- }
- }
-
- /**
- * Gets artifact file name by artifactId and version.
- *
- * <p>Note: Current implementation doesn't support artifacts with classifiers or non-jar packaging.
- *
- * @param artifactId Maven artifact id.
- * @param ver Maven version
- * @return File name
- */
- public static String fileNameByArtifactPattern(
- String artifactId,
- String ver) {
- return FILE_ARTIFACT_PATTERN
- .replace("[artifact]", artifactId)
- .replace("(-[classifier])", "")
- .replace("[revision]", ver)
- .replace("[ext]", "jar");
- }
-
- /**
- * Prepares Ivy instance for artifact resolving.
- *
- * @param repositories Additional maven repositories
- * @return Ivy instance
- */
- private Ivy ivyInstance(List<URL> repositories) {
- File tmpDir;
-
- try {
- tmpDir = Files.createTempDirectory("ignite-installer-cache").toFile();
- } catch (IOException e) {
- throw new IgniteCliException("Can't create temp directory for ivy");
- }
-
- tmpDir.deleteOnExit();
-
- final EventManager evtMgr = new EventManager();
-
- IvySettings ivySettings = new IvySettings();
- ivySettings.setDefaultCache(tmpDir);
- ivySettings.setDefaultCacheArtifactPattern(FILE_ARTIFACT_PATTERN);
-
- ChainResolver chainRslvr = new ChainResolver();
- chainRslvr.setName("chainResolver");
- chainRslvr.setEventManager(evtMgr);
-
- for (URL repoUrl : repositories) {
- IBiblioResolver br = new IBiblioResolver();
- br.setEventManager(evtMgr);
- br.setM2compatible(true);
- br.setUsepoms(true);
- br.setRoot(repoUrl.toString());
- br.setName(repoUrl.getPath());
-
- chainRslvr.add(br);
- }
-
- // use the biblio resolver, if you consider resolving
- // POM declared dependencies
- IBiblioResolver br = new IBiblioResolver();
- br.setEventManager(evtMgr);
- br.setM2compatible(true);
- br.setUsepoms(true);
- br.setName("central");
-
- chainRslvr.add(br);
-
- IBiblioResolver locBr = new IBiblioResolver();
- locBr.setEventManager(evtMgr);
- locBr.setM2compatible(true);
- locBr.setUsepoms(true);
- locBr.setRoot("file:///" + pathRslvr.osHomeDirectoryPath().resolve(".m2").resolve("repository/"));
- locBr.setName("local");
-
- chainRslvr.add(locBr);
-
- ivySettings.addResolver(chainRslvr);
- ivySettings.setDefaultResolver(chainRslvr.getName());
-
- Ivy ivy = new Ivy();
-
- ivy.getLoggerEngine().setDefaultLogger(new IvyLogger());
-
- // needed for setting the message logger before logging info from loading settings
- IvyContext.getContext().setIvy(ivy);
-
- ivy.setSettings(ivySettings);
-
- ivy.bind();
-
- return ivy;
- }
-
- /**
- * Prepares Ivy module descriptor with target maven artifact as a dependency. Then descriptor can be used for further resolving the
- * artifact dependencies. Existence of this descriptor is Ivy's requirement.
- *
- * @param grpId Maven group id.
- * @param artifactId Maven artifact id.
- * @param ver Maven artifact version.
- * @return Prepared for resolving module descriptor.
- */
- private ModuleDescriptor rootModuleDescriptor(String grpId, String artifactId, String ver) {
- // 1st create an ivy module (this always(!) has a "default" configuration already)
- DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(
- // give it some related name (so it can be cached)
- ModuleRevisionId.newInstance(
- "org.apache.ignite",
- "installer-envelope",
- "working"
- )
- );
-
- // 2. add dependencies for what we are really looking for
- ModuleRevisionId ri = ModuleRevisionId.newInstance(
- grpId,
- artifactId,
- ver
- );
-
- // don't go transitive here, if you want the single artifact
- DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ri, false, true, true);
-
- // map to master to just get the code jar. See generated ivy module xmls from maven repo
- // on how configurations are mapped into ivy. Or check
- // e.g. http://lightguard-jp.blogspot.de/2009/04/ivy-configurations-when-pulling-from.html
- dd.addDependencyConfiguration("default", "master");
- dd.addDependencyConfiguration("default", "runtime");
- dd.addDependencyConfiguration("default", "compile");
-
- md.addDependency(dd);
-
- return md;
- }
-
- /**
- * Ivy logger for routing all ivy logs to general logging system of CLI.
- */
- private static class IvyLogger extends AbstractMessageLogger {
- /** Common logger. */
- private final IgniteLogger log = Loggers.forClass(IvyLogger.class);
-
- /** {@inheritDoc} */
- @Override
- protected void doProgress() {
- // no-op
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doEndProgress(String msg) {
- // no-op
- }
-
- /** {@inheritDoc} */
- @Override
- public void log(String msg, int level) {
- switch (level) {
- case Message.MSG_ERR:
- log.error(msg);
- break;
-
- case Message.MSG_WARN:
- log.warn(msg);
- break;
-
- case Message.MSG_INFO:
- log.info(msg);
- break;
-
- case Message.MSG_VERBOSE:
- log.debug(msg);
- break;
-
- case Message.MSG_DEBUG:
- log.trace(msg);
- break;
-
- default:
- break;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void rawlog(String msg, int level) {
- log(msg, level);
- }
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/MavenCoordinates.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/MavenCoordinates.java
deleted file mode 100644
index d3fd6cfc03..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/MavenCoordinates.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.module;
-
-
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-
-/**
- * Simple wrapper of maven artifact coordinates groupid:artifactd:version.
- */
-public class MavenCoordinates {
- /** Group id. */
- public final String grpId;
-
- /** Artifact id. */
- public final String artifactId;
-
- /** Artifact version. */
- public final String ver;
-
- /**
- * Creates maven coordinates.
- *
- * @param grpId Maven group id.
- * @param artifactId Maven artifact id.
- * @param ver Maven version.
- */
- public MavenCoordinates(String grpId, String artifactId, String ver) {
- this.grpId = grpId;
- this.artifactId = artifactId;
- this.ver = ver;
- }
-
- /**
- * Creates instance from raw string 'groupdId:artifactId:version'.
- *
- * @param mvnStr Raw maven artifactd string in format 'groupdId:artifactId:version'.
- * @return Maven coordinates instance.
- */
- public static MavenCoordinates of(String mvnStr) {
- String[] coords = mvnStr.split(":");
-
- if (coords.length == 4) {
- return new MavenCoordinates(coords[1], coords[2], coords[3]);
- } else {
- throw new IgniteCliException("Incorrect maven coordinates " + mvnStr);
- }
- }
-
- /**
- * Creates instance from raw string 'groupdId:artifactId'. Artifact version will be received separately.
- *
- * @param mvnStr Raw maven artifactd string in format 'groupdId:artifactId'.
- * @param ver Version of maven artifact.
- * @return Maven coordinates instance.
- */
- static MavenCoordinates of(String mvnStr, String ver) {
- return of(mvnStr + ":" + ver);
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ModuleManager.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ModuleManager.java
deleted file mode 100644
index 72f992f484..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ModuleManager.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.module;
-
-import com.typesafe.config.ConfigFactory;
-import com.typesafe.config.ConfigObject;
-import com.typesafe.config.ConfigValue;
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.jar.JarInputStream;
-import java.util.stream.Collectors;
-import org.apache.ignite.internal.cli.CliVersionInfo;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-import org.apache.ignite.internal.cli.deprecated.IgnitePaths;
-import picocli.CommandLine.Help.ColorScheme;
-
-/**
- * Ignite distributive module manager. The main responsibilities:
- * <ul>
- * <li>Add/remove standard Ignite server modules</li>
- * <li>Add/remove any external server modules from maven repositories.</li>
- * <li>Add/remove Ignite CLI modules.</li>
- * </ul>
- */
-@Singleton
-public class ModuleManager {
- /** Prefix to identify internal modules in builtin modules list. */
- public static final String INTERNAL_MODULE_PREFIX = "_";
-
- /** Jar manifest key to identify the CLI module jar. */
- public static final String CLI_MODULE_MANIFEST_HEADER = "Apache-Ignite-CLI-Module";
-
- /** Maven artifact resolver. */
- private final MavenArtifactResolver mavenArtifactRslvr;
-
- /** Current Ignite CLI version. */
- private final CliVersionInfo cliVerInfo;
-
- /** Storage of meta info of installed modules. */
- private final ModuleRegistry moduleRegistry;
-
- /** List of standard Ignite modules. */
- private final List<StandardModuleDefinition> modules;
-
- /** Print writer for output user messages. */
- private PrintWriter out;
-
- /** Color scheme to enrich user output. */
- private ColorScheme cs;
-
- /**
- * Creates module manager instance.
- *
- * @param mavenArtifactRslvr Maven artifact resolver.
- * @param cliVerInfo Current Ignite CLI version info.
- * @param moduleRegistry Module storage.
- */
- @Inject
- public ModuleManager(
- MavenArtifactResolver mavenArtifactRslvr, CliVersionInfo cliVerInfo,
- ModuleRegistry moduleRegistry) {
- modules = readBuiltinModules();
- this.mavenArtifactRslvr = mavenArtifactRslvr;
- this.cliVerInfo = cliVerInfo;
- this.moduleRegistry = moduleRegistry;
- }
-
- /**
- * Sets print writer for any user messages.
- *
- * @param out PrintWriter
- */
- public void setOut(PrintWriter out) {
- this.out = out;
-
- mavenArtifactRslvr.setOut(out);
- }
-
- /**
- * Sets color scheme for enrhiching user output.
- *
- * @param cs ColorScheme
- */
- public void setColorScheme(ColorScheme cs) {
- this.cs = cs;
- }
-
- /**
- * Installs the CLI/server module by name to according directories from {@link IgnitePaths}.
- *
- * @param name Module name can be either fully qualified maven artifact name (groupId:artifactId:version) or the name of the
- * standard Ignite module.
- * @param ignitePaths Ignite paths instance.
- * @param repositories Custom maven repositories to resolve module from.
- */
- public void addModule(String name, IgnitePaths ignitePaths, List<URL> repositories) {
- Path installPath = ignitePaths.libsDir();
-
- if (name.startsWith("mvn:")) {
- MavenCoordinates mavenCoordinates = MavenCoordinates.of(name);
-
- try {
- ResolveResult resolveRes = mavenArtifactRslvr.resolve(
- installPath,
- mavenCoordinates.grpId,
- mavenCoordinates.artifactId,
- mavenCoordinates.ver,
- repositories
- );
-
- String mvnName = String.join(":", mavenCoordinates.grpId,
- mavenCoordinates.artifactId, mavenCoordinates.ver);
-
- var isCliModule = isRootArtifactCliModule(
- mavenCoordinates.artifactId, mavenCoordinates.ver,
- resolveRes.artifacts());
-
- moduleRegistry.saveModule(new ModuleRegistry.ModuleDefinition(
- mvnName,
- (isCliModule) ? Collections.emptyList() : resolveRes.artifacts(),
- (isCliModule) ? resolveRes.artifacts() : Collections.emptyList(),
- ModuleRegistry.SourceType.Maven,
- name
- ));
-
- out.println();
- out.println("New Maven dependency successfully added. To remove, type: "
- + cs.commandText("ignite module remove ") + cs.parameterText(mvnName));
- } catch (IOException e) {
- throw new IgniteCliException("\nFailed to install " + name, e);
- }
- } else if (isBuiltinModuleName(name)) {
- StandardModuleDefinition moduleDesc = readBuiltinModules()
- .stream()
- .filter(m -> m.name.equals(name))
- .findFirst().get();
-
- List<ResolveResult> libsResolveResults = new ArrayList<>();
-
- for (String artifact : moduleDesc.artifacts) {
- MavenCoordinates mavenCoordinates = MavenCoordinates.of(artifact, cliVerInfo.ver);
-
- try {
- libsResolveResults.add(mavenArtifactRslvr.resolve(
- ignitePaths.libsDir(),
- mavenCoordinates.grpId,
- mavenCoordinates.artifactId,
- mavenCoordinates.ver,
- repositories
- ));
- } catch (IOException e) {
- throw new IgniteCliException("\nFailed to install an Ignite module: " + name, e);
- }
- }
-
- List<ResolveResult> cliResolvResults = new ArrayList<>();
-
- for (String artifact : moduleDesc.cliArtifacts) {
- MavenCoordinates mavenCoordinates = MavenCoordinates.of(artifact, cliVerInfo.ver);
-
- try {
- cliResolvResults.add(mavenArtifactRslvr.resolve(
- ignitePaths.cliLibsDir(),
- mavenCoordinates.grpId,
- mavenCoordinates.artifactId,
- mavenCoordinates.ver,
- repositories
- ));
- } catch (IOException e) {
- throw new IgniteCliException("\nFailed to install a module " + name, e);
- }
- }
-
- try {
- moduleRegistry.saveModule(new ModuleRegistry.ModuleDefinition(
- name,
- libsResolveResults.stream().flatMap(r -> r.artifacts().stream()).collect(Collectors.toList()),
- cliResolvResults.stream().flatMap(r -> r.artifacts().stream()).collect(Collectors.toList()),
- ModuleRegistry.SourceType.Standard,
- name
- ));
- } catch (IOException e) {
- throw new IgniteCliException("Error during saving the installed module info");
- }
-
- } else {
- throw new IgniteCliException(
- "Module coordinates for non-standard modules must be started with mvn:|file://");
- }
- }
-
- /**
- * Removes module by name.
- *
- * @param name Module name can be either the name of standard Ignite module or the fully qualified maven artifact
- * 'groupId:artifactId:version'.
- * @return true if module was removed, false otherwise.
- */
- public boolean removeModule(String name) {
- try {
- return moduleRegistry.removeModule(name);
- } catch (IOException e) {
- throw new IgniteCliException(
- "Can't remove module " + name, e);
- }
- }
-
- /**
- * Returns builtin Ignite modules list. Builtin modules list packaged with CLI tool and so, depends only on its' version.
- *
- * @return Builtin modules list.
- */
- public List<StandardModuleDefinition> builtinModules() {
- return Collections.unmodifiableList(modules);
- }
-
- /**
- * Checks if root artifact contains Jar manifest key, which marks it as CLI extension.
- *
- * @param artifactId Maven artifact id.
- * @param ver Maven root artifact version.
- * @param artifacts Paths for all dependencies' files of the artifact.
- * @return true if the artifact has CLI mark, false otherwise.
- * @throws IOException If can't read artifact manifest.
- */
- private boolean isRootArtifactCliModule(String artifactId, String ver, List<Path> artifacts) throws IOException {
- var rootJarArtifactOpt = artifacts.stream()
- .filter(p -> MavenArtifactResolver.fileNameByArtifactPattern(artifactId, ver).equals(p.getFileName().toString()))
- .findFirst();
-
- if (rootJarArtifactOpt.isPresent()) {
- try (var input = new FileInputStream(rootJarArtifactOpt.get().toFile())) {
- var jarStream = new JarInputStream(input);
- var manifest = jarStream.getManifest();
-
- return "true".equals(manifest.getMainAttributes().getValue(CLI_MODULE_MANIFEST_HEADER));
- }
- } else {
- return false;
- }
- }
-
- /**
- * Checks if the module is a builtin Ignite module.
- *
- * @param name Module name.
- * @return true if the module is a builtin Ignite module.
- */
- private boolean isBuiltinModuleName(String name) {
- return readBuiltinModules().stream().anyMatch(m -> m.name.equals(name));
- }
-
- /**
- * Reads builtin modules from builtin modules registry.
- *
- * @return List of builtin modules.
- */
- private static List<StandardModuleDefinition> readBuiltinModules() {
- var cfg = ConfigFactory.load("builtin_modules.conf").getObject("modules");
-
- List<StandardModuleDefinition> modules = new ArrayList<>();
-
- for (Map.Entry<String, ConfigValue> entry : cfg.entrySet()) {
- ConfigObject cfgObj = (ConfigObject) entry.getValue();
-
- modules.add(new StandardModuleDefinition(
- entry.getKey(),
- cfgObj.toConfig().getString("description"),
- cfgObj.toConfig().getStringList("artifacts"),
- cfgObj.toConfig().getStringList("cli-artifacts")
- ));
- }
-
- return modules;
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ModuleRegistry.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ModuleRegistry.java
deleted file mode 100644
index e2f46eed6b..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ModuleRegistry.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.module;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonGetter;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.apache.ignite.internal.cli.deprecated.CliPathsConfigLoader;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-import org.apache.ignite.internal.tostring.IgniteToStringInclude;
-import org.apache.ignite.internal.tostring.S;
-
-/**
- * The registry of installed CLI or Ignite server modules. Module from the the registry's point of view is a pair of (name -> [artifacts,
- * cliArtifacts]). Where:
- * <ul>
- * <li>artifacts - is a list of Ignite server node artifacts, which will be used in classpath of any server node.</li>
- * <li>cliArtifacts - is a list of Ignite CLI artifacts, which will be used to lookup CLI extensions.</li>
- * </ul>
- * Registry persisted on a disk as a JSON file.
- */
-@Singleton
-public class ModuleRegistry {
- /** Loader of CLI config with Ignite distributive paths. */
- private final CliPathsConfigLoader cliPathsCfgLdr;
-
- /**
- * Creates module registry instance.
- *
- * @param cliPathsCfgLdr Loader of CLI config with Ignite ditributive paths.
- */
- @Inject
- public ModuleRegistry(CliPathsConfigLoader cliPathsCfgLdr) {
- this.cliPathsCfgLdr = cliPathsCfgLdr;
- }
-
- /**
- * Returns path of registry file.
- *
- * @return Path of registry file.
- */
- private Path moduleFile() {
- return cliPathsCfgLdr.loadIgnitePathsOrThrowError().installedModulesFile();
- }
-
- /**
- * Saves module to module registry.
- *
- * @param moduleDefinition Module definition.
- * @throws IOException If can't save the registry file.
- */
- //TODO: IGNITE-14021 write-to-tmp->move approach should be used to prevent file corruption on accidental exit
- public void saveModule(ModuleDefinition moduleDefinition) throws IOException {
- ModuleDefinitionsList moduleDefinitionsList = listInstalled();
-
- moduleDefinitionsList.modules.add(moduleDefinition);
-
- ObjectMapper objMapper = new ObjectMapper();
-
- objMapper.writeValue(moduleFile().toFile(), moduleDefinitionsList);
- }
-
- /**
- * Removes module from the registry of installed modules. Note: artifacts' files will not be removed. This action only remove module and
- * its dependencies from current classpaths as a result.
- *
- * @param name Module name to remove.
- * @return true if module was removed, false otherwise.
- * @throws IOException If can't save updated registry file.
- */
- //TODO: iIGNITE-14021 write-to-tmp->move approach should be used to prevent file corruption on accidental exit
- public boolean removeModule(String name) throws IOException {
- ModuleDefinitionsList moduleDefinitionsList = listInstalled();
-
- boolean rmv = moduleDefinitionsList.modules.removeIf(m -> m.name.equals(name));
-
- ObjectMapper objMapper = new ObjectMapper();
-
- objMapper.writeValue(moduleFile().toFile(), moduleDefinitionsList);
-
- return rmv;
- }
-
- /**
- * Returns definitions of installed modules.
- *
- * @return Definitions of installed modules.
- */
- public ModuleDefinitionsList listInstalled() {
- var moduleFileAvailable =
- cliPathsCfgLdr.loadIgnitePathsConfig()
- .map(p -> p.installedModulesFile().toFile().exists())
- .orElse(false);
-
- if (!moduleFileAvailable) {
- return new ModuleDefinitionsList(new ArrayList<>());
- } else {
- ObjectMapper objMapper = new ObjectMapper();
-
- try {
- return objMapper.readValue(
- moduleFile().toFile(),
- ModuleDefinitionsList.class);
- } catch (IOException e) {
- throw new IgniteCliException("Can't read lsit of installed modules because of IO error", e);
- }
- }
- }
-
- /**
- * Simple wrapper for a list of modules' definitions. Wrap it in the form suitable for JSON serialization.
- */
- public static class ModuleDefinitionsList {
- /** Modules list. */
- public final List<ModuleDefinition> modules;
-
- /**
- * Creates modules definitions list.
- *
- * @param modules List of definitions to wrap.
- */
- @JsonCreator
- public ModuleDefinitionsList(
- @JsonProperty("modules") List<ModuleDefinition> modules) {
- this.modules = modules;
- }
- }
-
- /**
- * Definition of Ignite module. Every module can consist of server, CLI, or both artifacts' lists.
- */
- public static class ModuleDefinition {
- /** Module's name. */
- @IgniteToStringInclude
- public final String name;
-
- /** Module's server artifacts. */
- @IgniteToStringInclude
- public final List<Path> artifacts;
-
- /** Module's CLI artifacts. */
- @IgniteToStringInclude
- public final List<Path> cliArtifacts;
-
- /** Type of module source. */
- @IgniteToStringInclude
- public final SourceType type;
-
- /**
- * It can be an url, file path, or any other source identificator, depending on the source type.
- */
- public final String src;
-
- /**
- * Creates module definition.
- *
- * @param name Module name.
- * @param artifacts Module server artifacts' paths.
- * @param cliArtifacts Module CLI artifacts' paths.
- * @param type Source type of the module.
- * @param src Source string (file path, url, maven coordinates and etc.).
- */
- @JsonCreator
- public ModuleDefinition(
- @JsonProperty("name") String name,
- @JsonProperty("artifacts") List<Path> artifacts,
- @JsonProperty("cliArtifacts") List<Path> cliArtifacts,
- @JsonProperty("type") SourceType type,
- @JsonProperty("source") String src) {
- this.name = name;
- this.artifacts = artifacts;
- this.cliArtifacts = cliArtifacts;
- this.type = type;
- this.src = src;
- }
-
- /**
- * Returns server artifacts' paths.
- *
- * @return Server artifacts' paths.
- */
- @JsonGetter("artifacts")
- public List<String> artifacts() {
- return artifacts.stream().map(a -> a.toAbsolutePath().toString()).collect(Collectors.toList());
- }
-
- /**
- * Returns CLI artifacts paths.
- *
- * @return CLI artifacts paths.
- */
- @JsonGetter("cliArtifacts")
- public List<String> cliArtifacts() {
- return cliArtifacts.stream().map(a -> a.toAbsolutePath().toString()).collect(Collectors.toList());
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- return S.toString(ModuleDefinition.class, this);
- }
- }
-
- /**
- * Type of module source.
- */
- public enum SourceType {
- /** Module is an maven artifact. */
- Maven,
- /** Module is an builtin module. */
- Standard
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ResolveResult.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ResolveResult.java
deleted file mode 100644
index d4b4001fb5..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/ResolveResult.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.module;
-
-import java.nio.file.Path;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Result of resolving maven artifact dependencies.
- */
-public class ResolveResult {
- /** List of resolver artifacts' paths. */
- private final List<Path> artifacts;
-
- /**
- * Creates result of artifacts resolving.
- *
- * @param artifacts List of artifacts paths.
- */
- public ResolveResult(List<Path> artifacts) {
- this.artifacts = artifacts;
- }
-
- /**
- * Returns list of artifacts' paths.
- *
- * @return List of artifacts' paths.
- */
- public List<Path> artifacts() {
- return Collections.unmodifiableList(artifacts);
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/StandardModuleDefinition.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/StandardModuleDefinition.java
deleted file mode 100644
index 302a344504..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/StandardModuleDefinition.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.module;
-
-import java.util.Collections;
-import java.util.List;
-import org.apache.ignite.internal.tostring.IgniteToStringInclude;
-import org.apache.ignite.internal.tostring.S;
-
-/**
- * Definition of Ignite standard module. Every module has two artifacts' lists - one for server modules and one for CLI tool extensions, if
- * any.
- */
-public class StandardModuleDefinition {
- /** Module name. **/
- @IgniteToStringInclude
- public final String name;
-
- /** Module description. */
- @IgniteToStringInclude
- public final String desc;
-
- /** List of server artifacts. */
- @IgniteToStringInclude
- public final List<String> artifacts;
-
- /** List of CLI tool artifacts. */
- @IgniteToStringInclude
- public final List<String> cliArtifacts;
-
- /**
- * Creates definition for standard Ignite module.
- *
- * @param name Module name.
- * @param desc Module description.
- * @param artifacts Server artifacts.
- * @param cliArtifacts CLI tool artifacts.
- */
- public StandardModuleDefinition(String name, String desc, List<String> artifacts, List<String> cliArtifacts) {
- this.name = name;
- this.desc = desc;
- this.artifacts = Collections.unmodifiableList(artifacts);
- this.cliArtifacts = Collections.unmodifiableList(cliArtifacts);
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- return S.toString(StandardModuleDefinition.class, this);
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/package-info.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/package-info.java
deleted file mode 100644
index 868ef5decb..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/module/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Contains classes for Ignite module management.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.module;
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/node/NodeManager.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/node/NodeManager.java
deleted file mode 100644
index f30c29be5e..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/node/NodeManager.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.node;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.time.Duration;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.locks.LockSupport;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-import org.apache.ignite.internal.cli.deprecated.builtins.module.ModuleRegistry;
-import org.apache.ignite.internal.cli.deprecated.ui.Spinner;
-
-/**
- * Manager of local Ignite nodes.
- */
-@Singleton
-public class NodeManager {
- /** Entry point of core Ignite artifact for running new node. */
- private static final String MAIN_CLASS = "org.apache.ignite.app.IgniteCliRunner";
-
- /** Timeout for successful node start. */
- private static final Duration NODE_START_TIMEOUT = Duration.ofSeconds(30);
-
- /** Interval for polling node logs to identify successful start. */
- private static final Duration LOG_FILE_POLL_INTERVAL = Duration.ofMillis(500);
-
- /** Module registry. **/
- private final ModuleRegistry moduleRegistry;
-
- /**
- * Creates node manager.
- *
- * @param moduleRegistry Module registry.
- */
- @Inject
- public NodeManager(ModuleRegistry moduleRegistry) {
- this.moduleRegistry = moduleRegistry;
- }
-
- /**
- * Starts new Ignite node and check if it was successfully started. It has very naive implementation of successful run check - just
- * waiting for appropriate message in the node logs.
- *
- * @param nodeName Node name.
- * @param baseWorkDir Root directory to store nodes data.
- * @param logDir Path to log directory for receiving node state.
- * @param pidsDir Path to directory where pid files of running nodes will be stored.
- * @param srvCfgPath Path to configuration file for Ignite node - mutually exclusive with {@code srvCfgStr}.
- * @param srvCfgStr Configuration for Ignite node - mutually exclusive with {@code srvCfgPath}.
- * @param javaLogProps Path to logging properties file.
- * @param out PrintWriter for user messages.
- * @return Information about successfully started node
- */
- public RunningNode start(
- String nodeName,
- Path baseWorkDir,
- Path logDir,
- Path pidsDir,
- Path srvCfgPath,
- String srvCfgStr,
- Path javaLogProps,
- PrintWriter out
- ) {
- if (getRunningNodes(logDir, pidsDir).stream().anyMatch(n -> n.name.equals(nodeName))) {
- throw new IgniteCliException("Node with nodeName " + nodeName + " is already exist");
- }
-
- try {
- Path workDir = workDir(baseWorkDir, nodeName);
-
- // If working directory does not exist then it should be created,
- // otherwise, just start a new node with existing data.
- if (!Files.exists(workDir)) {
- Files.createDirectory(workDir);
- }
-
- Path logFile = logFile(logDir, nodeName);
-
- if (Files.exists(logFile)) {
- Files.delete(logFile);
- }
-
- Files.createFile(logFile);
-
- var cmdArgs = new ArrayList<String>();
-
- cmdArgs.add("java");
-
- addAddOpens(cmdArgs, "java.base/java.lang=ALL-UNNAMED");
- addAddOpens(cmdArgs, "java.base/java.lang.invoke=ALL-UNNAMED");
- addAddOpens(cmdArgs, "java.base/java.lang.reflect=ALL-UNNAMED");
- addAddOpens(cmdArgs, "java.base/java.io=ALL-UNNAMED");
- addAddOpens(cmdArgs, "java.base/java.nio=ALL-UNNAMED");
- addAddOpens(cmdArgs, "java.base/java.math=ALL-UNNAMED");
- addAddOpens(cmdArgs, "java.base/java.util=ALL-UNNAMED");
- addAddOpens(cmdArgs, "java.base/jdk.internal.misc=ALL-UNNAMED");
-
- cmdArgs.add("-Dio.netty.tryReflectionSetAccessible=true");
-
- if (javaLogProps != null) {
- cmdArgs.add("-Djava.util.logging.config.file=" + javaLogProps.toAbsolutePath());
- }
-
- cmdArgs.add("-cp");
- cmdArgs.add(classpath());
- cmdArgs.add(MAIN_CLASS);
-
- if (srvCfgPath != null) {
- cmdArgs.add("--config-path");
- cmdArgs.add(srvCfgPath.toAbsolutePath().toString());
- } else if (srvCfgStr != null) {
- cmdArgs.add("--config-string");
- cmdArgs.add(escapeQuotes(srvCfgStr));
- }
-
- cmdArgs.add("--work-dir");
- cmdArgs.add(workDir.toAbsolutePath().toString());
-
- cmdArgs.add("--node-name");
- cmdArgs.add(nodeName);
-
- ProcessBuilder pb = new ProcessBuilder(cmdArgs)
- .redirectError(logFile.toFile())
- .redirectOutput(logFile.toFile());
-
- Process p = pb.start();
-
- try (var spinner = new Spinner(out, "Starting a new Ignite node")) {
- if (!waitForStart("REST protocol started successfully", logFile, p, NODE_START_TIMEOUT, spinner)) {
- p.destroyForcibly();
-
- throw new IgniteCliException("Node wasn't started during timeout period "
- + NODE_START_TIMEOUT.toMillis() + "ms. Read logs for details: " + logFile);
- }
- } catch (InterruptedException | IOException e) {
- throw new IgniteCliException("Waiting for node start was failed", e);
- }
-
- createPidFile(nodeName, p.pid(), pidsDir);
-
- return new RunningNode(p.pid(), nodeName, logFile);
- } catch (IOException e) {
- throw new IgniteCliException("Can't load classpath", e);
- }
- }
-
- private void addAddOpens(ArrayList<String> cmdArgs, String addOpens) {
- cmdArgs.add("--add-opens");
- cmdArgs.add(addOpens);
- }
-
- /**
- * Waits for node start by checking node logs in cycle.
- *
- * @param started Mark string that node was started.
- * @param file Node's log file
- * @param p External Ignite process.
- * @param timeout Timeout for waiting
- * @return true if node was successfully started, false otherwise.
- * @throws IOException If can't read the log file
- * @throws InterruptedException If waiting was interrupted.
- */
- private static boolean waitForStart(
- String started,
- Path file,
- Process p,
- Duration timeout,
- Spinner spinner
- ) throws IOException, InterruptedException {
- var start = System.currentTimeMillis();
-
- while ((System.currentTimeMillis() - start) < timeout.toMillis() && p.isAlive()) {
- spinner.spin();
- LockSupport.parkNanos(LOG_FILE_POLL_INTERVAL.toNanos());
-
- var content = Files.readString(file);
-
- if (content.contains(started)) {
- return true;
- }
- }
-
- if (!p.isAlive()) {
- throw new IgniteCliException("Can't start the node. Read logs for details: " + file);
- }
-
- return false;
- }
-
- /**
- * Returns actual classpath according to current installed modules.
- *
- * @return Actual classpath according to current installed modules.
- * @throws IOException If couldn't read the module registry file.
- */
- public String classpath() throws IOException {
- return moduleRegistry.listInstalled().modules.stream()
- .flatMap(m -> m.artifacts.stream())
- .map(m -> m.toAbsolutePath().toString())
- .collect(Collectors.joining(System.getProperty("path.separator")));
- }
-
- /**
- * Returns actual classpath items list according to current installed modules.
- *
- * @return Actual classpath items list according to current installed modules.
- * @throws IOException If couldn't read the module registry file.
- */
- public List<String> classpathItems() throws IOException {
- return moduleRegistry.listInstalled().modules.stream()
- .flatMap(m -> m.artifacts.stream())
- .map(m -> m.getFileName().toString())
- .collect(Collectors.toList());
- }
-
- /**
- * Creates pid file for Ignite node.
- *
- * @param nodeName Node name.
- * @param pid Pid
- * @param pidsDir Dir for storing pid files.
- */
- public void createPidFile(String nodeName, long pid, Path pidsDir) {
- if (!Files.exists(pidsDir)) {
- if (!pidsDir.toFile().mkdirs()) {
- throw new IgniteCliException("Can't create directory for storing the process pids: " + pidsDir);
- }
- }
-
- Path pidPath = pidsDir.resolve(nodeName + "_" + System.currentTimeMillis() + ".pid");
-
- try (FileWriter fileWriter = new FileWriter(pidPath.toFile(), UTF_8)) {
- fileWriter.write(String.valueOf(pid));
- } catch (IOException e) {
- throw new IgniteCliException("Can't write pid file " + pidPath);
- }
- }
-
- /**
- * Returns list of running nodes.
- *
- * @param logDir Ignite installation work dir.
- * @param pidsDir Dir with nodes pids.
- * @return List of running nodes.
- */
- public List<RunningNode> getRunningNodes(Path logDir, Path pidsDir) {
- if (Files.exists(pidsDir)) {
- try (Stream<Path> files = Files.find(pidsDir, 1, (f, attrs) -> f.getFileName().toString().endsWith(".pid"))) {
- return files
- .map(f -> {
- long pid;
-
- try {
- pid = Long.parseLong(Files.readAllLines(f).get(0));
-
- if (!ProcessHandle.of(pid).map(ProcessHandle::isAlive).orElse(false)) {
- return Optional.<RunningNode>empty();
- }
- } catch (IOException e) {
- throw new IgniteCliException("Can't parse pid file " + f);
- }
-
- String filename = f.getFileName().toString();
-
- if (filename.lastIndexOf('_') == -1) {
- return Optional.<RunningNode>empty();
- } else {
- String nodeName = filename.substring(0, filename.lastIndexOf('_'));
-
- return Optional.of(new RunningNode(pid, nodeName, logFile(logDir, nodeName)));
- }
-
- })
- .filter(Optional::isPresent)
- .map(Optional::get).collect(Collectors.toList());
- } catch (IOException e) {
- throw new IgniteCliException("Can't find directory with pid files for running nodes " + pidsDir);
- }
- } else {
- return Collections.emptyList();
- }
- }
-
- /**
- * Stops the node by name and waits for success.
- *
- * @param nodeName Node name.
- * @param pidsDir Dir with running nodes pids.
- * @return true if stopped, false otherwise.
- */
- public boolean stopWait(String nodeName, Path pidsDir) {
- if (Files.exists(pidsDir)) {
- try {
- List<Path> files = Files.find(pidsDir, 1,
- (f, attrs) ->
- f.getFileName().toString().startsWith(nodeName + "_")).collect(Collectors.toList());
-
- if (!files.isEmpty()) {
- return files.stream().map(f -> {
- try {
- long pid = Long.parseLong(Files.readAllLines(f).get(0));
-
- boolean res = stopWait(pid);
-
- Files.delete(f);
-
- return res;
- } catch (IOException e) {
- throw new IgniteCliException("Can't read pid file " + f);
- }
- }).reduce((a, b) -> a && b).orElse(false);
- } else {
- throw new IgniteCliException("Can't find node with name " + nodeName);
- }
- } catch (IOException e) {
- throw new IgniteCliException("Can't open directory with pid files " + pidsDir);
- }
- } else {
- return false;
- }
- }
-
- /**
- * Stops the process and waits for success.
- *
- * @param pid Pid of process to stop.
- * @return true if process was stopped, false otherwise.
- */
- private boolean stopWait(long pid) {
- return ProcessHandle
- .of(pid)
- .map(ProcessHandle::destroy)
- .orElse(false);
- }
-
- /**
- * Returns path of node log file.
- *
- * @param logDir Ignite log dir.
- * @param nodeName Node name.
- * @return Path of node log file.
- */
- private static Path logFile(Path logDir, String nodeName) {
- return logDir.resolve(nodeName + ".log");
- }
-
- /**
- * Returns a path to the node work directory.
- *
- * @param baseWorkDir Base ignite working directory.
- * @param nodeName Node name.
- * @return Path to node work directory.
- */
- private static Path workDir(Path baseWorkDir, String nodeName) {
- return baseWorkDir.resolve(nodeName);
- }
-
- /**
- * Adds backslash character before double quotes to keep them when passing as a command line argument.
- *
- * @param str String to escape.
- * @return Escaped string.
- */
- private static String escapeQuotes(String str) {
- StringWriter out = new StringWriter();
- for (int i = 0; i < str.length(); i++) {
- char c = str.charAt(i);
- if (c == '"') {
- out.write('\\');
- }
- out.write(c);
- }
- return out.toString();
- }
-
- /**
- * Simple structure with information about running node.
- */
- public static class RunningNode {
-
- /** Pid. */
- public final long pid;
-
- /** Consistent id. */
- public final String name;
-
- /** Path to log file. */
- public final Path logFile;
-
- /**
- * Creates info about running node.
- *
- * @param pid Pid.
- * @param name Consistent id.
- * @param logFile Log file.
- */
- public RunningNode(long pid, String name, Path logFile) {
- this.pid = pid;
- this.name = name;
- this.logFile = logFile;
- }
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/node/package-info.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/node/package-info.java
deleted file mode 100644
index ec12f55dc9..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/node/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Contains classes for Ignite node management.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.node;
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/package-info.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/package-info.java
deleted file mode 100644
index e15e17c1c1..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/builtins/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Contains classes and packages for builtin commands of Ignite CLI.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins;
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/BootstrapIgniteCommandSpec.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/BootstrapIgniteCommandSpec.java
deleted file mode 100644
index d13960705e..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/BootstrapIgniteCommandSpec.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.spec;
-
-import jakarta.inject.Inject;
-import java.net.URL;
-import java.util.concurrent.Callable;
-import org.apache.ignite.internal.cli.commands.BaseCommand;
-import org.apache.ignite.internal.cli.deprecated.builtins.init.InitIgniteCommand;
-import picocli.CommandLine;
-
-/**
- * Command for install Ignite distributive to start new nodes on the current machine.
- */
-@CommandLine.Command(name = "bootstrap", description = "Installs Ignite core modules locally.")
-public class BootstrapIgniteCommandSpec extends BaseCommand implements Callable<Integer> {
- /** Init command implementation. */
- @Inject
- private InitIgniteCommand cmd;
-
- /** Option for custom maven repository to download Ignite core. */
- @CommandLine.Option(
- names = "--repo",
- description = "Additional Maven repository URL"
- )
- private URL[] urls;
-
- /** {@inheritDoc} */
- @Override
- public Integer call() {
- cmd.init(urls, spec.commandLine().getOut(), spec.commandLine().getColorScheme());
-
- return 0;
- }
-}
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/NodeCommandSpec.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/NodeCommandSpec.java
deleted file mode 100644
index eb2933953b..0000000000
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/deprecated/spec/NodeCommandSpec.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.spec;
-
-import static org.apache.ignite.internal.cli.core.style.AnsiStringSupport.ansi;
-
-import com.jakewharton.fliptables.FlipTable;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import com.typesafe.config.ConfigRenderOptions;
-import jakarta.inject.Inject;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.stream.Collectors;
-import org.apache.ignite.internal.cli.commands.BaseCommand;
-import org.apache.ignite.internal.cli.core.converters.NetworkAddressConverter;
-import org.apache.ignite.internal.cli.core.style.element.UiElements;
-import org.apache.ignite.internal.cli.deprecated.CliPathsConfigLoader;
-import org.apache.ignite.internal.cli.deprecated.IgniteCliException;
-import org.apache.ignite.internal.cli.deprecated.IgnitePaths;
-import org.apache.ignite.internal.cli.deprecated.builtins.node.NodeManager;
-import org.apache.ignite.network.NetworkAddress;
-import picocli.CommandLine.ArgGroup;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Help.Ansi;
-import picocli.CommandLine.Help.ColorScheme;
-import picocli.CommandLine.Option;
-import picocli.CommandLine.Parameters;
-
-/**
- * Commands for start/stop/list Ignite nodes on the current machine.
- */
-@Command(
- name = "node",
- description = "Manages locally running Ignite nodes",
- subcommands = {
- NodeCommandSpec.StartNodeCommandSpec.class,
- NodeCommandSpec.StopNodeCommandSpec.class,
- NodeCommandSpec.NodesClasspathCommandSpec.class,
- NodeCommandSpec.ListNodesCommandSpec.class
- }
-)
-public class NodeCommandSpec {
- /**
- * Starts Ignite node command.
- */
- @Command(name = "start", description = "Starts an Ignite node locally")
- public static class StartNodeCommandSpec extends BaseCommand implements Callable<Integer> {
- /** Consistent id, which will be used by new node. */
- @Parameters(paramLabel = "name", description = "Name of the new node")
- public String nodeName;
-
- /** Loader for Ignite distributive paths. */
- @Inject
- private CliPathsConfigLoader cliPathsCfgLdr;
-
- /** Node manager. */
- @Inject
- private NodeManager nodeMgr;
-
- @ArgGroup(exclusive = false)
- private ConfigOptions configOptions;
-
- private static class ConfigOptions {
- @ArgGroup(exclusive = false)
- private ConfigArguments args;
-
- /** Path to node config. */
- @Option(names = {"-c", "--config"}, description = "Configuration file to start the node with")
- private Path configPath;
- }
-
- private static class ConfigArguments {
- @Option(names = {"-p", "--port"}, description = "Node port")
- private Integer port;
-
- @Option(names = {"-r", "--rest-port"}, description = "REST port")
- private Integer restPort;
-
- @Option(names = {"-j", "--join"}, description = "Seed nodes", split = ",", converter = NetworkAddressConverter.class)
- private NetworkAddress[] seedNodes;
- }
-
- /** {@inheritDoc} */
- @Override
- public Integer call() {
- IgnitePaths ignitePaths = cliPathsCfgLdr.loadIgnitePathsOrThrowError();
-
- PrintWriter out = spec.commandLine().getOut();
- ColorScheme cs = spec.commandLine().getColorScheme();
-
- NodeManager.RunningNode node = nodeMgr.start(
- nodeName,
- ignitePaths.nodesBaseWorkDir(),
- ignitePaths.logDir,
- ignitePaths.cliPidsDir(),
- getConfigPath(),
- getConfigStr(),
- ignitePaths.serverJavaUtilLoggingPros(),
- out);
-
- out.println(ansi(UiElements.done().represent()));
-
- out.println(String.format("[name: %s, pid: %d]", node.name, node.pid));
-
- out.println();
- out.println("Node is successfully started. To stop, type "
- + cs.commandText("ignite node stop ") + cs.parameterText(node.name));
-
- return 0;
- }
-
- private Path getConfigPath() {
- return configOptions != null ? configOptions.configPath : null;
- }
-
- private String getConfigStr() {
- if (configOptions == null || configOptions.args == null) {
- return null;
- }
- Map<String, Object> configMap = new HashMap<>();
- if (configOptions.args.port != null) {
- configMap.put("network.port", configOptions.args.port);
- }
- if (configOptions.args.seedNodes != null) {
- List<String> strings = Arrays.stream(configOptions.args.seedNodes)
- .map(NetworkAddress::toString)
- .collect(Collectors.toList());
- configMap.put("network.nodeFinder.netClusterNodes", strings);
- }
- if (configOptions.args.restPort != null) {
- configMap.put("rest.port", configOptions.args.restPort);
- }
- Config config = ConfigFactory.parseMap(configMap);
- if (configOptions.configPath != null) {
- Config fallback = ConfigFactory.parseFile(configOptions.configPath.toFile());
- config = config.withFallback(fallback).resolve();
- }
- return config.root().render(ConfigRenderOptions.concise().setJson(false));
- }
- }
-
- /**
- * Command for stopping Ignite node on the current machine.
- */
- @Command(name = "stop", description = "Stops a locally running Ignite node.")
- public static class StopNodeCommandSpec extends BaseCommand implements Callable<Integer> {
- /** Node manager. */
- @Inject
- private NodeManager nodeMgr;
-
- /** Loader for Ignite distributive paths. */
- @Inject
- private CliPathsConfigLoader cliPathsCfgLdr;
-
- /** Consistent ids of nodes to stop. */
- @Parameters(
- arity = "1..*",
- paramLabel = "consistent-ids",
- description = "Consistent IDs of the nodes to stop (space separated list)"
- )
- private List<String> consistentIds;
-
- /** {@inheritDoc} */
- @Override
- public Integer call() {
- IgnitePaths ignitePaths = cliPathsCfgLdr.loadIgnitePathsOrThrowError();
-
- PrintWriter out = spec.commandLine().getOut();
- ColorScheme cs = spec.commandLine().getColorScheme();
-
- consistentIds.forEach(p -> {
- out.println("Stopping locally running node with consistent ID " + cs.parameterText(p) + "...");
-
- if (nodeMgr.stopWait(p, ignitePaths.cliPidsDir())) {
- out.println(cs.text("@|bold,green Done|@"));
- } else {
- out.println(cs.text("@|bold,red Failed|@"));
- }
- });
- return 0;
- }
- }
-
- /**
- * Command for listing the running nodes.
- */
- @Command(name = "list", description = "Shows the list of currently running local Ignite nodes.")
- public static class ListNodesCommandSpec extends BaseCommand implements Callable<Integer> {
- /** Node manager. */
- @Inject
- private NodeManager nodeMgr;
-
- /** Loader for Ignite distributive paths. */
- @Inject
- private CliPathsConfigLoader cliPathsCfgLdr;
-
- /** {@inheritDoc} */
- @Override
- public Integer call() {
- IgnitePaths paths = cliPathsCfgLdr.loadIgnitePathsOrThrowError();
-
- List<NodeManager.RunningNode> nodes = nodeMgr.getRunningNodes(paths.logDir, paths.cliPidsDir());
-
- PrintWriter out = spec.commandLine().getOut();
- ColorScheme cs = spec.commandLine().getColorScheme();
-
- if (nodes.isEmpty()) {
- out.println("There are no locally running nodes");
- out.println("use the " + cs.commandText("ignite node start")
- + " command to start a new node");
- } else {
- String[] headers = {"consistent id", "pid", "log file"};
- String[][] content = nodes.stream().map(
- node -> new String[]{
- node.name,
- String.valueOf(node.pid),
- String.valueOf(node.logFile)
- }
- ).toArray(String[][]::new);
-
- out.println(FlipTable.of(headers, content));
-
- out.println("Number of running nodes: " + cs.text("@|bold " + nodes.size() + "|@"));
- }
- return 0;
- }
- }
-
- /**
- * Command for reading the current classpath of Ignite nodes.
- */
- @Command(name = "classpath", description = "Shows the current classpath used by the Ignite nodes.")
- public static class NodesClasspathCommandSpec extends BaseCommand implements Callable<Integer> {
- /** Node manager. */
- @Inject
- private NodeManager nodeMgr;
-
- /** {@inheritDoc} */
- @Override
- public Integer call() {
- try {
- List<String> items = nodeMgr.classpathItems();
-
- PrintWriter out = spec.commandLine().getOut();
-
- out.println(Ansi.AUTO.string("@|bold Current Ignite node classpath:|@"));
-
- for (String item : items) {
- out.println(" " + item);
- }
- } catch (IOException e) {
- throw new IgniteCliException("Can't get current classpath", e);
- }
- return 0;
- }
- }
-}
diff --git a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/IgniteCliInterfaceTest.java b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/IgniteCliInterfaceTest.java
index 76cec8d5b0..c2b8512fbe 100644
--- a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/IgniteCliInterfaceTest.java
+++ b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/IgniteCliInterfaceTest.java
@@ -23,10 +23,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import static org.mockserver.matchers.MatchType.ONLY_MATCHING_FIELDS;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;
@@ -37,23 +33,14 @@ import static org.mockserver.model.JsonBody.json;
import io.micronaut.context.ApplicationContext;
import io.micronaut.context.env.Environment;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.PrintWriter;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collections;
import org.apache.ignite.internal.cli.commands.TopLevelCliCommand;
-import org.apache.ignite.internal.cli.deprecated.builtins.init.InitIgniteCommand;
-import org.apache.ignite.internal.cli.deprecated.builtins.node.NodeManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.junit.jupiter.MockServerExtension;
@@ -77,18 +64,6 @@ public class IgniteCliInterfaceTest extends AbstractCliTest {
/** stdout. */
ByteArrayOutputStream out;
- /** Configuration loader. */
- @Mock
- CliPathsConfigLoader cliPathsCfgLdr;
-
- /** Paths to cli working directories. */
- IgnitePaths ignitePaths = new IgnitePaths(
- Path.of("bin"),
- Path.of("work"),
- Path.of("config"),
- Path.of("log"),
- "version");
-
private final ClientAndServer clientAndServer;
private final String mockUrl;
@@ -105,8 +80,6 @@ public class IgniteCliInterfaceTest extends AbstractCliTest {
void setup() {
ctx = ApplicationContext.run(Environment.TEST);
- ctx.registerSingleton(cliPathsCfgLdr);
-
err = new ByteArrayOutputStream();
out = new ByteArrayOutputStream();
@@ -138,304 +111,12 @@ public class IgniteCliInterfaceTest extends AbstractCliTest {
return cmd(ctx).execute(cmdLine.split(" "));
}
- /**
- * Tests "bootstrap" command.
- */
- @DisplayName("bootstrap")
- @Nested
- class Bootstrap {
- @Test
- @DisplayName("bootstrap")
- void bootstrap() {
- var initIgniteCmd = mock(InitIgniteCommand.class);
-
- ctx.registerSingleton(InitIgniteCommand.class, initIgniteCmd);
-
- CommandLine cli = cmd(ctx);
-
- assertEquals(0, cli.execute("bootstrap"));
- verify(initIgniteCmd).init(any(), any(), any());
- }
- }
-
/**
* Tests "node" command.
*/
@Nested
@DisplayName("node")
class Node {
- /** Manager of local Ignite nodes. */
- @Mock
- NodeManager nodeMgr;
-
- @BeforeEach
- void setUp() {
- ctx.registerSingleton(nodeMgr);
- }
-
- @Test
- @DisplayName("start node1 --config conf.json")
- void start() {
- var nodeName = "node1";
-
- var node =
- new NodeManager.RunningNode(1, nodeName, Path.of("logfile"));
-
- when(nodeMgr.start(any(), any(), any(), any(), any(), any(), any(), any()))
- .thenReturn(node);
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- CommandLine cli = cmd(ctx);
-
- int exitCode = cli.execute(("node start " + nodeName + " --config conf.json").split(" "));
-
- assertThatExitCodeMeansSuccess(exitCode);
-
- verify(nodeMgr).start(
- nodeName,
- ignitePaths.nodesBaseWorkDir(),
- ignitePaths.logDir,
- ignitePaths.cliPidsDir(),
- Path.of("conf.json"),
- null,
- ignitePaths.serverJavaUtilLoggingPros(),
- cli.getOut());
-
- assertOutputEqual("Done\n"
- + "[name: " + nodeName + ", pid: 1]\n\n"
- + "Node is successfully started. To stop, type ignite node stop node1"
- );
- assertThatStderrIsEmpty();
- }
-
- @Test
- @DisplayName("start node1 --port 12345")
- void startCustomPort() {
- var nodeName = "node1";
-
- var node = new NodeManager.RunningNode(1, nodeName, Path.of("logfile"));
-
- when(nodeMgr.start(any(), any(), any(), any(), any(), any(), any(), any()))
- .thenReturn(node);
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- int exitCode = execute("node start " + nodeName + " --port 12345");
-
- assertThatExitCodeMeansSuccess(exitCode);
-
- ArgumentCaptor<String> configStrCaptor = ArgumentCaptor.forClass(String.class);
- verify(nodeMgr).start(any(), any(), any(), any(), any(), configStrCaptor.capture(), any(), any());
-
- assertEqualsIgnoreLineSeparators(
- "network{port=12345}",
- configStrCaptor.getValue()
- );
- }
-
- @Test
- @DisplayName("start node1 --config ignite-config.json --port 12345")
- void startCustomPortOverrideConfigFile() throws URISyntaxException {
- var nodeName = "node1";
-
- var node = new NodeManager.RunningNode(1, nodeName, Path.of("logfile"));
-
- when(nodeMgr.start(any(), any(), any(), any(), any(), any(), any(), any()))
- .thenReturn(node);
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- Path configPath = Path.of(IgniteCliInterfaceTest.class.getResource("/ignite-config.json").toURI());
-
- int exitCode = execute("node start " + nodeName + " --config "
- + configPath.toAbsolutePath()
- + " --port 12345");
-
- assertThatExitCodeMeansSuccess(exitCode);
-
- ArgumentCaptor<String> configStrCaptor = ArgumentCaptor.forClass(String.class);
- verify(nodeMgr).start(any(), any(), any(), any(), any(), configStrCaptor.capture(), any(), any());
-
- assertEqualsIgnoreLineSeparators(
- "network{port=12345},rest{port=10300}",
- configStrCaptor.getValue()
- );
- }
-
- @Test
- @DisplayName("start node1 --port 12345 --rest-port 12346")
- void startCustomPortAndRestPort() {
- var nodeName = "node1";
-
- var node = new NodeManager.RunningNode(1, nodeName, Path.of("logfile"));
-
- when(nodeMgr.start(any(), any(), any(), any(), any(), any(), any(), any()))
- .thenReturn(node);
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- int exitCode = execute("node start " + nodeName + " --port 12345 --rest-port 12346");
-
- assertThatExitCodeMeansSuccess(exitCode);
-
- ArgumentCaptor<String> configStrCaptor = ArgumentCaptor.forClass(String.class);
- verify(nodeMgr).start(any(), any(), any(), any(), any(), configStrCaptor.capture(), any(), any());
-
- assertEqualsIgnoreLineSeparators(
- "network{port=12345},rest{port=12346}",
- configStrCaptor.getValue()
- );
- }
-
- @Test
- @DisplayName("start node1 --port 12345 --rest-port 12346 --join localhost:12345")
- void startCustomPortRestPortAndSeedNodes() {
- var nodeName = "node1";
-
- var node = new NodeManager.RunningNode(1, nodeName, Path.of("logfile"));
-
- when(nodeMgr.start(any(), any(), any(), any(), any(), any(), any(), any()))
- .thenReturn(node);
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- int exitCode = execute("node start " + nodeName + " --port 12345 --rest-port 12346 --join localhost:12345");
-
- assertThatExitCodeMeansSuccess(exitCode);
-
- ArgumentCaptor<String> configStrCaptor = ArgumentCaptor.forClass(String.class);
- verify(nodeMgr).start(any(), any(), any(), any(), any(), configStrCaptor.capture(), any(), any());
-
- assertEqualsIgnoreLineSeparators(
- "network{nodeFinder{netClusterNodes=[\"localhost:12345\"]},port=12345},rest{port=12346}",
- configStrCaptor.getValue()
- );
- }
-
- @Test
- @DisplayName("stop node1")
- void stopRunning() {
- var nodeName = "node1";
-
- when(nodeMgr.stopWait(any(), any()))
- .thenReturn(true);
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- CommandLine cmd = cmd(ctx);
- int exitCode =
- cmd.execute(("node stop " + nodeName).split(" "));
-
- assertThatExitCodeMeansSuccess(exitCode);
- verify(nodeMgr).stopWait(nodeName, ignitePaths.cliPidsDir());
- assertOutputEqual(
- "Stopping locally running node with consistent ID "
- + cmd.getColorScheme().parameterText(nodeName)
- + cmd.getColorScheme().text("...\n@|bold,green Done|@\n")
- );
- assertThatStderrIsEmpty();
- }
-
- @Test
- @DisplayName("stop unknown-node")
- void stopUnknown() {
- var nodeName = "unknown-node";
-
- when(nodeMgr.stopWait(any(), any()))
- .thenReturn(false);
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- CommandLine cmd = cmd(ctx);
- int exitCode =
- cmd.execute(("node stop " + nodeName).split(" "));
-
- assertThatExitCodeMeansSuccess(exitCode);
- verify(nodeMgr).stopWait(nodeName, ignitePaths.cliPidsDir());
- assertOutputEqual(
- "Stopping locally running node with consistent ID "
- + cmd.getColorScheme().parameterText(nodeName)
- + cmd.getColorScheme().text("...\n@|bold,red Failed|@\n")
- );
- assertThatStderrIsEmpty();
- }
-
- @Test
- @DisplayName("list")
- void list() {
- when(nodeMgr.getRunningNodes(any(), any()))
- .thenReturn(Arrays.asList(
- new NodeManager.RunningNode(1, "new1", Path.of("logFile1")),
- new NodeManager.RunningNode(2, "new2", Path.of("logFile2"))
- ));
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- CommandLine cmd = cmd(ctx);
- int exitCode =
- cmd.execute("node list".split(" "));
-
- assertThatExitCodeMeansSuccess(exitCode);
- verify(nodeMgr).getRunningNodes(ignitePaths.logDir, ignitePaths.cliPidsDir());
- assertOutputEqual(
- "╔═══════════════╤═════╤══════════╗\n"
- + "║ consistent id │ pid │ log file ║\n"
- + "╠═══════════════╪═════╪══════════╣\n"
- + "║ new1 │ 1 │ logFile1 ║\n"
- + "╟───────────────┼─────┼──────────╢\n"
- + "║ new2 │ 2 │ logFile2 ║\n"
- + "╚═══════════════╧═════╧══════════╝\n\n"
- + cmd.getColorScheme().text("Number of running nodes: @|bold 2|@\n")
- );
- assertThatStderrIsEmpty();
- }
-
- @Test
- @DisplayName("list")
- void listEmpty() {
- when(nodeMgr.getRunningNodes(any(), any()))
- .thenReturn(Collections.emptyList());
-
- when(cliPathsCfgLdr.loadIgnitePathsOrThrowError())
- .thenReturn(ignitePaths);
-
- CommandLine cmd = cmd(ctx);
- int exitCode =
- cmd.execute("node list".split(" "));
-
- assertThatExitCodeMeansSuccess(exitCode);
- verify(nodeMgr).getRunningNodes(ignitePaths.logDir, ignitePaths.cliPidsDir());
- assertOutputEqual("There are no locally running nodes\n"
- + "use the " + cmd.getColorScheme().commandText("ignite node start") + " command to start a new node"
- );
- assertThatStderrIsEmpty();
- }
-
- @Test
- @DisplayName("classpath")
- void classpath() throws IOException {
- when(nodeMgr.classpathItems()).thenReturn(Arrays.asList("item1", "item2"));
-
- CommandLine cmd = cmd(ctx);
- int exitCode = cmd.execute("node classpath".split(" "));
-
- assertThatExitCodeMeansSuccess(exitCode);
- verify(nodeMgr).classpathItems();
- assertOutputEqual(
- cmd.getColorScheme().text(
- "@|bold Current Ignite node classpath:|@\n item1\n item2\n").toString()
- );
- assertThatStderrIsEmpty();
- }
/**
* Tests "config" command.
diff --git a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/builtins/init/InitIgniteCommandTest.java b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/builtins/init/InitIgniteCommandTest.java
deleted file mode 100644
index e5268dff6d..0000000000
--- a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/builtins/init/InitIgniteCommandTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.init;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import io.micronaut.test.annotation.MockBean;
-import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
-import jakarta.inject.Inject;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Collections;
-import java.util.Comparator;
-import org.apache.ignite.internal.cli.deprecated.AbstractCliTest;
-import org.apache.ignite.internal.cli.deprecated.CliPathsConfigLoader;
-import org.apache.ignite.internal.cli.deprecated.builtins.SystemPathResolver;
-import org.apache.ignite.internal.cli.deprecated.builtins.module.MavenArtifactResolver;
-import org.apache.ignite.internal.cli.deprecated.builtins.module.ResolveResult;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.api.io.TempDir;
-import org.mockito.junit.jupiter.MockitoExtension;
-import picocli.CommandLine.Help.ColorScheme;
-
-/**
- * Tests for Ignite init command.
- */
-@ExtendWith(MockitoExtension.class)
-@MicronautTest
-public class InitIgniteCommandTest extends AbstractCliTest {
- /** Path resolver.*/
- @Inject
- SystemPathResolver pathRslvr;
-
- /** Maven artifact resolver. */
- @Inject
- MavenArtifactResolver mavenArtifactRslvr;
-
- /** Init command instance. */
- @Inject
- InitIgniteCommand initIgniteCmd;
-
- /** Configuration loader. */
- @Inject
- CliPathsConfigLoader cliPathsCfgLdr;
-
- /** Temporary home directory replacement. */
- @TempDir
- Path homeDir;
-
- /** Temporary current directory replacement. */
- @TempDir
- Path currDir;
-
- @Test
- void init() throws IOException {
- when(pathRslvr.osHomeDirectoryPath()).thenReturn(homeDir);
- when(pathRslvr.toolHomeDirectoryPath()).thenReturn(currDir);
-
- when(mavenArtifactRslvr.resolve(any(), any(), any(), any(), any()))
- .thenReturn(new ResolveResult(Collections.emptyList()));
-
- var out = new PrintWriter(System.out, true);
-
- initIgniteCmd.init(null, out, new ColorScheme.Builder().build());
-
- var ignitePaths = cliPathsCfgLdr.loadIgnitePathsConfig().get();
-
- assertTrue(ignitePaths.validateDirs());
- }
-
- @Test
- void reinit() throws IOException {
- when(pathRslvr.osHomeDirectoryPath()).thenReturn(homeDir);
- when(pathRslvr.toolHomeDirectoryPath()).thenReturn(currDir);
-
- when(mavenArtifactRslvr.resolve(any(), any(), any(), any(), any()))
- .thenReturn(new ResolveResult(Collections.emptyList()));
-
- var out = new PrintWriter(System.out, true);
-
- initIgniteCmd.init(null, out, new ColorScheme.Builder().build());
-
- var ignitePaths = cliPathsCfgLdr.loadIgnitePathsOrThrowError();
-
- recursiveDirRemove(ignitePaths.binDir);
-
- assertFalse(ignitePaths::validateDirs);
-
- initIgniteCmd.init(null, out, new ColorScheme.Builder().build());
-
- assertTrue(ignitePaths::validateDirs);
- }
-
- /**
- * Returns maven artifact resolver.
- *
- * @return Maven artifact resolver.
- */
- @MockBean(MavenArtifactResolver.class)
- MavenArtifactResolver mavenArtifactResolver() {
- return mock(MavenArtifactResolver.class);
- }
-
- /**
- * Returns system path resolver.
- *
- * @return System path resolver.
- */
- @MockBean(SystemPathResolver.class)
- SystemPathResolver systemPathResolver() {
- return mock(SystemPathResolver.class);
- }
-
- /**
- * Removes the specified {@dir} and its subdirectories.
- *
- * @param dir Directory to be removed.
- */
- private void recursiveDirRemove(Path dir) throws IOException {
- Files.walk(dir)
- .sorted(Comparator.reverseOrder())
- .map(Path::toFile)
- .forEach(File::delete);
- dir.toFile().delete();
- }
-}
diff --git a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/builtins/init/package-info.java b/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/builtins/init/package-info.java
deleted file mode 100644
index ee9bae9d93..0000000000
--- a/modules/cli/src/test/java/org/apache/ignite/internal/cli/deprecated/builtins/init/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Contains tests for Ignite 'init' process.
- */
-
-package org.apache.ignite.internal.cli.deprecated.builtins.init;
diff --git a/modules/runner/build.gradle b/modules/runner/build.gradle
index 7e584ec179..c88d6665f5 100644
--- a/modules/runner/build.gradle
+++ b/modules/runner/build.gradle
@@ -128,7 +128,7 @@ checkstyleMain {
jar {
manifest {
attributes(
- 'Main-Class': 'org.apache.ignite.app.IgniteCliRunner'
+ 'Main-Class': 'org.apache.ignite.app.IgniteRunner'
)
}
}
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgniteCliRunnerTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgniteRunnerTest.java
similarity index 89%
rename from modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgniteCliRunnerTest.java
rename to modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgniteRunnerTest.java
index 2f2541b58c..7b912794d0 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgniteCliRunnerTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgniteRunnerTest.java
@@ -25,7 +25,7 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgnitionManager;
-import org.apache.ignite.app.IgniteCliRunner;
+import org.apache.ignite.app.IgniteRunner;
import org.apache.ignite.internal.testframework.WorkDirectory;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
import org.junit.jupiter.api.AfterEach;
@@ -36,7 +36,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
* Tests the start ignite nodes.
*/
@ExtendWith(WorkDirectoryExtension.class)
-public class IgniteCliRunnerTest {
+public class IgniteRunnerTest {
private static final String NODE_NAME = "node";
@WorkDirectory
@@ -50,9 +50,9 @@ public class IgniteCliRunnerTest {
/** TODO: Replace this test by full integration test on the cli side IGNITE-15097. */
@Test
public void smokeTestArgs() throws Exception {
- Path configPath = Path.of(IgniteCliRunnerTest.class.getResource("/ignite-config.json").toURI());
+ Path configPath = Path.of(IgniteRunnerTest.class.getResource("/ignite-config.json").toURI());
- CompletableFuture<Ignite> ign = IgniteCliRunner.start(
+ CompletableFuture<Ignite> ign = IgniteRunner.start(
"--config-path", configPath.toAbsolutePath().toString(),
"--work-dir", workDir.resolve("node").toAbsolutePath().toString(),
"--node-name", NODE_NAME
@@ -65,7 +65,7 @@ public class IgniteCliRunnerTest {
@Test
public void smokeTestArgsNullConfig() {
- CompletableFuture<Ignite> ign = IgniteCliRunner.start(
+ CompletableFuture<Ignite> ign = IgniteRunner.start(
"--work-dir", workDir.resolve("node").toAbsolutePath().toString(),
"--node-name", NODE_NAME
);
diff --git a/modules/runner/src/main/java/org/apache/ignite/app/IgniteCliRunner.java b/modules/runner/src/main/java/org/apache/ignite/app/IgniteRunner.java
similarity index 95%
rename from modules/runner/src/main/java/org/apache/ignite/app/IgniteCliRunner.java
rename to modules/runner/src/main/java/org/apache/ignite/app/IgniteRunner.java
index 114b383696..e1691ecb47 100644
--- a/modules/runner/src/main/java/org/apache/ignite/app/IgniteCliRunner.java
+++ b/modules/runner/src/main/java/org/apache/ignite/app/IgniteRunner.java
@@ -41,14 +41,14 @@ import picocli.CommandLine.Option;
import picocli.CommandLine.TypeConversionException;
/**
- * The main entry point for running new Ignite node from CLI toolchain. Configuration values can be overridden using environment variables
+ * The main entry point for running new Ignite node. Configuration values can be overridden using environment variables
* or command-line arguments. Base configuration is either empty, or taken from the {@code --config-path} or {@code --config-string}. Then,
* if an environment variable with the pattern {@code IGNITE_VAR_NAME} (where VAR_NAME corresponds to {@code --var-name} command line
* argument) is set, it overrides the value from the config. And last, if the {@code --var-name} command line argument is passed, it
* overrides any other values.
*/
@Command(name = "runner")
-public class IgniteCliRunner implements Callable<CompletableFuture<Ignite>> {
+public class IgniteRunner implements Callable<CompletableFuture<Ignite>> {
// Picocli doesn't apply default values to arg groups without initial value.
@SuppressWarnings("FieldMayBeFinal")
@@ -120,7 +120,7 @@ public class IgniteCliRunner implements Callable<CompletableFuture<Ignite>> {
* @return New Ignite node.
*/
public static CompletableFuture<Ignite> start(String... args) {
- CommandLine commandLine = new CommandLine(new IgniteCliRunner());
+ CommandLine commandLine = new CommandLine(new IgniteRunner());
commandLine.setDefaultValueProvider(new EnvironmentDefaultValueProvider());
commandLine.registerConverter(NetworkAddress.class, value -> {
try {
diff --git a/packaging/docker/docker-entrypoint.sh b/packaging/docker/docker-entrypoint.sh
index 1c12871f0e..420a10cd4a 100644
--- a/packaging/docker/docker-entrypoint.sh
+++ b/packaging/docker/docker-entrypoint.sh
@@ -28,6 +28,6 @@ CMD="java \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
-Dio.netty.tryReflectionSetAccessible=true \
-Djava.util.logging.config.file=$CONFIG_PATH/ignite.java.util.logging.properties \
--classpath $LIBS_PATH/ignite-runner.jar:$LIBS_PATH/* org.apache.ignite.app.IgniteCliRunner"
+-classpath $LIBS_PATH/ignite-runner.jar:$LIBS_PATH/* org.apache.ignite.app.IgniteRunner"
exec $CMD "$@"
diff --git a/packaging/linux/start.sh b/packaging/linux/start.sh
index 4ccdf7b370..a4121ae007 100644
--- a/packaging/linux/start.sh
+++ b/packaging/linux/start.sh
@@ -35,7 +35,7 @@ CMD="java \
-Dio.netty.tryReflectionSetAccessible=true \
-Djava.util.logging.config.file=@CONF_DIR@/ignite.java.util.logging.properties \
${IGNITE3_EXTRA_JVM_ARGS} \
--classpath @INSTALL_DIR@/lib:@INSTALL_DIR@/lib/* org.apache.ignite.app.IgniteCliRunner \
+-classpath @INSTALL_DIR@/lib:@INSTALL_DIR@/lib/* org.apache.ignite.app.IgniteRunner \
--config-path ${CONFIG_FILE} \
--work-dir ${WORK_DIR} \
--node-name ${NODE_NAME}"
diff --git a/packaging/zip/ignite3db.sh b/packaging/zip/ignite3db.sh
index 4aefeefe14..dff339f131 100755
--- a/packaging/zip/ignite3db.sh
+++ b/packaging/zip/ignite3db.sh
@@ -24,7 +24,7 @@
. $IGNITE_HOME/etc/bootstrap-config.env
- # Export these variables so that IgniteCliRunner can use them as default values
+ # Export these variables so that IgniteRunner can use them as default values
export IGNITE_NODE_NAME=$NODE_NAME
export IGNITE_WORK_DIR=$WORK_PATH
export IGNITE_CONFIG_PATH=$IGNITE_CONFIG_FILE
@@ -46,7 +46,7 @@ start() {
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
-Dio.netty.tryReflectionSetAccessible=true \
-Djava.util.logging.config.file=$CONFIG_PATH/ignite.java.util.logging.properties \
- -classpath $LIBS_PATH/ignite-runner.jar:$LIBS_PATH/* org.apache.ignite.app.IgniteCliRunner"
+ -classpath $LIBS_PATH/ignite-runner.jar:$LIBS_PATH/* org.apache.ignite.app.IgniteRunner"
############# STAGE 3: RUN CMD, REPORT ###############
exec ${CMD} >>${LOG_OUT_FILE:-/dev/null} 2>&1 < /dev/null & jobs -p > ${IGNITE_HOME}/pid