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);
}
}
}
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());
}
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);
}
}
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;
}
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();
}
Aggregations