use of org.apache.tez.dag.api.SessionNotRunning in project tez by apache.
the class TestTezClient method testSubmitDAGAppFailed.
@Test(timeout = 5000)
public void testSubmitDAGAppFailed() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
client.callRealGetSessionAMProxy = true;
String msg = "Application Test Failed";
when(client.mockYarnClient.getApplicationReport(client.mockAppId).getYarnApplicationState()).thenReturn(YarnApplicationState.KILLED);
when(client.mockYarnClient.getApplicationReport(client.mockAppId).getDiagnostics()).thenReturn(msg);
Vertex vertex = Vertex.create("Vertex", ProcessorDescriptor.create("P"), 1, Resource.newInstance(1, 1));
DAG dag = DAG.create("DAG").addVertex(vertex);
try {
client.submitDAG(dag);
fail();
} catch (SessionNotRunning e) {
assertTrue(e.getMessage().contains(msg));
}
client.stop();
}
use of org.apache.tez.dag.api.SessionNotRunning in project tez by apache.
the class DAGAppMaster method submitDAGToAppMaster.
public String submitDAGToAppMaster(DAGPlan dagPlan, Map<String, LocalResource> additionalResources) throws TezException {
if (sessionStopped.get()) {
throw new SessionNotRunning("AM unable to accept new DAG submissions." + " In the process of shutting down");
}
// dag is in cleanup when dag state is completed but AM state is still RUNNING
synchronized (idleStateLock) {
while (currentDAG != null && currentDAG.isComplete() && state == DAGAppMasterState.RUNNING) {
try {
LOG.info("wait for previous dag cleanup");
idleStateLock.wait();
} catch (InterruptedException e) {
throw new TezException(e);
}
}
}
synchronized (this) {
if (this.versionMismatch) {
throw new TezException("Unable to accept DAG submissions as the ApplicationMaster is" + " incompatible with the client. " + versionMismatchDiagnostics);
}
if (state.equals(DAGAppMasterState.ERROR) || sessionStopped.get()) {
throw new SessionNotRunning("AM unable to accept new DAG submissions." + " In the process of shutting down");
}
if (currentDAG != null && !currentDAG.isComplete()) {
throw new TezException("App master already running a DAG");
}
// 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: " + dagPlan.getName());
if (LOG.isDebugEnabled()) {
LOG.debug("Invoked with additional local resources: " + additionalResources);
}
if (!dagPlan.getName().startsWith(TezConstants.TEZ_PREWARM_DAG_NAME_PREFIX)) {
submittedDAGs.incrementAndGet();
}
startDAG(dagPlan, additionalResources);
return currentDAG.getID().toString();
}
}
use of org.apache.tez.dag.api.SessionNotRunning in project hive by apache.
the class TestTezTask method testSubmitOnPoolSession.
@Test
public void testSubmitOnPoolSession() throws Exception {
DAG dag = DAG.create("test");
// Move session to TezSessionPool, reopen will handle it
SampleTezSessionState tezSessionPoolSession = mock(SampleTezSessionState.class);
TezClient tezClient = mock(TezClient.class);
when(tezSessionPoolSession.reopen()).thenThrow(new HiveException("Dag cannot be submitted"));
doNothing().when(tezSessionPoolSession).returnToSessionManager();
when(tezSessionPoolSession.getSession()).thenReturn(tezClient);
when(tezSessionPoolSession.isDefault()).thenReturn(true);
when(tezClient.submitDAG(any(DAG.class))).thenThrow(new SessionNotRunning(""));
boolean isException = false;
try {
task.submit(dag, Ref.from(tezSessionPoolSession));
} catch (Exception e) {
isException = true;
verify(tezClient, times(1)).submitDAG(any(DAG.class));
verify(tezSessionPoolSession, times(2)).reopen();
verify(tezSessionPoolSession, times(0)).destroy();
verify(tezSessionPoolSession, times(1)).returnToSessionManager();
}
assertTrue(isException);
}
use of org.apache.tez.dag.api.SessionNotRunning in project hive by apache.
the class TestTezTask method testSubmitOnNonPoolSession.
@Test
public void testSubmitOnNonPoolSession() throws Exception {
DAG dag = DAG.create("test");
// Destroy session incase of non-pool tez session
TezSessionState tezSessionState = mock(TezSessionState.class);
TezClient tezClient = mock(TezClient.class);
when(tezSessionState.reopen()).thenThrow(new HiveException("Dag cannot be submitted"));
when(tezSessionState.getSession()).thenReturn(tezClient);
when(tezClient.submitDAG(any(DAG.class))).thenThrow(new SessionNotRunning(""));
doNothing().when(tezSessionState).destroy();
boolean isException = false;
try {
task.submit(dag, Ref.from(tezSessionState));
} catch (Exception e) {
isException = true;
verify(tezClient, times(1)).submitDAG(any(DAG.class));
verify(tezSessionState, times(2)).reopen();
verify(tezSessionState, times(1)).destroy();
verify(tezSessionState, times(0)).returnToSessionManager();
}
assertTrue(isException);
}
use of org.apache.tez.dag.api.SessionNotRunning in project hive by apache.
the class TezTask method submit.
DAGClient submit(DAG dag, Ref<TezSessionState> sessionStateRef) throws Exception {
perfLogger.perfLogBegin(CLASS_NAME, PerfLogger.TEZ_SUBMIT_DAG);
DAGClient dagClient = null;
TezSessionState sessionState = sessionStateRef.value;
try {
try {
// ready to start execution on the cluster
dagClient = sessionState.getSession().submitDAG(dag);
} catch (SessionNotRunning nr) {
console.printInfo("Tez session was closed. Reopening...");
sessionStateRef.value = sessionState = getNewTezSessionOnError(sessionState);
console.printInfo("Session re-established.");
dagClient = sessionState.getSession().submitDAG(dag);
}
} catch (Exception e) {
if (this.isShutdown) {
// Incase of taskShutdown, no need to retry
sessionDestroyOrReturnToPool(sessionStateRef, sessionState);
throw e;
}
// In case of any other exception, retry. If this also fails, report original error and exit.
try {
console.printInfo("Dag submit failed due to " + e.getMessage() + " stack trace: " + Arrays.toString(e.getStackTrace()) + " retrying...");
sessionStateRef.value = sessionState = getNewTezSessionOnError(sessionState);
dagClient = sessionState.getSession().submitDAG(dag);
} catch (Exception retryException) {
// we failed to submit after retrying.
// If this is a non-pool session, destroy it.
// Otherwise move it to sessionPool, reopen will retry.
sessionDestroyOrReturnToPool(sessionStateRef, sessionState);
throw retryException;
}
}
perfLogger.perfLogEnd(CLASS_NAME, PerfLogger.TEZ_SUBMIT_DAG);
return new SyncDagClient(dagClient);
}
Aggregations