EricJoy2048 commented on code in PR #5450:
URL: https://github.com/apache/seatunnel/pull/5450#discussion_r1360063100


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalPlan.java:
##########
@@ -315,4 +262,63 @@ public JobStatus getJobStatus() {
     public String getJobFullName() {
         return jobFullName;
     }
+
+    public void makeJobFailing(Throwable e) {
+        errorBySubPlan.compareAndSet(null, ExceptionUtils.getMessage(e));
+        updateJobState(JobStatus.FAILING);
+    }
+
+    public void startJob() {
+        isRunning = true;
+        log.info("{} state process is start", getJobFullName());
+        stateProcess();
+    }
+
+    public void stopJobStateProcess() {
+        isRunning = false;
+        log.info("{} state process is stop", getJobFullName());
+    }
+
+    private synchronized void stateProcess() {
+        if (!isRunning) {
+            log.warn(String.format("%s state process is stopped", 
jobFullName));
+            return;
+        }
+        switch (getJobStatus()) {
+            case CREATED:
+                updateJobState(JobStatus.SCHEDULED);
+                break;
+            case SCHEDULED:
+                getPipelineList()
+                        .forEach(
+                                subPlan -> {
+                                    if (PipelineStatus.CREATED.equals(
+                                            subPlan.getCurrPipelineStatus())) {
+                                        subPlan.startSubPlanStateProcess();
+                                    }
+                                });
+                updateJobState(JobStatus.RUNNING);
+                break;
+            case RUNNING:
+                try {
+                    Thread.sleep(200);
+                } catch (InterruptedException e) {
+                    makeJobFailing(e);
+                }

Review Comment:
   done



-- 
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