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/21 10:07:14 UTC

[GitHub] [incubator-seatunnel] hailin0 commented on a diff in pull request #2478: [engine][checkpoint] checkpoint base classes

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


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CompletedCheckpoint.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.checkpoint;
+
+import org.apache.seatunnel.engine.core.checkpoint.Checkpoint;
+
+import java.io.Serializable;
+import java.util.Map;
+
+public class CompletedCheckpoint implements Checkpoint, Serializable {
+    private static final long serialVersionUID = 1L;
+    private final long jobId;
+
+    private final long pipelineId;
+
+    private final long checkpointId;
+
+    private final long triggerTimestamp;
+
+    private final long completedTimestamp;
+
+    private final Map<Long, TaskState> taskStates;
+
+    public CompletedCheckpoint(long jobId,
+                             long pipelineId,
+                             long checkpointId,
+                             long triggerTimestamp,
+                             long completedTimestamp,
+                             Map<Long, TaskState> taskStates) {
+        this.jobId = jobId;
+        this.pipelineId = pipelineId;
+        this.checkpointId = checkpointId;
+        this.triggerTimestamp = triggerTimestamp;
+        this.completedTimestamp = completedTimestamp;
+        this.taskStates = taskStates;
+    }
+
+    @Override
+    public long getCheckpointId() {
+        return this.checkpointId;
+    }
+
+    @Override
+    public long getPipelineId() {

Review Comment:
   as above



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointCoordinatorConfiguration.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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.checkpoint;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+public class CheckpointCoordinatorConfiguration implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    public static final long MINIMAL_CHECKPOINT_TIME = 10;
+
+    private final long checkpointInterval;
+
+    private final long checkpointTimeout;
+
+    private final int maxConcurrentCheckpoints;
+
+    private final int tolerableFailureCheckpoints;
+
+    private CheckpointCoordinatorConfiguration(long checkpointInterval,
+                                               long checkpointTimeout,
+                                               int maxConcurrentCheckpoints,
+                                               int tolerableFailureCheckpoints) {
+        this.checkpointInterval = checkpointInterval;
+        this.checkpointTimeout = checkpointTimeout;
+        this.maxConcurrentCheckpoints = maxConcurrentCheckpoints;
+        this.tolerableFailureCheckpoints = tolerableFailureCheckpoints;
+    }
+
+    public long getCheckpointInterval() {
+        return checkpointInterval;
+    }
+
+    public long getCheckpointTimeout() {
+        return checkpointTimeout;
+    }
+
+    public int getMaxConcurrentCheckpoints() {
+        return maxConcurrentCheckpoints;
+    }
+
+    public int getTolerableFailureCheckpoints() {
+        return tolerableFailureCheckpoints;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        CheckpointCoordinatorConfiguration that = (CheckpointCoordinatorConfiguration) o;
+        return checkpointInterval == that.checkpointInterval
+            && checkpointTimeout == that.checkpointTimeout
+            && maxConcurrentCheckpoints == that.maxConcurrentCheckpoints
+            && tolerableFailureCheckpoints == that.tolerableFailureCheckpoints;
+    }
+
+    @Override
+    public int hashCode() {

Review Comment:
   Why not use lombok annotations to generate code?



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/operation/CheckpointAckOperation.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.operation;
+
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.checkpoint.CheckpointBarrier;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.checkpoint.CheckpointCoordinator;
+import org.apache.seatunnel.engine.server.execution.TaskInfo;
+import org.apache.seatunnel.engine.server.serializable.OperationDataSerializerHook;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+
+import java.io.IOException;
+
+public class CheckpointAckOperation extends AsyncOperation {
+    private TaskInfo taskInfo;
+
+    private byte[] states;
+
+    public CheckpointAckOperation() {
+    }
+
+    public CheckpointAckOperation(TaskInfo taskInfo, byte[] states) {
+        this.taskInfo = taskInfo;
+        this.states = states;
+    }
+
+    @Override
+    public int getClassId() {
+        return OperationDataSerializerHook.SUBMIT_OPERATOR;
+    }
+
+    @Override
+    protected void writeInternal(ObjectDataOutput out) throws IOException {
+        out.writeObject(taskInfo);
+        out.writeByteArray(states);
+    }
+
+    @Override
+    protected void readInternal(ObjectDataInput in) throws IOException {
+        taskInfo = in.readObject(CheckpointBarrier.class);

Review Comment:
   Use TaskInfo.class?  
   TaskInfo need to implement the Serializable interface?



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/operation/TaskCompletedOperation.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.operation;
+
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.checkpoint.CheckpointBarrier;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.checkpoint.CheckpointCoordinator;
+import org.apache.seatunnel.engine.server.execution.TaskInfo;
+import org.apache.seatunnel.engine.server.serializable.OperationDataSerializerHook;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+
+import java.io.IOException;
+
+public class TaskCompletedOperation extends AsyncOperation {
+    private TaskInfo taskInfo;
+
+    public TaskCompletedOperation() {
+    }
+
+    public TaskCompletedOperation(TaskInfo taskInfo) {
+        this.taskInfo = taskInfo;
+    }
+
+    @Override
+    public int getClassId() {
+        return OperationDataSerializerHook.SUBMIT_OPERATOR;
+    }
+
+    @Override
+    protected void writeInternal(ObjectDataOutput out) throws IOException {
+        out.writeObject(taskInfo);
+    }
+
+    @Override
+    protected void readInternal(ObjectDataInput in) throws IOException {
+        taskInfo = in.readObject(CheckpointBarrier.class);

Review Comment:
   Use TaskInfo.class ?



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