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 2021/10/06 10:43:14 UTC

[ignite-3] branch ignite-3.0.0-alpha3 updated: IGNITE-15538 Fixed NullPointerException during node start via cli. Fixes #378

This is an automated email from the ASF dual-hosted git repository.

sk0x50 pushed a commit to branch ignite-3.0.0-alpha3
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/ignite-3.0.0-alpha3 by this push:
     new 3ce8058  IGNITE-15538 Fixed NullPointerException during node start via cli. Fixes #378
3ce8058 is described below

commit 3ce8058c19628c2dd227d839415be09279cf8d2b
Author: Slava Koptilin <sl...@gmail.com>
AuthorDate: Wed Oct 6 13:40:10 2021 +0300

    IGNITE-15538 Fixed NullPointerException during node start via cli. Fixes #378
    
    (cherry picked from commit cb1a405fd1f37a144be19c03fe91dbd1ecfe6f0b)
---
 .../org/apache/ignite/cli/builtins/node/NodeManager.java   | 14 ++++++++------
 .../main/java/org/apache/ignite/app/IgniteCliRunner.java   |  5 ++++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/modules/cli/src/main/java/org/apache/ignite/cli/builtins/node/NodeManager.java b/modules/cli/src/main/java/org/apache/ignite/cli/builtins/node/NodeManager.java
index 5e4b1f2..2ea71af 100644
--- a/modules/cli/src/main/java/org/apache/ignite/cli/builtins/node/NodeManager.java
+++ b/modules/cli/src/main/java/org/apache/ignite/cli/builtins/node/NodeManager.java
@@ -111,12 +111,11 @@ public class NodeManager {
             Process p = pb.start();
 
             try (var spinner = new Spinner(out, "Starting a new Ignite node")) {
-
-                if (!waitForStart("Apache Ignite started successfully!", logFile, NODE_START_TIMEOUT, spinner)) {
+                if (!waitForStart("Apache Ignite 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");
+                        + NODE_START_TIMEOUT.toMillis() + "ms. Read logs for details: " + logFile);
                 }
             }
             catch (InterruptedException | IOException e) {
@@ -137,6 +136,7 @@ public class NodeManager {
      *
      * @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
@@ -145,12 +145,13 @@ public class NodeManager {
     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()) {
+        while ((System.currentTimeMillis() - start) < timeout.toMillis() && p.isAlive()) {
             spinner.spin();
             LockSupport.parkNanos(LOG_FILE_POLL_INTERVAL.toNanos());
 
@@ -158,10 +159,11 @@ public class NodeManager {
 
             if (content.contains(started))
                 return true;
-            else if (content.contains("Exception"))
-                throw new IgniteCLIException("Can't start the node. Read logs for details: " + file);
         }
 
+        if (!p.isAlive())
+            throw new IgniteCLIException("Can't start the node. Read logs for details: " + file);
+
         return false;
     }
 
diff --git a/modules/runner/src/main/java/org/apache/ignite/app/IgniteCliRunner.java b/modules/runner/src/main/java/org/apache/ignite/app/IgniteCliRunner.java
index 09fb12a..5bc34e7 100644
--- a/modules/runner/src/main/java/org/apache/ignite/app/IgniteCliRunner.java
+++ b/modules/runner/src/main/java/org/apache/ignite/app/IgniteCliRunner.java
@@ -56,7 +56,10 @@ public class IgniteCliRunner {
         var ignition = new IgnitionImpl();
 
         // TODO use the work dir provided as a parameter: https://issues.apache.org/jira/browse/IGNITE-15060
-        ignition.start(parsedArgs.nodeName, parsedArgs.config.toAbsolutePath(), Path.of("work"));
+        ignition.start(
+            parsedArgs.nodeName,
+            parsedArgs.config != null ? parsedArgs.config.toAbsolutePath() : null,
+            Path.of("work"));
     }
 
     /**