ic4y commented on code in PR #4683:
URL: 
https://github.com/apache/incubator-seatunnel/pull/4683#discussion_r1191850323


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/TaskExecutionService.java:
##########
@@ -455,6 +459,37 @@ private synchronized void updateMetricsContextInImap() {
         contextMap.putAll(finishedExecutionContexts);
         contextMap.putAll(executionContexts);
         try {
+            ClusterState clusterState =
+                    
nodeEngine.getHazelcastInstance().getCluster().getClusterState();
+            if (clusterState != ClusterState.ACTIVE) {
+                logger.warning(
+                        String.format(
+                                "The cluster is not ready yet, cluster state 
[%s], looking forward to the next "
+                                        + "scheduling",
+                                clusterState));
+                return;
+            }
+            // Waiting for cluster startup to complete
+            if (waitClusterStarted == null) {
+                waitClusterStarted =
+                        new CountDownLatch(
+                                
nodeEngine.getHazelcastInstance().getCluster().getMembers().size());
+                nodeEngine
+                        .getHazelcastInstance()
+                        .getLifecycleService()
+                        .addLifecycleListener(
+                                event -> {
+                                    if (event.getState() == 
LifecycleEvent.LifecycleState.STARTED) {
+                                        waitClusterStarted.countDown();
+                                    }
+                                });
+            }
+            if (waitClusterStarted.getCount() > 0) {
+                logger.warning(
+                        "The cluster is not ready yet, looking forward to the 
next scheduling");
+                return;
+            }
+

Review Comment:
   I've reviewed the code, and the exception might be thrown because the 
current Node hasn't finished initializing. Try using 
nodeEngine.getNode().getState().equals(NodeState.ACTIVE) and see how it goes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to