Search in sources :

Example 6 with SessionNotRunning

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();
}
Also used : Vertex(org.apache.tez.dag.api.Vertex) PreWarmVertex(org.apache.tez.dag.api.PreWarmVertex) SessionNotRunning(org.apache.tez.dag.api.SessionNotRunning) DAG(org.apache.tez.dag.api.DAG) Test(org.junit.Test)

Example 7 with SessionNotRunning

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();
    }
}
Also used : TezException(org.apache.tez.dag.api.TezException) SessionNotRunning(org.apache.tez.dag.api.SessionNotRunning)

Example 8 with SessionNotRunning

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);
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) SessionNotRunning(org.apache.tez.dag.api.SessionNotRunning) DAG(org.apache.tez.dag.api.DAG) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) IOException(java.io.IOException) TezClient(org.apache.tez.client.TezClient) Test(org.junit.Test)

Example 9 with SessionNotRunning

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);
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) SessionNotRunning(org.apache.tez.dag.api.SessionNotRunning) DAG(org.apache.tez.dag.api.DAG) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) IOException(java.io.IOException) TezClient(org.apache.tez.client.TezClient) Test(org.junit.Test)

Example 10 with SessionNotRunning

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);
}
Also used : SessionNotRunning(org.apache.tez.dag.api.SessionNotRunning) DAGClient(org.apache.tez.dag.api.client.DAGClient) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) IOException(java.io.IOException) TezException(org.apache.tez.dag.api.TezException)

Aggregations

SessionNotRunning (org.apache.tez.dag.api.SessionNotRunning)10 TezException (org.apache.tez.dag.api.TezException)6 IOException (java.io.IOException)5 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)5 DAGClient (org.apache.tez.dag.api.client.DAGClient)4 Test (org.junit.Test)4 TezClient (org.apache.tez.client.TezClient)3 DAG (org.apache.tez.dag.api.DAG)3 LinkedHashMap (java.util.LinkedHashMap)2 Path (org.apache.hadoop.fs.Path)2 Vertex (org.apache.tez.dag.api.Vertex)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 QueryPlan (org.apache.hadoop.hive.ql.QueryPlan)1 Operator (org.apache.hadoop.hive.ql.exec.Operator)1 BaseWork (org.apache.hadoop.hive.ql.plan.BaseWork)1 MapWork (org.apache.hadoop.hive.ql.plan.MapWork)1