You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/09/07 12:11:41 UTC

[GitHub] [incubator-seatunnel] hailin0 commented on a diff in pull request #2667: [Feature][ST-Engine] Add handle checkpoint timeout

hailin0 commented on code in PR #2667:
URL: https://github.com/apache/incubator-seatunnel/pull/2667#discussion_r964687181


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobMaster.java:
##########
@@ -164,6 +193,7 @@ public Address queryTaskGroupAddress(long taskGroupId) {
     }
 
     public void cancelJob() {
+        physicalPlan.neverNeedRestore();
         this.physicalPlan.cancelJob();

Review Comment:
   Add `this` or remove `this`?



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalPlan.java:
##########
@@ -85,53 +102,74 @@ public PhysicalPlan(@NonNull List<SubPlan> pipelineList,
         }
         this.jobFullName = String.format("Job %s (%s)", jobImmutableInformation.getJobConfig().getName(),
             jobImmutableInformation.getJobId());
+
+        pipelineSchedulerFutureMap = new HashMap<>(pipelineList.size());
+    }
+
+    public void initJobMaster(JobMaster jobMaster) {
+        this.jobMaster = jobMaster;
     }
 
     public void initStateFuture() {
-        pipelineList.forEach(subPlan -> {
-            PassiveCompletableFuture<PipelineState> future = subPlan.initStateFuture();
-            future.whenComplete((v, t) -> {
-                // We need not handle t, Because we will not return t from Pipeline
+        pipelineList.forEach(subPlan -> addPipelineEndCallback(subPlan));
+    }
+
+    private void addPipelineEndCallback(SubPlan subPlan) {
+        PassiveCompletableFuture<PipelineState> future = subPlan.initStateFuture();
+        future.whenComplete((v, t) -> {

Review Comment:
   (v, t) -> (state, throwable)?



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobMaster.java:
##########
@@ -134,27 +142,48 @@ public void run() {
                 }
                 jobMasterCompleteFuture.complete(physicalPlan.getJobStatus());
             });
-            ownedSlotProfiles.putAll(new PipelineBaseScheduler(physicalPlan, this).startScheduling());
+            jobScheduler = new PipelineBaseScheduler(physicalPlan, this);
+            scheduleFuture = CompletableFuture.runAsync(() -> {
+                ownedSlotProfiles.putAll(jobScheduler.startScheduling());
+            }, executorService);
+            scheduleFuture.join();

Review Comment:
   Add log before blocking code



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalPlan.java:
##########
@@ -85,53 +102,74 @@ public PhysicalPlan(@NonNull List<SubPlan> pipelineList,
         }
         this.jobFullName = String.format("Job %s (%s)", jobImmutableInformation.getJobConfig().getName(),
             jobImmutableInformation.getJobId());
+
+        pipelineSchedulerFutureMap = new HashMap<>(pipelineList.size());
+    }
+
+    public void initJobMaster(JobMaster jobMaster) {
+        this.jobMaster = jobMaster;
     }
 
     public void initStateFuture() {
-        pipelineList.forEach(subPlan -> {
-            PassiveCompletableFuture<PipelineState> future = subPlan.initStateFuture();
-            future.whenComplete((v, t) -> {
-                // We need not handle t, Because we will not return t from Pipeline
+        pipelineList.forEach(subPlan -> addPipelineEndCallback(subPlan));
+    }
+
+    private void addPipelineEndCallback(SubPlan subPlan) {
+        PassiveCompletableFuture<PipelineState> future = subPlan.initStateFuture();
+        future.whenComplete((v, t) -> {
+            // We need not handle t, Because we will not return t from Pipeline
+            try {
                 if (PipelineState.CANCELED.equals(v)) {
+                    if (needRestore) {
+                        restorePipeline(subPlan);
+                        return;
+                    }
                     canceledPipelineNum.incrementAndGet();
+                    if (makeJobEndWhenPipelineEnded) {
+                        cancelJob();
+                    }
+                    jobMaster.releasePipelineResource(subPlan.getPipelineId());

Review Comment:
   Add log?



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalPlan.java:
##########
@@ -85,53 +102,74 @@ public PhysicalPlan(@NonNull List<SubPlan> pipelineList,
         }
         this.jobFullName = String.format("Job %s (%s)", jobImmutableInformation.getJobConfig().getName(),
             jobImmutableInformation.getJobId());
+
+        pipelineSchedulerFutureMap = new HashMap<>(pipelineList.size());
+    }
+
+    public void initJobMaster(JobMaster jobMaster) {

Review Comment:
   rename to `setJobMaster`?



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalVertex.java:
##########
@@ -229,25 +230,25 @@ private TaskGroupImmutableInformation getTaskGroupImmutableInformation() {
             this.pluginJarsUrls);
     }
 
-    private void turnToEndState(@NonNull ExecutionState endState) {
+    private boolean turnToEndState(@NonNull ExecutionState endState) {
         // consistency check
         if (executionState.get().isEndState()) {
-            String message = "Task is trying to leave terminal state " + executionState.get();
-            LOGGER.severe(message);
-            throw new IllegalStateException(message);
+            String message = "Task is already in terminal state " + executionState.get();
+            LOGGER.warning(message);
+            return false;
         }
-
         if (!endState.isEndState()) {
             String message = "Need a end state, not " + endState;
-            LOGGER.severe(message);
-            throw new IllegalStateException(message);
+            LOGGER.warning(message);
+            return false;
         }
 
         LOGGER.info(String.format("%s turn to end state %s.",
             taskFullName,
             endState));

Review Comment:
   Add `taskFullName` to log message?



##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/TestUtils.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.engine.server;
+
+import org.apache.seatunnel.api.common.SeaTunnelContext;
+import org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSink;
+import org.apache.seatunnel.connectors.seatunnel.fake.source.FakeSource;
+import org.apache.seatunnel.engine.common.utils.IdGenerator;
+import org.apache.seatunnel.engine.core.dag.actions.Action;
+import org.apache.seatunnel.engine.core.dag.actions.SinkAction;
+import org.apache.seatunnel.engine.core.dag.actions.SourceAction;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalEdge;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalVertex;
+
+import com.google.common.collect.Sets;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class TestUtils {
+
+    @SuppressWarnings("checkstyle:MagicNumber")
+    public static LogicalDag getTestLogicalDag() throws MalformedURLException {
+        IdGenerator idGenerator = new IdGenerator();
+        FakeSource fakeSource = new FakeSource();
+        fakeSource.setSeaTunnelContext(SeaTunnelContext.getContext());
+
+        Action fake = new SourceAction<>(idGenerator.getNextId(), "fake", fakeSource,
+            Sets.newHashSet(new URL("file:///fake.jar")));
+        fake.setParallelism(3);
+        LogicalVertex fakeVertex = new LogicalVertex(fake.getId(), fake, 3);
+
+        ConsoleSink consoleSink = new ConsoleSink();
+        consoleSink.setSeaTunnelContext(SeaTunnelContext.getContext());
+        Action console = new SinkAction<>(idGenerator.getNextId(), "console", consoleSink,
+            Sets.newHashSet(new URL("file:///console.jar")));

Review Comment:
   Is this jar path valid?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org