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/08/15 02:56:38 UTC

[GitHub] [incubator-seatunnel] EricJoy2048 opened a new pull request, #2413: [ST-Engine] Add wait for job complete feture

EricJoy2048 opened a new pull request, #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413

   Client should wait for job complete.


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


[GitHub] [incubator-seatunnel] ic4y commented on a diff in pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
ic4y commented on code in PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949039714


##########
seatunnel-engine/seatunnel-engine-core/src/main/java/org/apache/seatunnel/engine/core/protocol/codec/SeaTunnelWaitForJobCompleteCodec.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.core.protocol.codec;
+
+import static com.hazelcast.client.impl.protocol.ClientMessage.PARTITION_ID_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.RESPONSE_BACKUP_ACKS_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.TYPE_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.UNFRAGMENTED_MESSAGE;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.BYTE_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.INT_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.LONG_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.decodeInt;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.decodeLong;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.encodeInt;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.encodeLong;
+
+import com.hazelcast.client.impl.protocol.ClientMessage;
+import com.hazelcast.client.impl.protocol.Generated;
+
+/*
+ * This file is auto-generated by the Hazelcast Client Protocol Code Generator.
+ * To change this file, edit the templates or the protocol
+ * definitions on the https://github.com/hazelcast/hazelcast-client-protocol
+ * and regenerate it.
+ */
+
+@Generated("45a79cdd8ea874bd3c99b414d5f7639f")
+public final class SeaTunnelWaitForJobCompleteCodec {
+    //hex: 0xDE0300
+    public static final int REQUEST_MESSAGE_TYPE = 14549760;
+    //hex: 0xDE0301
+    public static final int RESPONSE_MESSAGE_TYPE = 14549761;
+    private static final int REQUEST_JOB_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES;
+    private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_JOB_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES;
+    private static final int RESPONSE_JOB_STATUS_FIELD_OFFSET = RESPONSE_BACKUP_ACKS_FIELD_OFFSET + BYTE_SIZE_IN_BYTES;
+    private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_JOB_STATUS_FIELD_OFFSET + INT_SIZE_IN_BYTES;
+
+    private SeaTunnelWaitForJobCompleteCodec() {
+    }
+
+    public static ClientMessage encodeRequest(long jobId) {
+        ClientMessage clientMessage = ClientMessage.createForEncode();
+        clientMessage.setRetryable(true);
+        clientMessage.setOperationName("SeaTunnel.WaitForJobComplete");
+        ClientMessage.Frame initialFrame =
+            new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE);
+        encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE);
+        encodeInt(initialFrame.content, PARTITION_ID_FIELD_OFFSET, -1);
+        encodeLong(initialFrame.content, REQUEST_JOB_ID_FIELD_OFFSET, jobId);
+        clientMessage.add(initialFrame);
+        return clientMessage;
+    }
+
+    /**
+     *
+     */

Review Comment:
   meaningless code



