-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-27929 Add parent process listener to IgniteNodeRunner #12933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alex-plekhanov
merged 4 commits into
apache:master
from
chesnokoff:ignite-27929-parent-watcher
Mar 27, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f7c19f3
IGNITE-27929 Move IgniteCompatibilityNodeRunner#startParentPipeWatche…
chesnokoff 82a3c0b
Revert "IGNITE-27929 Move IgniteCompatibilityNodeRunner#startParentPi…
chesnokoff bf78b08
IGNITE-27929 Add parent process listener to IgniteNodeRunner
chesnokoff fc382c2
IGNITE-27929 Add doc about duplication
chesnokoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,11 +67,50 @@ public static void main(String[] args) throws Exception { | |
|
|
||
| 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(); | ||
| } | ||
|
|
||
|
Comment on lines
+77
to
+113
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy-pasted from |
||
| /** | ||
| * @return Ignite instance started at main. | ||
| */ | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially, my idea was to introduce the following structure:
This approach was implemented in the first commit of this PR.
However, the problem is that
IgniteNodeRunneris located in the core module, and for compatibility tests we load its older versions (seeIgniteCompatibilityAbstractTest#getDependencies,getExcluded).As a result,
IgniteCompatibilityNodeRunnercannot override methods of older versions ofIgniteNodeRunner.I believe that, for now, it’s better to just copy-paste
IgniteCompatibilityNodeRunner#startParentPipeWatcherintoIgniteNodeRunner, since it currently has only one inheritorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe describe this problem as comment at
IgniteCompatibilityNodeRunner?