Search in sources :

Example 6 with FlowSpecification

use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.

the class FlowVerificationTest method testFlowWithMoreOutputThanWhatInputCanHandle.

@Test
public void testFlowWithMoreOutputThanWhatInputCanHandle() throws Exception {
    ApplicationSpecification appSpec = Specifications.from(new WebCrawlApp());
    ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
    ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
    FlowVerification flowSpec = new FlowVerification();
    for (Map.Entry<String, FlowSpecification> entry : newSpec.getFlows().entrySet()) {
        VerifyResult result = flowSpec.verify(new ApplicationId("test", newSpec.getName()), entry.getValue());
        // that is not connected to any input to flowlet CountByField.
        if (entry.getValue().getName().equals("WordCountFlow")) {
            Assert.assertTrue(result.getStatus() == VerifyResult.Status.FAILED);
        } else {
            Assert.assertTrue(result.getStatus() == VerifyResult.Status.SUCCESS);
        }
    }
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) WebCrawlApp(co.cask.cdap.WebCrawlApp) FlowSpecification(co.cask.cdap.api.flow.FlowSpecification) ApplicationSpecificationAdapter(co.cask.cdap.internal.app.ApplicationSpecificationAdapter) ReflectionSchemaGenerator(co.cask.cdap.internal.io.ReflectionSchemaGenerator) VerifyResult(co.cask.cdap.app.verification.VerifyResult) ApplicationId(co.cask.cdap.proto.id.ApplicationId) Map(java.util.Map) Test(org.junit.Test)

Example 7 with FlowSpecification

use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.

the class FlowletProgramRunner method createSchemaCache.

private SchemaCache createSchemaCache(Program program) throws Exception {
    ImmutableSet.Builder<Schema> schemas = ImmutableSet.builder();
    for (FlowSpecification flowSpec : program.getApplicationSpecification().getFlows().values()) {
        for (FlowletDefinition flowletDef : flowSpec.getFlowlets().values()) {
            schemas.addAll(Iterables.concat(flowletDef.getInputs().values()));
            schemas.addAll(Iterables.concat(flowletDef.getOutputs().values()));
        }
    }
    // Temp fix for ENG-3949. Always add old stream event schema.
    // TODO: Remove it later. The right thing to do is to have schemas history being stored to support schema
    // evolution. By design, as long as the schema cache is populated with old schema, the type projection logic
    // in the decoder would handle it correctly.
    schemas.add(schemaGenerator.generate(StreamEventData.class));
    return new SchemaCache(schemas.build(), program.getClassLoader());
}
Also used : FlowletDefinition(co.cask.cdap.api.flow.FlowletDefinition) ImmutableSet(com.google.common.collect.ImmutableSet) FlowSpecification(co.cask.cdap.api.flow.FlowSpecification) Schema(co.cask.cdap.api.data.schema.Schema) StreamEventData(co.cask.cdap.api.stream.StreamEventData)

Example 8 with FlowSpecification

use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.

the class DistributedFlowProgramRunner method validateOptions.

@Override
protected void validateOptions(Program program, ProgramOptions options) {
    super.validateOptions(program, options);
    FlowSpecification spec = program.getApplicationSpecification().getFlows().get(program.getName());
    for (String flowlet : spec.getFlowlets().keySet()) {
        SystemArguments.validateTransactionTimeout(options.getUserArguments().asMap(), cConf, "flowlet", flowlet);
    }
}
Also used : FlowSpecification(co.cask.cdap.api.flow.FlowSpecification)

Example 9 with FlowSpecification

use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.

the class DistributedFlowProgramRunner method getFlowSpecification.

private FlowSpecification getFlowSpecification(Program program) {
    // Extract and verify parameters
    ApplicationSpecification appSpec = program.getApplicationSpecification();
    Preconditions.checkNotNull(appSpec, "Missing application specification.");
    ProgramType processorType = program.getType();
    Preconditions.checkNotNull(processorType, "Missing processor type.");
    Preconditions.checkArgument(processorType == ProgramType.FLOW, "Only FLOW process type is supported.");
    FlowSpecification flowSpec = appSpec.getFlows().get(program.getName());
    Preconditions.checkNotNull(flowSpec, "Missing FlowSpecification for %s", program.getName());
    return flowSpec;
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) FlowSpecification(co.cask.cdap.api.flow.FlowSpecification) ProgramType(co.cask.cdap.proto.ProgramType)

Example 10 with FlowSpecification

use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.

the class DistributedFlowProgramRunner method createProgramController.

@Override
public ProgramController createProgramController(TwillController twillController, ProgramDescriptor programDescriptor, RunId runId) {
    FlowSpecification flowSpec = programDescriptor.getSpecification();
    DistributedFlowletInstanceUpdater instanceUpdater = new DistributedFlowletInstanceUpdater(programDescriptor.getProgramId(), twillController, queueAdmin, streamAdmin, getFlowletQueues(programDescriptor.getProgramId().getParent(), flowSpec), txExecutorFactory, impersonator);
    return new FlowTwillProgramController(programDescriptor.getProgramId(), twillController, instanceUpdater, runId).startListen();
}
Also used : FlowSpecification(co.cask.cdap.api.flow.FlowSpecification)

Aggregations

FlowSpecification (co.cask.cdap.api.flow.FlowSpecification)25 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)15 FlowletDefinition (co.cask.cdap.api.flow.FlowletDefinition)7 ApplicationId (co.cask.cdap.proto.id.ApplicationId)7 ProgramType (co.cask.cdap.proto.ProgramType)5 Test (org.junit.Test)4 VerifyResult (co.cask.cdap.app.verification.VerifyResult)3 ApplicationSpecificationAdapter (co.cask.cdap.internal.app.ApplicationSpecificationAdapter)3 ForwardingFlowSpecification (co.cask.cdap.internal.app.ForwardingFlowSpecification)3 ProgramId (co.cask.cdap.proto.id.ProgramId)3 WebCrawlApp (co.cask.cdap.WebCrawlApp)2 MapReduceSpecification (co.cask.cdap.api.mapreduce.MapReduceSpecification)2 ServiceSpecification (co.cask.cdap.api.service.ServiceSpecification)2 SparkSpecification (co.cask.cdap.api.spark.SparkSpecification)2 WorkflowSpecification (co.cask.cdap.api.workflow.WorkflowSpecification)2 ProgramController (co.cask.cdap.app.runtime.ProgramController)2 NotFoundException (co.cask.cdap.common.NotFoundException)2 QueueName (co.cask.cdap.common.queue.QueueName)2 ForwardingApplicationSpecification (co.cask.cdap.internal.app.ForwardingApplicationSpecification)2 SimpleQueueSpecificationGenerator (co.cask.cdap.internal.app.queue.SimpleQueueSpecificationGenerator)2