umustafi commented on code in PR #3825: URL: https://github.com/apache/gobblin/pull/3825#discussion_r1441067703
########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagProcFactory.java: ########## @@ -0,0 +1,104 @@ +/* + * 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 com.google.inject.Singleton; +import com.typesafe.config.ConfigFactory; + +import lombok.extern.slf4j.Slf4j; + +import org.apache.gobblin.annotation.Alpha; +import org.apache.gobblin.instrumented.Instrumented; +import org.apache.gobblin.metrics.MetricContext; +import org.apache.gobblin.metrics.event.EventSubmitter; +import org.apache.gobblin.service.modules.orchestration.proc.AdvanceDagProc; +import org.apache.gobblin.service.modules.orchestration.proc.CleanUpDagProc; +import org.apache.gobblin.service.modules.orchestration.proc.DagProc; +import org.apache.gobblin.service.modules.orchestration.proc.KillDagProc; +import org.apache.gobblin.service.modules.orchestration.proc.LaunchDagProc; +import org.apache.gobblin.service.modules.orchestration.proc.ReloadDagProc; +import org.apache.gobblin.service.modules.orchestration.proc.ResumeDagProc; +import org.apache.gobblin.service.modules.orchestration.proc.RetryDagProc; +import org.apache.gobblin.service.modules.orchestration.task.AdvanceDagTask; +import org.apache.gobblin.service.modules.orchestration.task.CleanUpDagTask; +import org.apache.gobblin.service.modules.orchestration.task.DagTask; +import org.apache.gobblin.service.modules.orchestration.task.KillDagTask; +import org.apache.gobblin.service.modules.orchestration.task.LaunchDagTask; +import org.apache.gobblin.service.modules.orchestration.task.ReloadDagTask; +import org.apache.gobblin.service.modules.orchestration.task.ResumeDagTask; +import org.apache.gobblin.service.modules.orchestration.task.RetryDagTask; +import org.apache.gobblin.util.ConfigUtils; + + +/** + * Factory for creating {@link DagProc} based on the visitor type for a given {@link DagTask}. + */ + +@Alpha +@Slf4j +@Singleton +public class DagProcFactory implements DagTaskVisitor { + Optional<EventSubmitter> eventSubmitter; + + public DagProcFactory(boolean instrumentationEnabled) { + if (instrumentationEnabled) { + MetricContext metricContext = Instrumented.getMetricContext(ConfigUtils.configToState(ConfigFactory.empty()), getClass()); + this.eventSubmitter = Optional.of(new EventSubmitter.Builder(metricContext, "org.apache.gobblin.service").build()); + } else { + this.eventSubmitter = Optional.empty(); + } + } + + @Override + public DagProc meet(LaunchDagTask launchDagTask, DagProcessingEngine dagProcessingEngine) { + return new LaunchDagProc(launchDagTask, dagProcessingEngine); + } + + @Override + public DagProc meet(KillDagTask killDagTask, DagProcessingEngine dagProcessingEngine) { + return new KillDagProc(killDagTask, dagProcessingEngine); + } + + @Override + public Object meet(ReloadDagTask reloadDagTask, DagProcessingEngine dagProcessingEngine) { + return new ReloadDagProc(reloadDagTask, dagProcessingEngine); + } Review Comment: can we get rid of this one after previous discussion about no need to reload preemptively? we only access dagStateStore at time of execution ########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagTaskStream.java: ########## @@ -0,0 +1,112 @@ +/* + * 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 java.util.Iterator; +import java.util.Properties; +import java.util.concurrent.BlockingQueue; + +import com.google.common.base.Optional; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import org.apache.gobblin.annotation.Alpha; +import org.apache.gobblin.runtime.api.DagActionStore; +import org.apache.gobblin.runtime.api.MultiActiveLeaseArbiter; +import org.apache.gobblin.service.modules.flowgraph.Dag; +import org.apache.gobblin.service.modules.orchestration.task.DagTask; +import org.apache.gobblin.service.modules.orchestration.task.KillDagTask; +import org.apache.gobblin.service.modules.spec.JobExecutionPlan; + + +/** + * Holds a stream of {@link DagTask}s that {@link DagProcessingEngine} would pull from for processing. + * It provides an implementation for {@link DagManagement} that defines the rules for a flow and job. + * Implements {@link Iterable} to provide {@link DagTask}s as soon as it's available to {@link DagProcessingEngine} + */ + +@Alpha +@Slf4j +@AllArgsConstructor +// change to iterable +public class DagTaskStream implements Iterator<DagTask>{ Review Comment: the java doc mentions implementing `DagManagement` but after recent convo and seeing` NewDagManager` is the one to implement the code looks fine but update ja ########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagManagement.java: ########## @@ -0,0 +1,40 @@ +/* + * 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 java.util.Map; +import java.util.Set; + +import org.apache.gobblin.runtime.api.DagActionStore; +import org.apache.gobblin.service.modules.flowgraph.Dag; +import org.apache.gobblin.service.modules.spec.JobExecutionPlan; +import org.apache.gobblin.service.monitoring.KillFlowEvent; +import org.apache.gobblin.service.monitoring.ResumeFlowEvent; +import org.apache.gobblin.service.monitoring.event.JobStatusEvent; + + +public interface DagManagement { Review Comment: shouldn't we have a method to handle a launch? ########## gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/proc/ReloadDagProc.java: ########## @@ -0,0 +1,164 @@ +/* + * 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.proc; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Future; + +import com.google.common.base.Optional; +import com.google.common.collect.Maps; + +import lombok.extern.slf4j.Slf4j; + +import org.apache.gobblin.annotation.Alpha; +import org.apache.gobblin.metrics.event.TimingEvent; +import org.apache.gobblin.runtime.api.JobSpec; +import org.apache.gobblin.runtime.api.Spec; +import org.apache.gobblin.runtime.api.SpecProducer; +import org.apache.gobblin.service.modules.flowgraph.Dag; +import org.apache.gobblin.service.modules.orchestration.DagManagerUtils; +import org.apache.gobblin.service.modules.orchestration.DagProcFactory; +import org.apache.gobblin.service.modules.orchestration.TimingEventUtils; +import org.apache.gobblin.service.modules.orchestration.task.ReloadDagTask; +import org.apache.gobblin.service.modules.spec.JobExecutionPlan; + +import static org.apache.gobblin.service.ExecutionStatus.RUNNING; + + +/** + * An implementation of {@link DagProc} for launching {@link org.apache.gobblin.service.modules.orchestration.task.DagTask}. + */ +@Slf4j +@Alpha +// todo - maybe reload need different treatment from other operations, because these are already present in the dag store Review Comment: do we still need this? what is loading here? every time we start up we only need to initialize the scheduler then the scheduler should take care of triggering launch tasks. or if there are unfinished tasks in the dagActionStore those will be separately dealt with by the startup sequence. -- 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]
