Search in sources :

Example 6 with DagNode

use of org.apache.gobblin.service.modules.flowgraph.Dag.DagNode in project incubator-gobblin by apache.

the class FlowGraphPath method concatenate.

/**
 * Concatenate two {@link Dag}s. Modify the {@link ConfigurationKeys#JOB_DEPENDENCIES} in the {@link JobSpec}s of the child
 * {@link Dag} to reflect the concatenation operation.
 * @param dagLeft The parent dag.
 * @param dagRight The child dag.
 * @return The concatenated dag with modified {@link ConfigurationKeys#JOB_DEPENDENCIES}.
 */
@VisibleForTesting
static Dag<JobExecutionPlan> concatenate(Dag<JobExecutionPlan> dagLeft, Dag<JobExecutionPlan> dagRight) {
    // Compute the fork nodes - set of nodes with no dependents in the concatenated dag.
    Set<DagNode<JobExecutionPlan>> forkNodes = dagLeft.getEndNodes().stream().filter(endNode -> isNodeForkable(endNode)).collect(Collectors.toSet());
    Set<DagNode<JobExecutionPlan>> dependencyNodes = dagLeft.getDependencyNodes(forkNodes);
    if (!dependencyNodes.isEmpty()) {
        List<String> dependenciesList = dependencyNodes.stream().map(dagNode -> dagNode.getValue().getJobSpec().getConfig().getString(ConfigurationKeys.JOB_NAME_KEY)).collect(Collectors.toList());
        String dependencies = Joiner.on(",").join(dependenciesList);
        for (DagNode<JobExecutionPlan> childNode : dagRight.getStartNodes()) {
            JobSpec jobSpec = childNode.getValue().getJobSpec();
            jobSpec.setConfig(jobSpec.getConfig().withValue(ConfigurationKeys.JOB_DEPENDENCIES, ConfigValueFactory.fromAnyRef(dependencies)));
        }
    }
    return dagLeft.concatenate(dagRight, forkNodes);
}
Also used : JobExecutionPlanDagFactory(org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory) Getter(lombok.Getter) FlowTemplate(org.apache.gobblin.service.modules.template.FlowTemplate) URISyntaxException(java.net.URISyntaxException) ConfigValueFactory(com.typesafe.config.ConfigValueFactory) ConfigUtils(org.apache.gobblin.util.ConfigUtils) ArrayList(java.util.ArrayList) DatasetDescriptor(org.apache.gobblin.service.modules.dataset.DatasetDescriptor) JobSpec(org.apache.gobblin.runtime.api.JobSpec) Files(com.google.common.io.Files) Optional(com.google.common.base.Optional) Map(java.util.Map) Path(org.apache.hadoop.fs.Path) JobTemplate(org.apache.gobblin.runtime.api.JobTemplate) URI(java.net.URI) FlowEdge(org.apache.gobblin.service.modules.flowgraph.FlowEdge) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) Iterator(java.util.Iterator) Dag(org.apache.gobblin.service.modules.flowgraph.Dag) Config(com.typesafe.config.Config) Set(java.util.Set) ConfigurationKeys(org.apache.gobblin.configuration.ConfigurationKeys) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) SpecNotFoundException(org.apache.gobblin.runtime.api.SpecNotFoundException) List(java.util.List) DagNode(org.apache.gobblin.service.modules.flowgraph.Dag.DagNode) VisibleForTesting(com.google.common.annotations.VisibleForTesting) JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) Joiner(com.google.common.base.Joiner) FlowSpec(org.apache.gobblin.runtime.api.FlowSpec) DagNode(org.apache.gobblin.service.modules.flowgraph.Dag.DagNode) JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) JobSpec(org.apache.gobblin.runtime.api.JobSpec) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

DagNode (org.apache.gobblin.service.modules.flowgraph.Dag.DagNode)6 HashSet (java.util.HashSet)5 JobExecutionPlan (org.apache.gobblin.service.modules.spec.JobExecutionPlan)5 Config (com.typesafe.config.Config)4 FlowSpec (org.apache.gobblin.runtime.api.FlowSpec)3 Test (org.testng.annotations.Test)3 ArrayList (java.util.ArrayList)2 Dag (org.apache.gobblin.service.modules.flowgraph.Dag)2 AzkabanProjectConfig (org.apache.gobblin.service.modules.orchestration.AzkabanProjectConfig)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Joiner (com.google.common.base.Joiner)1 Optional (com.google.common.base.Optional)1 Maps (com.google.common.collect.Maps)1 Files (com.google.common.io.Files)1 ConfigValueFactory (com.typesafe.config.ConfigValueFactory)1 File (java.io.File)1 Field (java.lang.reflect.Field)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1