Search in sources :

Example 1 with JobExecutionPlanDagFactory

use of org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory in project incubator-gobblin by apache.

the class DagTestUtils method buildDag.

/**
 * Create a {@link Dag < JobExecutionPlan >} with one parent and one child.
 * @return a Dag.
 */
public static Dag<JobExecutionPlan> buildDag(String id, Long flowExecutionId) throws URISyntaxException {
    List<JobExecutionPlan> jobExecutionPlans = new ArrayList<>();
    for (int i = 0; i < 2; i++) {
        String suffix = Integer.toString(i);
        Config jobConfig = ConfigBuilder.create().addPrimitive(ConfigurationKeys.FLOW_GROUP_KEY, "group" + id).addPrimitive(ConfigurationKeys.FLOW_NAME_KEY, "flow" + id).addPrimitive(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, flowExecutionId).addPrimitive(ConfigurationKeys.JOB_NAME_KEY, "job" + suffix).build();
        if (i > 0) {
            jobConfig = jobConfig.withValue(ConfigurationKeys.JOB_DEPENDENCIES, ConfigValueFactory.fromAnyRef("job" + (i - 1)));
        }
        JobSpec js = JobSpec.builder("test_job" + suffix).withVersion(suffix).withConfig(jobConfig).withTemplate(new URI("job" + suffix)).build();
        SpecExecutor specExecutor = buildNaiveTopologySpec("mySpecExecutor").getSpecExecutor();
        JobExecutionPlan jobExecutionPlan = new JobExecutionPlan(js, specExecutor);
        jobExecutionPlan.setExecutionStatus(ExecutionStatus.RUNNING);
        // Future of type CompletedFuture is used because in tests InMemorySpecProducer is used and that responds with CompletedFuture
        CompletedFuture future = new CompletedFuture<>(Boolean.TRUE, null);
        jobExecutionPlan.setJobFuture(Optional.of(future));
        jobExecutionPlans.add(jobExecutionPlan);
    }
    return new JobExecutionPlanDagFactory().createDag(jobExecutionPlans);
}
Also used : JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) Config(com.typesafe.config.Config) ArrayList(java.util.ArrayList) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) InMemorySpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.InMemorySpecExecutor) JobSpec(org.apache.gobblin.runtime.api.JobSpec) URI(java.net.URI) CompletedFuture(org.apache.gobblin.util.CompletedFuture) JobExecutionPlanDagFactory(org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory)

Example 2 with JobExecutionPlanDagFactory

use of org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory in project incubator-gobblin by apache.

the class FlowGraphPathTest method buildDag.

/**
 * A method to create a {@link Dag <JobExecutionPlan>}.
 * @return a Dag.
 */
public Dag<JobExecutionPlan> buildDag(int numNodes, int startNodeId, boolean isForkable) throws URISyntaxException {
    List<JobExecutionPlan> jobExecutionPlans = new ArrayList<>();
    Config baseConfig = ConfigBuilder.create().addPrimitive(ConfigurationKeys.FLOW_GROUP_KEY, "group0").addPrimitive(ConfigurationKeys.FLOW_NAME_KEY, "flow0").addPrimitive(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, System.currentTimeMillis()).addPrimitive(ConfigurationKeys.JOB_GROUP_KEY, "group0").build();
    for (int i = startNodeId; i < startNodeId + numNodes; i++) {
        String suffix = Integer.toString(i);
        Config jobConfig = baseConfig.withValue(ConfigurationKeys.JOB_NAME_KEY, ConfigValueFactory.fromAnyRef("job" + suffix));
        if (isForkable && (i == startNodeId + numNodes - 1)) {
            jobConfig = jobConfig.withValue(ConfigurationKeys.JOB_FORK_ON_CONCAT, ConfigValueFactory.fromAnyRef(true));
        }
        if (i > startNodeId) {
            jobConfig = jobConfig.withValue(ConfigurationKeys.JOB_DEPENDENCIES, ConfigValueFactory.fromAnyRef("job" + (i - 1)));
        }
        JobSpec js = JobSpec.builder("test_job" + suffix).withVersion(suffix).withConfig(jobConfig).withTemplate(new URI("job" + suffix)).build();
        SpecExecutor specExecutor = InMemorySpecExecutor.createDummySpecExecutor(new URI("job" + i));
        JobExecutionPlan jobExecutionPlan = new JobExecutionPlan(js, specExecutor);
        jobExecutionPlans.add(jobExecutionPlan);
    }
    return new JobExecutionPlanDagFactory().createDag(jobExecutionPlans);
}
Also used : JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) Config(com.typesafe.config.Config) ArrayList(java.util.ArrayList) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) InMemorySpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.InMemorySpecExecutor) JobSpec(org.apache.gobblin.runtime.api.JobSpec) URI(java.net.URI) JobExecutionPlanDagFactory(org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory)

