DAGPlan dagPlan = dag.createDag(sessionConfig.getTezConfiguration());
SubmitDAGRequestProto requestProto =
SubmitDAGRequestProto.newBuilder().setDAGPlan(dagPlan).build();
DAGClientAMProtocolBlockingPB proxy;
long startTime = System.currentTimeMillis();
int timeout = sessionConfig.getTezConfiguration().getInt(
TezConfiguration.TEZ_SESSION_CLIENT_TIMEOUT_SECS,
TezConfiguration.TEZ_SESSION_CLIENT_TIMEOUT_SECS_DEFAULT);
long endTime = startTime + (timeout * 1000);
while (true) {
proxy = TezClientUtils.getSessionAMProxy(yarnClient,
sessionConfig.getYarnConfiguration(), applicationId);
if (proxy != null) {
break;
}
Thread.sleep(100l);
if (timeout != -1 && System.currentTimeMillis() > endTime) {
try {
LOG.warn("DAG submission to session timed out, stopping session");
stop();
} catch (Throwable t) {
LOG.info("Got an exception when trying to stop session", t);
}
throw new DAGSubmissionTimedOut("Could not submit DAG to Tez Session"
+ ", timed out after " + timeout + " seconds");
}
}
try {
dagId = proxy.submitDAG(null, requestProto).getDagId();
} catch (ServiceException e) {
throw new TezException(e);
}
LOG.info("Submitted dag to TezSession"
+ ", sessionName=" + sessionName