use of co.cask.cdap.internal.specification.OutputEmitterFieldExtractor in project cdap by caskdata.
the class DefaultFlowConfigurer method addFlowlet.
@Override
public void addFlowlet(String name, Flowlet flowlet, int instances) {
Preconditions.checkNotNull(flowlet, UserMessages.getMessage(UserErrors.INVALID_FLOWLET_NULL));
DefaultFlowletConfigurer flowletConfigurer = new DefaultFlowletConfigurer(flowlet);
flowlet.configure(flowletConfigurer);
FlowletSpecification flowletSpecification = flowletConfigurer.createSpecification();
Map<String, Set<Type>> inputTypes = new HashMap<>();
Map<String, Set<Type>> outputTypes = new HashMap<>();
Reflections.visit(flowlet, flowlet.getClass(), new OutputEmitterFieldExtractor(outputTypes), new ProcessMethodExtractor(inputTypes));
FlowletDefinition flowletDef = new FlowletDefinition(name, inputTypes, outputTypes, flowletSpecification, instances);
String flowletName = flowletDef.getFlowletSpec().getName();
Preconditions.checkArgument(instances > 0, String.format(UserMessages.getMessage(UserErrors.INVALID_INSTANCES), flowletName, instances));
Preconditions.checkArgument(!flowlets.containsKey(flowletName), UserMessages.getMessage(UserErrors.INVALID_FLOWLET_EXISTS), flowletName);
flowlets.put(flowletName, flowletDef);
addStreams(flowletConfigurer.getStreams());
addDatasetSpecs(flowletConfigurer.getDatasetSpecs());
addDatasetModules(flowletConfigurer.getDatasetModules());
}
Aggregations