Hisoka-X commented on code in PR #2386: URL: https://github.com/apache/incubator-seatunnel/pull/2386#discussion_r944514706
########## seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/dag/PhysicalPlanTest.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.server.dag; + +import org.apache.seatunnel.connectors.seatunnel.console.sink.ConsoleSink; +import org.apache.seatunnel.connectors.seatunnel.fake.source.FakeSource; +import org.apache.seatunnel.engine.common.Constant; +import org.apache.seatunnel.engine.common.config.SeaTunnelConfig; +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 org.apache.seatunnel.engine.core.job.JobImmutableInformation; +import org.apache.seatunnel.engine.server.SeaTunnelNodeContext; +import org.apache.seatunnel.engine.server.dag.physical.PhysicalPlan; +import org.apache.seatunnel.engine.server.dag.physical.PhysicalPlanUtils; + +import com.hazelcast.config.Config; +import com.hazelcast.core.Hazelcast; +import com.hazelcast.instance.impl.HazelcastInstanceFactory; +import com.hazelcast.instance.impl.HazelcastInstanceImpl; +import com.hazelcast.instance.impl.HazelcastInstanceProxy; +import com.hazelcast.spi.impl.NodeEngine; +import org.junit.Assert; +import org.junit.Test; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.concurrent.Executors; + +public class PhysicalPlanTest { + + @Test + public void testLogicalToPhysical() throws MalformedURLException { + + HazelcastInstanceImpl instance = ((HazelcastInstanceProxy) HazelcastInstanceFactory.newHazelcastInstance(new Config(), Thread.currentThread().getName(), new SeaTunnelNodeContext(new SeaTunnelConfig()))).getOriginal(); + NodeEngine nodeEngine = instance.node.nodeEngine; + + IdGenerator idGenerator = new IdGenerator(); + + Action fake = new SourceAction<>(idGenerator.getNextId(), "fake", new FakeSource(), + Collections.singletonList(new URL("file:///fake.jar"))); Review Comment: I just for test, not use the jar path at now. ########## seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/SeaTunnelTask.java: ########## @@ -30,48 +50,95 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.UUID; -public class SeaTunnelTask extends AbstractTask { +public abstract class SeaTunnelTask extends AbstractTask { private static final long serialVersionUID = 2604309561613784425L; private final Flow executionFlow; - // TODO init memberID in task execution service - private UUID memberID = UUID.randomUUID(); - private int enumeratorTaskID = -1; + protected FlowLifeCycle startFlowLifeCycle; - public SeaTunnelTask(long taskID, Flow executionFlow) { - super(taskID); - // TODO add enumerator task ID - enumeratorTaskID = 1; + protected List<OneInputFlowLifeCycle<Record>> outputs; + + protected int indexID; + + private TaskGroup taskBelongGroup; + + public SeaTunnelTask(long jobID, TaskLocation taskID, int indexID, Flow executionFlow) { + super(jobID, taskID); + this.indexID = indexID; this.executionFlow = executionFlow; } @Override - public void init() { + public void init() throws Exception { + super.init(); + startFlowLifeCycle = convertFlowToActionLifeCycle(executionFlow); } - @Override - public void close() throws IOException { - super.close(); + public void setTaskGroup(TaskGroup group) { + this.taskBelongGroup = group; } - private void register() { - if (startFromSource()) { - this.executionContext.sendToMaster(new RegisterOperation(taskID, enumeratorTaskID)); + @SuppressWarnings({"unchecked", "rawtypes", "checkstyle:MagicNumber"}) + private FlowLifeCycle convertFlowToActionLifeCycle(Flow flow) throws Exception { Review Comment: Done ########## seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/serializable/TaskDataSerializerHook.java: ########## @@ -57,14 +73,24 @@ private static class Factory implements DataSerializableFactory { @Override public IdentifiedDataSerializable create(int typeId) { switch (typeId) { - case REGISTER_TYPE: - return new RegisterOperation(); + case SOURCE_REGISTER_TYPE: + return new SourceRegisterOperation(); case REQUEST_SPLIT_TYPE: return new RequestSplitOperation(); case ASSIGN_SPLIT_TYPE: - return new AssignSplitOperation(); + return new AssignSplitOperation<>(); case TASK_GROUP_INFO_TYPE: return new TaskGroupImmutableInformation(); + case SOURCE_UNREGISTER_TYPE: + return new SourceUnregisterOperation(); + case SINK_REGISTER_TYPE: + return new SinkRegisterOperation(); + case SINK_UNREGISTER_TYPE: + return new SinkUnregisterOperation(); + case TASK_LOCATION_TYPE: + return new TaskLocation(); + case PROGRESS_TYPE: + return new Progress(); default: return null; Review Comment: Done ########## seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/SimpleResourceManager.java: ########## @@ -44,7 +44,7 @@ public Address applyForResource(@NonNull Long jobId, @NonNull Long taskId) { } Address localhost = - jobAddressMap.putIfAbsent(taskId, new Address("localhost", 5801)); + jobAddressMap.putIfAbsent(taskId, new Address("192.168.2.1", 5701)); Review Comment: Sorry, I test it in local with my ip. Wrong commit. I removed 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