Example 3 with JobExecutionPlanDagFactory

use of org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory in project incubator-gobblin by apache.

the class IdentityFlowToJobSpecCompiler method compileFlow.

@Override
public Dag<JobExecutionPlan> compileFlow(Spec spec) {
    Preconditions.checkNotNull(spec);
    Preconditions.checkArgument(spec instanceof FlowSpec, "IdentityFlowToJobSpecCompiler only converts FlowSpec to JobSpec");
    long startTime = System.nanoTime();
    FlowSpec flowSpec = (FlowSpec) spec;
    String source = flowSpec.getConfig().getString(ServiceConfigKeys.FLOW_SOURCE_IDENTIFIER_KEY);
    String destination = flowSpec.getConfig().getString(ServiceConfigKeys.FLOW_DESTINATION_IDENTIFIER_KEY);
    log.info(String.format("Compiling flow for source: %s and destination: %s", source, destination));
    JobSpec jobSpec = jobSpecGenerator(flowSpec);
    Instrumented.markMeter(this.flowCompilationSuccessFulMeter);
    Instrumented.updateTimer(this.flowCompilationTimer, System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
    List<JobExecutionPlan> jobExecutionPlans;
    try {
        jobExecutionPlans = getJobExecutionPlans(source, destination, jobSpec);
    } catch (InterruptedException | ExecutionException e) {
        Instrumented.markMeter(this.flowCompilationFailedMeter);
        throw new RuntimeException("Cannot determine topology capabilities", e);
    }
    return new JobExecutionPlanDagFactory().createDag(jobExecutionPlans);
}
Also used : JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) FlowSpec(org.apache.gobblin.runtime.api.FlowSpec) JobSpec(org.apache.gobblin.runtime.api.JobSpec) ExecutionException(java.util.concurrent.ExecutionException) JobExecutionPlanDagFactory(org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory)

Example 4 with JobExecutionPlanDagFactory

use of org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory in project incubator-gobblin by apache.

the class DagManagerTest method buildDag.

static Dag<JobExecutionPlan> buildDag(String id, Long flowExecutionId, String flowFailureOption, int numNodes) throws URISyntaxException {
    List<JobExecutionPlan> jobExecutionPlans = new ArrayList<>();
    for (int i = 0; i < numNodes; i++) {
        String suffix = Integer.toString(i);
        Config jobConfig = ConfigBuilder.create().addPrimitive(ConfigurationKeys.FLOW_GROUP_KEY, "group" + id).addPrimitive(ConfigurationKeys.FLOW_NAME_KEY, "flow" + id).addPrimitive(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, flowExecutionId).addPrimitive(ConfigurationKeys.JOB_GROUP_KEY, "group" + id).addPrimitive(ConfigurationKeys.JOB_NAME_KEY, "job" + suffix).addPrimitive(ConfigurationKeys.FLOW_FAILURE_OPTION, flowFailureOption).build();
        if ((i == 1) || (i == 2)) {
            jobConfig = jobConfig.withValue(ConfigurationKeys.JOB_DEPENDENCIES, ConfigValueFactory.fromAnyRef("job0"));
        } else if (i == 3) {
            jobConfig = jobConfig.withValue(ConfigurationKeys.JOB_DEPENDENCIES, ConfigValueFactory.fromAnyRef("job1"));
        } else if (i == 4) {
            jobConfig = jobConfig.withValue(ConfigurationKeys.JOB_DEPENDENCIES, ConfigValueFactory.fromAnyRef("job2"));
        }
        JobSpec js = JobSpec.builder("test_job" + suffix).withVersion(suffix).withConfig(jobConfig).withTemplate(new URI("job" + suffix)).build();
        SpecExecutor specExecutor = MockedSpecExecutor.createDummySpecExecutor(new URI("job" + i));
        JobExecutionPlan jobExecutionPlan = new JobExecutionPlan(js, specExecutor);
        jobExecutionPlans.add(jobExecutionPlan);
    }
    return new JobExecutionPlanDagFactory().createDag(jobExecutionPlans);
}
Also used : JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) Config(com.typesafe.config.Config) ArrayList(java.util.ArrayList) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) MockedSpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.MockedSpecExecutor) JobSpec(org.apache.gobblin.runtime.api.JobSpec) URI(java.net.URI) JobExecutionPlanDagFactory(org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory)

Example 5 with JobExecutionPlanDagFactory

use of org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory in project incubator-gobblin by apache.

the class DagManagerTest method testDagManagerWithBadFlowSLAConfig.

