@Override
public FlowId addFlow(FlowSpecification spec) throws InterruptedException {
if (null != spec) {
// Turn the specification into a physical plan and run it.
FlowId flowId = new FlowId(mNextFlowId++);
UserSession userSession = getSessionForConf(spec.getConf());
LocalFlowBuilder flowBuilder = new LocalFlowBuilder(flowId, mRootSymbolTable,
mFlumeConfig, mMemoryOutputMap, userSession);
try {
spec.reverseBfs(flowBuilder);
} catch (DAGOperatorException doe) {
// An exception occurred when creating the physical plan.
// LocalFlowBuilder put a message for the user in here; print it
// without a stack trace. The flow cannot be executed.
userSession.sendErr(doe.getMessage());
return null;
}
LocalFlow localFlow = flowBuilder.getLocalFlow();
localFlow.setQuery(spec.getQuery());
localFlow.setConf(spec.getConf());