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

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


The following commit(s) were added to refs/heads/main by this push:
     new 3f8ccfc9fb IGNITE-23667 Stop already started components if start phase 
fails (#4715)
3f8ccfc9fb is described below

commit 3f8ccfc9fbcad7f29ce5bbc0a464ee82cb65e3c0
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Thu Nov 14 10:26:01 2024 +0400

    IGNITE-23667 Stop already started components if start phase fails (#4715)
---
 .../org/apache/ignite/internal/app/IgniteImpl.java | 37 +++++++++++++---------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git 
a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java 
b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
index c135b32bc2..da8ccaaa32 100644
--- 
a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
+++ 
b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
@@ -1273,7 +1273,7 @@ public class IgniteImpl implements Ignite {
 
             // Start the components that are required to join the cluster.
             // TODO https://issues.apache.org/jira/browse/IGNITE-22570
-            return lifecycleManager.startComponentsAsync(
+            CompletableFuture<Void> componentsStartFuture = 
lifecycleManager.startComponentsAsync(
                     componentContext,
                     longJvmPauseDetector,
                     vaultMgr,
@@ -1294,19 +1294,26 @@ public class IgniteImpl implements Ignite {
                     raftMgr,
                     cmgMgr,
                     lowWatermark
-            ).thenRun(() -> {
-                try {
-                    vaultMgr.putName(name);
-
-                    clusterSvc.updateMetadata(
-                            new NodeMetadata(restComponent.hostName(), 
restComponent.httpPort(), restComponent.httpsPort()));
-                } catch (Throwable e) {
-                    startupExecutor.shutdownNow();
-
-                    throw handleStartException(e);
-                }
-                LOG.info("Components started");
-            });
+            );
+
+            return componentsStartFuture
+                    .thenRunAsync(() -> {
+                        vaultMgr.putName(name);
+
+                        clusterSvc.updateMetadata(
+                                new NodeMetadata(restComponent.hostName(), 
restComponent.httpPort(), restComponent.httpsPort()));
+
+                        LOG.info("Components started");
+                    }, startupExecutor)
+                    .handleAsync((v, e) -> {
+                        if (e != null) {
+                            throw handleStartException(e);
+                        }
+
+                        return v;
+                    }, startupExecutor)
+                    // Moving to the common pool on purpose to close the join 
pool and proceed with user's code in the common pool.
+                    .whenCompleteAsync((res, ex) -> 
startupExecutor.shutdownNow());
         } catch (Throwable e) {
             startupExecutor.shutdownNow();
 
@@ -1426,7 +1433,7 @@ public class IgniteImpl implements Ignite {
 
                     return (Ignite) this;
                 }, joinExecutor)
-                // Moving to the common pool on purpose to close the join pool 
and proceed user's code in the common pool.
+                // Moving to the common pool on purpose to close the join pool 
and proceed with user's code in the common pool.
                 .whenCompleteAsync((res, ex) -> joinExecutor.shutdownNow());
     }
 

Reply via email to