Search in sources :

Example 6 with FlowTemplate

use of org.apache.gobblin.service.modules.template.FlowTemplate in project incubator-gobblin by apache.

the class ObservingFSFlowEdgeTemplateCatalog method getFlowTemplate.

@Override
public FlowTemplate getFlowTemplate(URI flowTemplateDirURI) throws SpecNotFoundException, JobTemplate.TemplateException, IOException, URISyntaxException {
    FlowTemplate flowTemplate = flowTemplateMap.getOrDefault(flowTemplateDirURI, null);
    if (flowTemplate == null) {
        flowTemplate = super.getFlowTemplate(flowTemplateDirURI);
        flowTemplateMap.put(flowTemplateDirURI, flowTemplate);
    }
    return flowTemplate;
}
Also used : FlowTemplate(org.apache.gobblin.service.modules.template.FlowTemplate)

Example 7 with FlowTemplate

use of org.apache.gobblin.service.modules.template.FlowTemplate in project incubator-gobblin by apache.

the class FlowGraphPath method convertHopToDag.

/**
 * Given an instance of {@link FlowEdge}, this method returns a {@link Dag < JobExecutionPlan >} that moves data
 * from the source of the {@link FlowEdge} to the destination of the {@link FlowEdge}.
 * @param flowEdgeContext an instance of {@link FlowEdgeContext}.
 * @param sysConfig environment config.
 * @return a {@link Dag} of {@link JobExecutionPlan}s associated with the {@link FlowEdge}.
 */
private Dag<JobExecutionPlan> convertHopToDag(FlowEdgeContext flowEdgeContext, Config sysConfig) throws SpecNotFoundException, JobTemplate.TemplateException, URISyntaxException {
    FlowTemplate flowTemplate = flowEdgeContext.getEdge().getFlowTemplate();
    DatasetDescriptor inputDatasetDescriptor = flowEdgeContext.getInputDatasetDescriptor();
    DatasetDescriptor outputDatasetDescriptor = flowEdgeContext.getOutputDatasetDescriptor();
    Config mergedConfig = flowEdgeContext.getMergedConfig();
    SpecExecutor specExecutor = flowEdgeContext.getSpecExecutor();
    // Get resolved job configs from the flow template
    List<Config> resolvedJobConfigs = flowTemplate.getResolvedJobConfigs(mergedConfig, inputDatasetDescriptor, outputDatasetDescriptor);
    List<JobExecutionPlan> jobExecutionPlans = new ArrayList<>(resolvedJobConfigs.size());
    Map<String, String> templateToJobNameMap = Maps.newHashMapWithExpectedSize(resolvedJobConfigs.size());
    // Iterate over each resolved job config and convert the config to a JobSpec.
    for (Config resolvedJobConfig : resolvedJobConfigs) {
        JobExecutionPlan jobExecutionPlan = new JobExecutionPlan.Factory().createPlan(flowSpec, resolvedJobConfig, specExecutor, flowExecutionId, sysConfig);
        jobExecutionPlans.add(jobExecutionPlan);
        templateToJobNameMap.put(getJobTemplateName(jobExecutionPlan), jobExecutionPlan.getJobSpec().getConfig().getString(ConfigurationKeys.JOB_NAME_KEY));
    }
    updateJobDependencies(jobExecutionPlans, templateToJobNameMap);
    return new JobExecutionPlanDagFactory().createDag(jobExecutionPlans);
}
Also used : FlowTemplate(org.apache.gobblin.service.modules.template.FlowTemplate) JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) DatasetDescriptor(org.apache.gobblin.service.modules.dataset.DatasetDescriptor) Config(com.typesafe.config.Config) ArrayList(java.util.ArrayList) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) JobExecutionPlanDagFactory(org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory)

Aggregations

FlowTemplate (org.apache.gobblin.service.modules.template.FlowTemplate)7 Config (com.typesafe.config.Config)5 URI (java.net.URI)5 Properties (java.util.Properties)3 ArrayList (java.util.ArrayList)2 JobTemplate (org.apache.gobblin.runtime.api.JobTemplate)2 Path (org.apache.hadoop.fs.Path)2 Test (org.testng.annotations.Test)2 Charsets (com.google.common.base.Charsets)1 Function (com.google.common.base.Function)1 ServiceManager (com.google.common.util.concurrent.ServiceManager)1 ConfigFactory (com.typesafe.config.ConfigFactory)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 URISyntaxException (java.net.URISyntaxException)1 Path (java.nio.file.Path)1 Arrays (java.util.Arrays)1 List (java.util.List)1