@Override
protected ProgramController launch(Program program, ProgramOptions options,
File hConfFile, File cConfFile, ApplicationLauncher launcher) {
// Extract and verify parameters
FlowSpecification flowSpec = program.getSpecification();
ProgramType processorType = program.getType();
Preconditions.checkNotNull(processorType, "Missing processor type.");
Preconditions.checkArgument(processorType == ProgramType.FLOW, "Only FLOW process type is supported.");
try {
Preconditions.checkNotNull(flowSpec, "Missing FlowSpecification for %s", program.getName());
for (FlowletDefinition flowletDefinition : flowSpec.getFlowlets().values()) {
int maxInstances = flowletDefinition.getFlowletSpec().getMaxInstances();
Preconditions.checkArgument(flowletDefinition.getInstances() <= maxInstances,
"Flowlet %s can have a maximum of %s instances",
flowletDefinition.getFlowletSpec().getName(), maxInstances);
}
LOG.info("Configuring flowlets queues");
Multimap<String, QueueName> flowletQueues = FlowUtils.configureQueue(program, flowSpec, queueAdmin);
// Launch flowlet program runners
LOG.info("Launching distributed flow: " + program.getName() + ":" + flowSpec.getName());
TwillController controller = launcher.launch(new FlowTwillApplication(program, flowSpec,
hConfFile, cConfFile, eventHandler));
DistributedFlowletInstanceUpdater instanceUpdater = new DistributedFlowletInstanceUpdater(program, controller,
queueAdmin,
flowletQueues);