phet commented on code in PR #3776: URL: https://github.com/apache/gobblin/pull/3776#discussion_r1329391204
########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/NewDagManagerBoilerPlate.java: ########## @@ -0,0 +1,74 @@ +/* + * 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.gobblin.service.modules.orchestration; + + +import java.util.Optional; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import org.apache.gobblin.annotation.Alpha; +import org.apache.gobblin.runtime.api.MultiActiveLeaseArbiter; + + +@Alpha +@Slf4j +@AllArgsConstructor +public class NewDagManagerBoilerPlate { + private DagTaskStream dagTaskStream; + private DagProcFactory dagProcFactory; + private DagManager.DagManagerThread [] dagManagerThreads; + private MultiActiveLeaseArbiter multiActiveLeaseArbiter; + //TODO instantiate DMT + + @AllArgsConstructor + public static class DagManagerThread implements Runnable { + private DagTaskStream dagTaskStream; + private DagProcFactory dagProcFactory; + + private MultiActiveLeaseArbiter multiActiveLeaseArbiter; + @Override + public void run() { + try { + while (dagTaskStream.hasNext()) { Review Comment: tip: if `DagTaskStream` were to implement `Iterable<T>`, rather than `Iterator<T>`, it could be used in a "foreach" loop: ``` for (DagTask task : dagTaskStream) { ... } ``` ########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/NewDagManagerBoilerPlate.java: ########## @@ -0,0 +1,74 @@ +/* + * 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.gobblin.service.modules.orchestration; + + +import java.util.Optional; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import org.apache.gobblin.annotation.Alpha; +import org.apache.gobblin.runtime.api.MultiActiveLeaseArbiter; + + +@Alpha +@Slf4j +@AllArgsConstructor +public class NewDagManagerBoilerPlate { + private DagTaskStream dagTaskStream; + private DagProcFactory dagProcFactory; + private DagManager.DagManagerThread [] dagManagerThreads; + private MultiActiveLeaseArbiter multiActiveLeaseArbiter; + //TODO instantiate DMT + + @AllArgsConstructor + public static class DagManagerThread implements Runnable { Review Comment: this class probably needn't be `public`, since I don't expect to find use outside the enclosing one. also no need to recapitulate the parent's name in this one's. I'm thinking: ``` private static class Thread implements Runnable ``` does that work? ########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/NewDagManagerBoilerPlate.java: ########## @@ -0,0 +1,74 @@ +/* + * 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.gobblin.service.modules.orchestration; + + +import java.util.Optional; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import org.apache.gobblin.annotation.Alpha; +import org.apache.gobblin.runtime.api.MultiActiveLeaseArbiter; + + +@Alpha +@Slf4j +@AllArgsConstructor +public class NewDagManagerBoilerPlate { Review Comment: suggestion for name: `DagProcEngine` ########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/NewDagManagerBoilerPlate.java: ########## @@ -0,0 +1,74 @@ +/* + * 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.gobblin.service.modules.orchestration; + + +import java.util.Optional; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import org.apache.gobblin.annotation.Alpha; +import org.apache.gobblin.runtime.api.MultiActiveLeaseArbiter; + + +@Alpha +@Slf4j +@AllArgsConstructor +public class NewDagManagerBoilerPlate { + private DagTaskStream dagTaskStream; + private DagProcFactory dagProcFactory; + private DagManager.DagManagerThread [] dagManagerThreads; + private MultiActiveLeaseArbiter multiActiveLeaseArbiter; + //TODO instantiate DMT Review Comment: yes, exactly, let's have a ctor that takes in `DagManagementStateStore` as well as other params (such as how many threads) and then constructs the threads. ########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagTaskVisitor.java: ########## @@ -0,0 +1,33 @@ +/* + * 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.gobblin.service.modules.orchestration; + +import java.io.IOException; + + +/** + * Interface defining {@link DagTask} based on the type of visitor. + * @param <T> + */ +@WorkInProgress +public interface DagTaskVisitor<T> { + T meet(LaunchDagTask launchDagTask) + throws IOException, InstantiationException, IllegalAccessException; + T meet(KillDagTask killDagTask) throws IOException; Review Comment: ping on this one ########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/LaunchDagTask.java: ########## @@ -0,0 +1,62 @@ +/* + * 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.gobblin.service.modules.orchestration; + +import java.io.IOException; + +import org.apache.gobblin.annotation.Alpha; +import org.apache.gobblin.runtime.api.DagActionStore; +import org.apache.gobblin.service.modules.flowgraph.Dag; +import org.apache.gobblin.service.modules.spec.JobExecutionPlan; + + +/** + * A {@link DagTask} responsible to handle launch tasks. + */ +@Alpha +public class LaunchDagTask extends DagTask { + String flowGroup; + String flowName; + + String flowExecutionId; + + public LaunchDagTask(String flowGroup, String flowName, String flowExecutionId) { + this.flowGroup = flowGroup; + this.flowName = flowName; + this.flowExecutionId = flowExecutionId; + } + + /** + * initializes the job properties associated with a {@link DagTask} + * @param dag + * @param triggerTimeStamp + */ + @Override + void initialize(Object dag, long triggerTimeStamp) { + Dag<JobExecutionPlan> launchDag = (Dag<JobExecutionPlan>) dag; + this.flowAction = new DagActionStore.DagAction(flowGroup, flowName, flowExecutionId, DagActionStore.FlowActionType.LAUNCH); + this.jobProps = launchDag.getStartNodes().get(0).getValue().getJobSpec().getConfigAsProperties(); + this.triggerTimeStamp = triggerTimeStamp; + } + + @Override + LaunchDagProc host(DagTaskVisitor visitor) throws IOException, InstantiationException, IllegalAccessException { + + return (LaunchDagProc) visitor.meet(this); + } Review Comment: where does the need arise for an impl of this method to return the specific type of the `DagProc`? the cast should not be necessary. and do keep in mind that `DagTaskVisitor<T>` is a generic, hence: ``` @Override <T> T host(DagTaskVisitor<T> visitor) { return visitor.meet(this); } ``` -- 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]
