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

alexpl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new d2acf963208 IGNITE-27929 Add parent process listener to 
IgniteNodeRunner (#12933)
d2acf963208 is described below

commit d2acf963208339e09fca9c030ccf503ba3957e3b
Author: Aleksandr Chesnokov <[email protected]>
AuthorDate: Fri Mar 27 15:28:37 2026 +0300

    IGNITE-27929 Add parent process listener to IgniteNodeRunner (#12933)
---
 .../junits/IgniteCompatibilityNodeRunner.java      |  4 +++
 .../junits/multijvm/IgniteNodeRunner.java          | 39 ++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java
 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java
index 0a83943e4af..6632ecfdcde 100644
--- 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java
+++ 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java
@@ -128,6 +128,10 @@ public class IgniteCompatibilityNodeRunner extends 
IgniteNodeRunner {
     /**
      * Checks that parent process is alive.
      *
+     * <p>This logic is intentionally duplicated here and in {@link 
IgniteNodeRunner}.
+     * Compatibility tests may run with an older {@code ignite-core-tests} on 
the classpath,
+     * so this runner cannot safely depend on newly added methods in {@code 
IgniteNodeRunner}.</p>
+     *
      * <p>We listen on {@code System.in} because this compatibility node is 
started by the parent JVM via
      * {@link ProcessBuilder}, where {@code System.in} is a pipe from the 
parent. When the parent process exits,
      * the write-end of the pipe is closed and {@code System.in.read()} 
returns EOF. We treat this as a signal
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
 
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
index 030542254a6..7fd89c43443 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
@@ -67,11 +67,50 @@ public class IgniteNodeRunner {
 
         X.println("Starting Ignite Node... Args=" + Arrays.toString(args));
 
+        startParentPipeWatcher();
+        
         IgniteConfiguration cfg = readCfgFromFileAndDeleteFile(args[0]);
 
         ignite = Ignition.start(cfg);
     }
 
+    /**
+     * Checks that parent process is alive.
+     *
+     * <p>We listen on {@code System.in} because this node runner is started 
by the parent JVM via
+     * {@link ProcessBuilder}, where {@code System.in} is a pipe from the 
parent. When the parent process exits,
+     * the write-end of the pipe is closed and {@code System.in.read()} 
returns EOF. We treat this as a signal
+     * to stop Ignite and terminate the process.</p>
+     */
+    private static void startParentPipeWatcher() {
+        Thread thread = new Thread(() -> {
+            try {
+                while (System.in.read() != -1) {
+                    // No-op
+                }
+            }
+            catch (IOException e) {
+                X.println("Failed to read parent stdin pipe, stopping Ignite 
node: " + e);
+            }
+
+            X.println("Parent JVM stdin pipe is closed, stopping Ignite node");
+
+            try {
+                if (ignite != null)
+                    Ignition.stop(ignite.name(), true);
+            }
+            catch (Throwable e) {
+                X.println("Failed to stop Ignite node after parent pipe 
closure: " + e);
+            }
+            finally {
+                System.exit(0);
+            }
+        }, "ignite-parent-pipe-watcher");
+
+        thread.setDaemon(true);
+        thread.start();
+    }
+
     /**
      * @return Ignite instance started at main.
      */

Reply via email to