##########
seatunnel-core/seatunnel-seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelStarter.java:
##########
@@ -45,12 +45,13 @@ public static void main(String[] args) {
         SeaTunnelClient engineClient = new SeaTunnelClient(clientConfig);
         JobExecutionEnvironment jobExecutionEnv = engineClient.createExecutionContext(configFile.toString(), jobConfig);
 
+        JobProxy jobProxy;
         try {
-            JobProxy jobProxy = jobExecutionEnv.execute();
+            jobProxy = jobExecutionEnv.execute();
         } catch (ExecutionException | InterruptedException e) {
             throw new RuntimeException(e);
         }
 
-        // TODO wait for job complete and then exit
+        jobProxy.waitForJobComplete();

Review Comment:
   jobProxy may be null



##########
seatunnel-engine/seatunnel-engine-core/src/main/java/org/apache/seatunnel/engine/core/protocol/codec/SeaTunnelWaitForJobCompleteCodec.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.core.protocol.codec;
+
+import static com.hazelcast.client.impl.protocol.ClientMessage.PARTITION_ID_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.RESPONSE_BACKUP_ACKS_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.TYPE_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.UNFRAGMENTED_MESSAGE;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.BYTE_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.INT_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.LONG_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.decodeInt;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.decodeLong;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.encodeInt;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.encodeLong;
+
+import com.hazelcast.client.impl.protocol.ClientMessage;
+import com.hazelcast.client.impl.protocol.Generated;
+
+/*
+ * This file is auto-generated by the Hazelcast Client Protocol Code Generator.
+ * To change this file, edit the templates or the protocol
+ * definitions on the https://github.com/hazelcast/hazelcast-client-protocol
+ * and regenerate it.
+ */
+
+@Generated("45a79cdd8ea874bd3c99b414d5f7639f")
+public final class SeaTunnelWaitForJobCompleteCodec {
+    //hex: 0xDE0300
+    public static final int REQUEST_MESSAGE_TYPE = 14549760;
+    //hex: 0xDE0301
+    public static final int RESPONSE_MESSAGE_TYPE = 14549761;
+    private static final int REQUEST_JOB_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES;
+    private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_JOB_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES;
+    private static final int RESPONSE_JOB_STATUS_FIELD_OFFSET = RESPONSE_BACKUP_ACKS_FIELD_OFFSET + BYTE_SIZE_IN_BYTES;
+    private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_JOB_STATUS_FIELD_OFFSET + INT_SIZE_IN_BYTES;
+
+    private SeaTunnelWaitForJobCompleteCodec() {
+    }
+
+    public static ClientMessage encodeRequest(long jobId) {
+        ClientMessage clientMessage = ClientMessage.createForEncode();
+        clientMessage.setRetryable(true);
+        clientMessage.setOperationName("SeaTunnel.WaitForJobComplete");
+        ClientMessage.Frame initialFrame =
+            new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE);
+        encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE);
+        encodeInt(initialFrame.content, PARTITION_ID_FIELD_OFFSET, -1);
+        encodeLong(initialFrame.content, REQUEST_JOB_ID_FIELD_OFFSET, jobId);
+        clientMessage.add(initialFrame);
+        return clientMessage;
+    }
+
+    /**
+     *
+     */
+    public static long decodeRequest(ClientMessage clientMessage) {
+        ClientMessage.ForwardFrameIterator iterator = clientMessage.frameIterator();
+        ClientMessage.Frame initialFrame = iterator.next();
+        return decodeLong(initialFrame.content, REQUEST_JOB_ID_FIELD_OFFSET);
+    }
+
+    public static ClientMessage encodeResponse(int jobStatus) {
+        ClientMessage clientMessage = ClientMessage.createForEncode();
+        ClientMessage.Frame initialFrame =
+            new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE);
+        encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE);
+        encodeInt(initialFrame.content, RESPONSE_JOB_STATUS_FIELD_OFFSET, jobStatus);
+        clientMessage.add(initialFrame);
+
+        return clientMessage;
+    }
+
+    /**
+     *
+     */

