synchronized String submitDAGToAppMaster(DAGPlan dagPlan,
Map<String, LocalResource> additionalResources) throws TezException {
if(currentDAG != null
&& !state.equals(DAGAppMasterState.IDLE)) {
throw new TezException("App master already running a DAG");
}
if (state.equals(DAGAppMasterState.ERROR)
|| sessionStopped.get()) {
throw new TezException("AM unable to accept new DAG submissions."
+ " In the process of shutting down");
}
// RPC server runs in the context of the job user as it was started in
// the job user's UGI context
LOG.info("Starting DAG submitted via RPC");
if (LOG.isDebugEnabled()) {
LOG.debug("Invoked with additional local resources: " + additionalResources);
LOG.debug("Writing DAG plan to: "
+ TezConfiguration.TEZ_PB_PLAN_TEXT_NAME);
File outFile = new File(TezConfiguration.TEZ_PB_PLAN_TEXT_NAME);
try {
PrintWriter printWriter = new PrintWriter(outFile);
String dagPbString = dagPlan.toString();
printWriter.println(dagPbString);
printWriter.close();
} catch (IOException e) {
throw new TezException("Failed to write TEZ_PLAN to "
+ outFile.toString(), e);
}
}
submittedDAGs.incrementAndGet();