@Test(dependsOnMethods = "testJobStartSLAKilledDag")
public void testDagManagerWithBadFlowSLAConfig() throws URISyntaxException, IOException {
    long flowExecutionId = System.currentTimeMillis();
    String flowGroup = "group0";
    String flowName = "flow0";
    String jobName = "job0";
    // Create a config with an improperly formatted Flow SLA time e.g. "1h"
    Config jobConfig = ConfigBuilder.create().addPrimitive(ConfigurationKeys.FLOW_GROUP_KEY, "group" + flowGroup).addPrimitive(ConfigurationKeys.FLOW_NAME_KEY, "flow" + flowName).addPrimitive(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, flowExecutionId).addPrimitive(ConfigurationKeys.JOB_GROUP_KEY, flowGroup).addPrimitive(ConfigurationKeys.JOB_NAME_KEY, jobName).addPrimitive(ConfigurationKeys.FLOW_FAILURE_OPTION, "FINISH_RUNNING").addPrimitive(ConfigurationKeys.GOBBLIN_FLOW_SLA_TIME, "1h").build();
    List<JobExecutionPlan> jobExecutionPlans = new ArrayList<>();
    JobSpec js = JobSpec.builder("test_job" + jobName).withVersion("0").withConfig(jobConfig).withTemplate(new URI(jobName)).build();
    SpecExecutor specExecutor = MockedSpecExecutor.createDummySpecExecutor(new URI(jobName));
    JobExecutionPlan jobExecutionPlan = new JobExecutionPlan(js, specExecutor);
    jobExecutionPlans.add(jobExecutionPlan);
    Dag<JobExecutionPlan> dag = (new JobExecutionPlanDagFactory()).createDag(jobExecutionPlans);
    String dagId = DagManagerUtils.generateDagId(dag);
    // Add a dag to the queue of dags
    this.queue.offer(dag);
    // Job should have been run normally without breaking on SLA check, so we can just mark as completed for status
    Iterator<JobStatus> jobStatusIterator1 = getMockJobStatus(flowName, flowGroup, flowExecutionId + 1, jobName, flowGroup, String.valueOf(ExecutionStatus.COMPLETE));
    Mockito.when(_jobStatusRetriever.getJobStatusesForFlowExecution(Mockito.anyString(), Mockito.anyString(), Mockito.anyLong(), Mockito.anyString(), Mockito.anyString())).thenReturn(jobStatusIterator1);
    // Run the thread once. Job should run without crashing thread on SLA check and cleanup
    this._dagManagerThread.run();
    Assert.assertEquals(this.dags.size(), 0);
    Assert.assertEquals(this.jobToDag.size(), 0);
    Assert.assertEquals(this.dagToJobs.size(), 0);
}
Also used : JobExecutionPlan(org.apache.gobblin.service.modules.spec.JobExecutionPlan) Config(com.typesafe.config.Config) ArrayList(java.util.ArrayList) URI(java.net.URI) JobStatus(org.apache.gobblin.service.monitoring.JobStatus) SpecExecutor(org.apache.gobblin.runtime.api.SpecExecutor) MockedSpecExecutor(org.apache.gobblin.runtime.spec_executorInstance.MockedSpecExecutor) JobSpec(org.apache.gobblin.runtime.api.JobSpec) JobExecutionPlanDagFactory(org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory) Test(org.testng.annotations.Test)

Aggregations

JobExecutionPlan (org.apache.gobblin.service.modules.spec.JobExecutionPlan)7 JobExecutionPlanDagFactory (org.apache.gobblin.service.modules.spec.JobExecutionPlanDagFactory)7 ArrayList (java.util.ArrayList)6 JobSpec (org.apache.gobblin.runtime.api.JobSpec)6 Config (com.typesafe.config.Config)5 SpecExecutor (org.apache.gobblin.runtime.api.SpecExecutor)5 URI (java.net.URI)4 InMemorySpecExecutor (org.apache.gobblin.runtime.spec_executorInstance.InMemorySpecExecutor)3 FlowSpec (org.apache.gobblin.runtime.api.FlowSpec)2 MockedSpecExecutor (org.apache.gobblin.runtime.spec_executorInstance.MockedSpecExecutor)2 Properties (java.util.Properties)1 ExecutionException (java.util.concurrent.ExecutionException)1 DatasetDescriptor (org.apache.gobblin.service.modules.dataset.DatasetDescriptor)1 FlowTemplate (org.apache.gobblin.service.modules.template.FlowTemplate)1 JobStatus (org.apache.gobblin.service.monitoring.JobStatus)1 CompletedFuture (org.apache.gobblin.util.CompletedFuture)1 Test (org.testng.annotations.Test)1