Review Comment:
   as above.



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalVertex.java:
##########
@@ -145,26 +142,35 @@ public PhysicalVertex(long physicalVertexId,
     @SuppressWarnings("checkstyle:MagicNumber")
     // This method must not throw an exception
     public void deploy(@NonNull Address address) {
-
-        TaskGroupImmutableInformation taskGroupImmutableInformation =
-                new TaskGroupImmutableInformation(flakeIdGenerator.newId(),
-                        nodeEngine.getSerializationService().toData(this.taskGroup),
-                        this.pluginJarsUrls);
-
-        try {
-            waitForCompleteByExecutionService = new NonCompletableFuture<>(
-                    nodeEngine.getOperationService().createInvocationBuilder(Constant.SEATUNNEL_SERVICE_NAME,
-                                    new DeployTaskOperation(nodeEngine.getSerializationService().toData(taskGroupImmutableInformation)),
-                                    address)
-                            .invoke());
-        } catch (Throwable th) {
-            LOGGER.severe(String.format("%s deploy error with Exception: %s",
-                    this.taskFullName,
-                    ExceptionUtils.getMessage(th)));
-            updateTaskState(ExecutionState.DEPLOYING, ExecutionState.FAILED);
-            taskFuture.complete(
-                    new TaskExecutionState(taskGroupImmutableInformation.getExecutionId(), ExecutionState.FAILED, null));
-        }
+        /**
+         TaskGroupImmutableInformation taskGroupImmutableInformation =
+         new TaskGroupImmutableInformation(flakeIdGenerator.newId(),
+         nodeEngine.getSerializationService().toData(this.taskGroup),
+         this.pluginJarsUrls);
+
+         try {
+         waitForCompleteByExecutionService = new NonCompletableFuture<>(
+         nodeEngine.getOperationService().createInvocationBuilder(Constant.SEATUNNEL_SERVICE_NAME,
+         new DeployTaskOperation(nodeEngine.getSerializationService().toData(taskGroupImmutableInformation)),
+         address)
+         .invoke());
+         } catch (Throwable th) {
+         LOGGER.severe(String.format("%s deploy error with Exception: %s",
+         this.taskFullName,
+         ExceptionUtils.getMessage(th)));
+         updateTaskState(ExecutionState.DEPLOYING, ExecutionState.FAILED);
+         taskFuture.complete(
+         new TaskExecutionState(taskGroupImmutableInformation.getExecutionId(), ExecutionState.FAILED, null));
+         }*/
+
+        waitForCompleteByExecutionService = new PassiveCompletableFuture<>(CompletableFuture.supplyAsync(() -> {
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+            }
+            return new TaskExecutionState(flakeIdGenerator.newId(), ExecutionState.FINISHED, null);
+        }));

Review Comment:
   Why not deploy the task, but simulate execution



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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949773527


##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/JobProxy.java:
##########
@@ -47,10 +51,37 @@ public long getJobId() {
 
     @Override
     public void submitJob() throws ExecutionException, InterruptedException {
-        ClientMessage request = SeaTunnelSubmitJobCodec.encodeRequest(
+        ClientMessage request = SeaTunnelSubmitJobCodec.encodeRequest(jobImmutableInformation.getJobId(),
             seaTunnelHazelcastClient.getSerializationService().toData(jobImmutableInformation));
-        NonCompletableFuture<Void> submitJobFuture =
+        PassiveCompletableFuture<Void> submitJobFuture =
             seaTunnelHazelcastClient.requestOnMasterAndGetCompletableFuture(request);
         submitJobFuture.get();
     }
+
+    @Override
+    public void waitForJobComplete() {
+        PassiveCompletableFuture<JobStatus> jobFuture =
+            seaTunnelHazelcastClient.requestOnMasterAndGetCompletableFuture(
+                SeaTunnelWaitForJobCompleteCodec.encodeRequest(jobImmutableInformation.getJobId()),
+                response -> {
+                    return JobStatus.values()[SeaTunnelWaitForJobCompleteCodec.decodeResponse(response)];
+                });
+
+        jobFuture.whenComplete((v, t) -> {

Review Comment:
   Yes, I will do it in next feature.



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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949732778


##########
seatunnel-core/seatunnel-seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelStarter.java:
##########
@@ -45,12 +45,13 @@ public static void main(String[] args) {
         SeaTunnelClient engineClient = new SeaTunnelClient(clientConfig);
         JobExecutionEnvironment jobExecutionEnv = engineClient.createExecutionContext(configFile.toString(), jobConfig);
 
+        JobProxy jobProxy;
         try {
-            JobProxy jobProxy = jobExecutionEnv.execute();
+            jobProxy = jobExecutionEnv.execute();
         } catch (ExecutionException | InterruptedException e) {
             throw new RuntimeException(e);
         }
 
-        // TODO wait for job complete and then exit
+        jobProxy.waitForJobComplete();

Review Comment:
   done



##########
seatunnel-engine/seatunnel-engine-core/src/main/java/org/apache/seatunnel/engine/core/protocol/codec/SeaTunnelWaitForJobCompleteCodec.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.core.protocol.codec;
+
+import static com.hazelcast.client.impl.protocol.ClientMessage.PARTITION_ID_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.RESPONSE_BACKUP_ACKS_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.TYPE_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.UNFRAGMENTED_MESSAGE;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.BYTE_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.INT_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.LONG_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.decodeInt;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.decodeLong;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.encodeInt;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.encodeLong;
+
+import com.hazelcast.client.impl.protocol.ClientMessage;
+import com.hazelcast.client.impl.protocol.Generated;
+
+/*
+ * This file is auto-generated by the Hazelcast Client Protocol Code Generator.
+ * To change this file, edit the templates or the protocol
+ * definitions on the https://github.com/hazelcast/hazelcast-client-protocol
+ * and regenerate it.
+ */
+
+@Generated("45a79cdd8ea874bd3c99b414d5f7639f")
+public final class SeaTunnelWaitForJobCompleteCodec {
+    //hex: 0xDE0300
+    public static final int REQUEST_MESSAGE_TYPE = 14549760;
+    //hex: 0xDE0301
+    public static final int RESPONSE_MESSAGE_TYPE = 14549761;
+    private static final int REQUEST_JOB_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES;
+    private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_JOB_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES;
+    private static final int RESPONSE_JOB_STATUS_FIELD_OFFSET = RESPONSE_BACKUP_ACKS_FIELD_OFFSET + BYTE_SIZE_IN_BYTES;
+    private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_JOB_STATUS_FIELD_OFFSET + INT_SIZE_IN_BYTES;
+
+    private SeaTunnelWaitForJobCompleteCodec() {
+    }
+
+    public static ClientMessage encodeRequest(long jobId) {
+        ClientMessage clientMessage = ClientMessage.createForEncode();
+        clientMessage.setRetryable(true);
+        clientMessage.setOperationName("SeaTunnel.WaitForJobComplete");
+        ClientMessage.Frame initialFrame =
+            new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE);
+        encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE);
+        encodeInt(initialFrame.content, PARTITION_ID_FIELD_OFFSET, -1);
+        encodeLong(initialFrame.content, REQUEST_JOB_ID_FIELD_OFFSET, jobId);
+        clientMessage.add(initialFrame);
+        return clientMessage;
+    }
+
+    /**
+     *
+     */

Review Comment:
   done



##########
seatunnel-engine/seatunnel-engine-core/src/main/java/org/apache/seatunnel/engine/core/protocol/codec/SeaTunnelWaitForJobCompleteCodec.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.core.protocol.codec;
+
+import static com.hazelcast.client.impl.protocol.ClientMessage.PARTITION_ID_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.RESPONSE_BACKUP_ACKS_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.TYPE_FIELD_OFFSET;
+import static com.hazelcast.client.impl.protocol.ClientMessage.UNFRAGMENTED_MESSAGE;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.BYTE_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.INT_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.LONG_SIZE_IN_BYTES;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.decodeInt;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.decodeLong;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.encodeInt;
+import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.encodeLong;
+
+import com.hazelcast.client.impl.protocol.ClientMessage;
+import com.hazelcast.client.impl.protocol.Generated;
+
+/*
+ * This file is auto-generated by the Hazelcast Client Protocol Code Generator.
+ * To change this file, edit the templates or the protocol
+ * definitions on the https://github.com/hazelcast/hazelcast-client-protocol
+ * and regenerate it.
+ */
+
+@Generated("45a79cdd8ea874bd3c99b414d5f7639f")
+public final class SeaTunnelWaitForJobCompleteCodec {
+    //hex: 0xDE0300
+    public static final int REQUEST_MESSAGE_TYPE = 14549760;
+    //hex: 0xDE0301
+    public static final int RESPONSE_MESSAGE_TYPE = 14549761;
+    private static final int REQUEST_JOB_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES;
+    private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_JOB_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES;
+    private static final int RESPONSE_JOB_STATUS_FIELD_OFFSET = RESPONSE_BACKUP_ACKS_FIELD_OFFSET + BYTE_SIZE_IN_BYTES;
+    private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_JOB_STATUS_FIELD_OFFSET + INT_SIZE_IN_BYTES;
+
+    private SeaTunnelWaitForJobCompleteCodec() {
+    }
+
+    public static ClientMessage encodeRequest(long jobId) {
+        ClientMessage clientMessage = ClientMessage.createForEncode();
+        clientMessage.setRetryable(true);
+        clientMessage.setOperationName("SeaTunnel.WaitForJobComplete");
+        ClientMessage.Frame initialFrame =
+            new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE);
+        encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE);
+        encodeInt(initialFrame.content, PARTITION_ID_FIELD_OFFSET, -1);
+        encodeLong(initialFrame.content, REQUEST_JOB_ID_FIELD_OFFSET, jobId);
+        clientMessage.add(initialFrame);
+        return clientMessage;
+    }
+
+    /**
+     *
+     */
+    public static long decodeRequest(ClientMessage clientMessage) {
+        ClientMessage.ForwardFrameIterator iterator = clientMessage.frameIterator();
+        ClientMessage.Frame initialFrame = iterator.next();
+        return decodeLong(initialFrame.content, REQUEST_JOB_ID_FIELD_OFFSET);
+    }
+
+    public static ClientMessage encodeResponse(int jobStatus) {
+        ClientMessage clientMessage = ClientMessage.createForEncode();
+        ClientMessage.Frame initialFrame =
+            new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE);
+        encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE);
+        encodeInt(initialFrame.content, RESPONSE_JOB_STATUS_FIELD_OFFSET, jobStatus);
+        clientMessage.add(initialFrame);
+
+        return clientMessage;
+    }
+
+    /**
+     *
+     */

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

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


[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949764046


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/operation/DeployTaskOperation.java:
##########
@@ -40,9 +40,9 @@ public DeployTaskOperation(@NonNull Data taskImmutableInformation) {
     }
 
     @Override
-    protected NonCompletableFuture<?> doRun() throws Exception {
-        SeaTunnelServer server = getService();
-        return server.getTaskExecutionService().deployTask(taskImmutableInformation);
+    protected PassiveCompletableFuture<?> doRun() throws Exception {
+        TaskExecutionService taskExecutionService = getService();

Review Comment:
   Does `TaskExecutionService` is an hazelcast service? Can use `getService()` to get it?



##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/JobProxy.java:
##########
@@ -47,10 +51,37 @@ public long getJobId() {
 
     @Override
     public void submitJob() throws ExecutionException, InterruptedException {
-        ClientMessage request = SeaTunnelSubmitJobCodec.encodeRequest(
+        ClientMessage request = SeaTunnelSubmitJobCodec.encodeRequest(jobImmutableInformation.getJobId(),
             seaTunnelHazelcastClient.getSerializationService().toData(jobImmutableInformation));
-        NonCompletableFuture<Void> submitJobFuture =
+        PassiveCompletableFuture<Void> submitJobFuture =
             seaTunnelHazelcastClient.requestOnMasterAndGetCompletableFuture(request);
         submitJobFuture.get();
     }
+
+    @Override
+    public void waitForJobComplete() {
+        PassiveCompletableFuture<JobStatus> jobFuture =
+            seaTunnelHazelcastClient.requestOnMasterAndGetCompletableFuture(
+                SeaTunnelWaitForJobCompleteCodec.encodeRequest(jobImmutableInformation.getJobId()),
+                response -> {
+                    return JobStatus.values()[SeaTunnelWaitForJobCompleteCodec.decodeResponse(response)];
+                });
+
+        jobFuture.whenComplete((v, t) -> {

Review Comment:
   Did we can't show log in client at now?



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServer.java:
##########
@@ -116,23 +122,39 @@ public LiveOperationRegistry getLiveOperationRegistry() {
     /**
      * call by client to submit job
      */
-    @SuppressWarnings("checkstyle:MagicNumber")
-    public NonCompletableFuture<Void> submitJob(Data jobImmutableInformation) {
+    public PassiveCompletableFuture<Void> submitJob(long jobId, Data jobImmutableInformation) {
         CompletableFuture<Void> voidCompletableFuture = new CompletableFuture<>();
         JobMaster jobMaster = new JobMaster(jobImmutableInformation, this.nodeEngine, executorService);
         executorService.submit(() -> {
             try {
                 jobMaster.init();
-                jobMaster.run();
+                runningJobMasterMap.put(jobId, jobMaster);
             } catch (Throwable e) {
-                LOGGER.severe("submit job error: " + e.getMessage());
+                LOGGER.severe(String.format("submit job %s error %s ", jobId, ExceptionUtils.getMessage(e)));
                 voidCompletableFuture.completeExceptionally(e);
             } finally {
                 // We specify that when init is complete, the submitJob is complete
                 voidCompletableFuture.complete(null);
             }
-            //jobMaster.run();
+
+            try {
+                jobMaster.run();
+            } finally {
+                runningJobMasterMap.remove(jobId);
+            }
         });
-        return new NonCompletableFuture<>(voidCompletableFuture);
+        return new PassiveCompletableFuture(voidCompletableFuture);
+    }
+
+    public PassiveCompletableFuture<JobStatus> waitForJobComplete(long jobId) {
+        JobMaster runningJobMaster = runningJobMasterMap.get(jobId);
+        if (runningJobMaster == null) {

Review Comment:
   If `runningJobMaster` failed, but `runningJobMasterMap.remove(jobId)` already executed. The job status will be FINISHED not FAILED. This is a mistake.



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServer.java:
##########
@@ -116,23 +122,39 @@ public LiveOperationRegistry getLiveOperationRegistry() {
     /**
      * call by client to submit job
      */
-    @SuppressWarnings("checkstyle:MagicNumber")
-    public NonCompletableFuture<Void> submitJob(Data jobImmutableInformation) {
+    public PassiveCompletableFuture<Void> submitJob(long jobId, Data jobImmutableInformation) {
         CompletableFuture<Void> voidCompletableFuture = new CompletableFuture<>();
         JobMaster jobMaster = new JobMaster(jobImmutableInformation, this.nodeEngine, executorService);
         executorService.submit(() -> {
             try {
                 jobMaster.init();
-                jobMaster.run();
+                runningJobMasterMap.put(jobId, jobMaster);
             } catch (Throwable e) {
-                LOGGER.severe("submit job error: " + e.getMessage());
+                LOGGER.severe(String.format("submit job %s error %s ", jobId, ExceptionUtils.getMessage(e)));
                 voidCompletableFuture.completeExceptionally(e);
             } finally {
                 // We specify that when init is complete, the submitJob is complete
                 voidCompletableFuture.complete(null);
             }
-            //jobMaster.run();
+
+            try {
+                jobMaster.run();

Review Comment:
   If `jobMaster.run()` throw an exception, how handle it?



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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949777036


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/operation/DeployTaskOperation.java:
##########
@@ -40,9 +40,9 @@ public DeployTaskOperation(@NonNull Data taskImmutableInformation) {
     }
 
     @Override
-    protected NonCompletableFuture<?> doRun() throws Exception {
-        SeaTunnelServer server = getService();
-        return server.getTaskExecutionService().deployTask(taskImmutableInformation);
+    protected PassiveCompletableFuture<?> doRun() throws Exception {
+        TaskExecutionService taskExecutionService = getService();

Review Comment:
   Yes, `TaskExecutionService is an hazelcast service` is right.



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


[GitHub] [incubator-seatunnel] EricJoy2048 closed pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
EricJoy2048 closed pull request #2413: [ST-Engine] Add wait for job complete feture
URL: https://github.com/apache/incubator-seatunnel/pull/2413


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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949775983


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServer.java:
##########
@@ -116,23 +122,39 @@ public LiveOperationRegistry getLiveOperationRegistry() {
     /**
      * call by client to submit job
      */
-    @SuppressWarnings("checkstyle:MagicNumber")
-    public NonCompletableFuture<Void> submitJob(Data jobImmutableInformation) {
+    public PassiveCompletableFuture<Void> submitJob(long jobId, Data jobImmutableInformation) {
         CompletableFuture<Void> voidCompletableFuture = new CompletableFuture<>();
         JobMaster jobMaster = new JobMaster(jobImmutableInformation, this.nodeEngine, executorService);
         executorService.submit(() -> {
             try {
                 jobMaster.init();
-                jobMaster.run();
+                runningJobMasterMap.put(jobId, jobMaster);
             } catch (Throwable e) {
-                LOGGER.severe("submit job error: " + e.getMessage());
+                LOGGER.severe(String.format("submit job %s error %s ", jobId, ExceptionUtils.getMessage(e)));
                 voidCompletableFuture.completeExceptionally(e);
             } finally {
                 // We specify that when init is complete, the submitJob is complete
                 voidCompletableFuture.complete(null);
             }
-            //jobMaster.run();
+
+            try {
+                jobMaster.run();

Review Comment:
   `submitJob` method only return the `submit` operation state, If `jobMaster.run()` throw Exception, if will be handle in `waitForJobComplete()`



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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949776562


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServer.java:
##########
@@ -116,23 +122,39 @@ public LiveOperationRegistry getLiveOperationRegistry() {
     /**
      * call by client to submit job
      */
-    @SuppressWarnings("checkstyle:MagicNumber")
-    public NonCompletableFuture<Void> submitJob(Data jobImmutableInformation) {
+    public PassiveCompletableFuture<Void> submitJob(long jobId, Data jobImmutableInformation) {
         CompletableFuture<Void> voidCompletableFuture = new CompletableFuture<>();
         JobMaster jobMaster = new JobMaster(jobImmutableInformation, this.nodeEngine, executorService);
         executorService.submit(() -> {
             try {
                 jobMaster.init();
-                jobMaster.run();
+                runningJobMasterMap.put(jobId, jobMaster);
             } catch (Throwable e) {
-                LOGGER.severe("submit job error: " + e.getMessage());
+                LOGGER.severe(String.format("submit job %s error %s ", jobId, ExceptionUtils.getMessage(e)));
                 voidCompletableFuture.completeExceptionally(e);
             } finally {
                 // We specify that when init is complete, the submitJob is complete
                 voidCompletableFuture.complete(null);
             }
-            //jobMaster.run();
+
+            try {
+                jobMaster.run();
+            } finally {
+                runningJobMasterMap.remove(jobId);
+            }
         });
-        return new NonCompletableFuture<>(voidCompletableFuture);
+        return new PassiveCompletableFuture(voidCompletableFuture);
+    }
+
+    public PassiveCompletableFuture<JobStatus> waitForJobComplete(long jobId) {
+        JobMaster runningJobMaster = runningJobMasterMap.get(jobId);
+        if (runningJobMaster == null) {

Review Comment:
   I add a todo comment `// TODO Get Job Status from JobHistoryStorage` .
   Now I only add some tmp code.



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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949731384


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalVertex.java:
##########
@@ -145,26 +142,35 @@ public PhysicalVertex(long physicalVertexId,
     @SuppressWarnings("checkstyle:MagicNumber")
     // This method must not throw an exception
     public void deploy(@NonNull Address address) {
-
-        TaskGroupImmutableInformation taskGroupImmutableInformation =
-                new TaskGroupImmutableInformation(flakeIdGenerator.newId(),
-                        nodeEngine.getSerializationService().toData(this.taskGroup),
-                        this.pluginJarsUrls);
-
-        try {
-            waitForCompleteByExecutionService = new NonCompletableFuture<>(
-                    nodeEngine.getOperationService().createInvocationBuilder(Constant.SEATUNNEL_SERVICE_NAME,
-                                    new DeployTaskOperation(nodeEngine.getSerializationService().toData(taskGroupImmutableInformation)),
-                                    address)
-                            .invoke());
-        } catch (Throwable th) {
-            LOGGER.severe(String.format("%s deploy error with Exception: %s",
-                    this.taskFullName,
-                    ExceptionUtils.getMessage(th)));
-            updateTaskState(ExecutionState.DEPLOYING, ExecutionState.FAILED);
-            taskFuture.complete(
-                    new TaskExecutionState(taskGroupImmutableInformation.getExecutionId(), ExecutionState.FAILED, null));
-        }
+        /**
+         TaskGroupImmutableInformation taskGroupImmutableInformation =
+         new TaskGroupImmutableInformation(flakeIdGenerator.newId(),
+         nodeEngine.getSerializationService().toData(this.taskGroup),
+         this.pluginJarsUrls);
+
+         try {
+         waitForCompleteByExecutionService = new NonCompletableFuture<>(
+         nodeEngine.getOperationService().createInvocationBuilder(Constant.SEATUNNEL_SERVICE_NAME,
+         new DeployTaskOperation(nodeEngine.getSerializationService().toData(taskGroupImmutableInformation)),
+         address)
+         .invoke());
+         } catch (Throwable th) {
+         LOGGER.severe(String.format("%s deploy error with Exception: %s",
+         this.taskFullName,
+         ExceptionUtils.getMessage(th)));
+         updateTaskState(ExecutionState.DEPLOYING, ExecutionState.FAILED);
+         taskFuture.complete(
+         new TaskExecutionState(taskGroupImmutableInformation.getExecutionId(), ExecutionState.FAILED, null));
+         }*/
+
+        waitForCompleteByExecutionService = new PassiveCompletableFuture<>(CompletableFuture.supplyAsync(() -> {
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+            }
+            return new TaskExecutionState(flakeIdGenerator.newId(), ExecutionState.FINISHED, null);
+        }));

Review Comment:
   > Why not deploy the task, but simulate execution
   
   Because TaskGroup can not serialization when this pr create, So I do it in another pr.



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


[GitHub] [incubator-seatunnel] Hisoka-X merged pull request #2413: [ST-Engine] Add wait for job complete feture

Posted by GitBox <gi...@apache.org>.
Hisoka-X merged PR #2413:
URL: https://github.com/apache/incubator-seatunnel/pull/2413


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