Search in sources :

Example 16 with DAG

use of org.apache.tez.dag.app.dag.DAG in project tez by apache.

the class TestHistoryEventHandler method createHandler.

private HistoryEventHandler createHandler(HistoryLogLevel logLevel) {
    Configuration conf = new Configuration(baseConfig);
    conf.setBoolean(TezConfiguration.DAG_RECOVERY_ENABLED, false);
    conf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, InMemoryHistoryLoggingService.class.getName());
    if (logLevel != null) {
        conf.setEnum(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, logLevel);
    }
    DAG dag = mock(DAG.class);
    when(dag.getConf()).thenReturn(conf);
    AppContext appContext = mock(AppContext.class);
    when(appContext.getApplicationID()).thenReturn(appId);
    when(appContext.getHadoopShim()).thenReturn(new HadoopShim() {
    });
    when(appContext.getAMConf()).thenReturn(conf);
    when(appContext.getCurrentDAG()).thenReturn(dag);
    HistoryEventHandler handler = new HistoryEventHandler(appContext);
    handler.init(conf);
    return handler;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) HadoopShim(org.apache.tez.hadoop.shim.HadoopShim) AppContext(org.apache.tez.dag.app.AppContext) DAG(org.apache.tez.dag.app.dag.DAG)

Example 17 with DAG

use of org.apache.tez.dag.app.dag.DAG in project tez by apache.

the class Utils method processNonFatalServiceErrorReport.

public static void processNonFatalServiceErrorReport(String entityString, ServicePluginError servicePluginError, String diagnostics, DagInfo dagInfo, AppContext appContext, String componentName) {
    String message = "Error reported by " + componentName + " [" + entityString + "][" + servicePluginError + "] " + (diagnostics == null ? "" : diagnostics);
    if (dagInfo != null) {
        DAG dag = appContext.getCurrentDAG();
        if (dag != null && dag.getID().getId() == dagInfo.getIndex()) {
            TezDAGID dagId = dag.getID();
            // Send a kill message only if it is the same dag.
            LOG.warn(message + ", Failing dag: [" + dagInfo.getName() + ", " + dagId + "]");
            sendEvent(appContext, new DAGEventTerminateDag(dagId, DAGTerminationCause.SERVICE_PLUGIN_ERROR, message));
        }
    } else {
        LOG.warn("No current dag name provided. Not acting on " + message);
    }
}
Also used : TezDAGID(org.apache.tez.dag.records.TezDAGID) DAG(org.apache.tez.dag.app.dag.DAG) DAGEventTerminateDag(org.apache.tez.dag.app.dag.event.DAGEventTerminateDag)

Example 18 with DAG

use of org.apache.tez.dag.app.dag.DAG in project tez by apache.

the class DAGClientHandler method tryKillDAG.

public void tryKillDAG(String dagIdStr) throws TezException {
    DAG dag = getDAG(dagIdStr);
    String message = "Sending client kill from " + getClientInfo() + " to dag " + dagIdStr;
    LOG.info(message);
    dagAppMaster.tryKillDAG(dag, message);
}
Also used : DAG(org.apache.tez.dag.app.dag.DAG)

Example 19 with DAG

use of org.apache.tez.dag.app.dag.DAG in project tez by apache.

the class TaskCommunicatorContextImpl method getFirstAttemptStartTime.

@Override
public long getFirstAttemptStartTime(String vertexName, int taskIndex) {
    Preconditions.checkArgument(vertexName != null, "VertexName must be specified");
    Preconditions.checkArgument(taskIndex >= 0, "TaskIndex must be > 0");
    DAG dag = getDag();
    Vertex vertex = dag.getVertex(vertexName);
    Task task = vertex.getTask(taskIndex);
    return task.getFirstAttemptStartTime();
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) Task(org.apache.tez.dag.app.dag.Task) DAG(org.apache.tez.dag.app.dag.DAG)

Example 20 with DAG

use of org.apache.tez.dag.app.dag.DAG in project tez by apache.

the class TestDAGClientHandler method testDAGClientHandler.

@Test(timeout = 5000)
public void testDAGClientHandler() throws TezException {
    TezDAGID mockTezDAGId = mock(TezDAGID.class);
    when(mockTezDAGId.getId()).thenReturn(1);
    when(mockTezDAGId.toString()).thenReturn("dag_9999_0001_1");
    DAG mockDAG = mock(DAG.class);
    when(mockDAG.getID()).thenReturn(mockTezDAGId);
    DAGStatusBuilder mockDagStatusBuilder = mock(DAGStatusBuilder.class);
    when(mockDAG.getDAGStatus(anySetOf(StatusGetOpts.class))).thenReturn(mockDagStatusBuilder);
    VertexStatusBuilder mockVertexStatusBuilder = mock(VertexStatusBuilder.class);
    when(mockDAG.getVertexStatus(anyString(), anySetOf(StatusGetOpts.class))).thenReturn(mockVertexStatusBuilder);
    DAGAppMaster mockDagAM = mock(DAGAppMaster.class);
    when(mockDagAM.getState()).thenReturn(DAGAppMasterState.RUNNING);
    AppContext mockAppContext = mock(AppContext.class);
    when(mockDagAM.getContext()).thenReturn(mockAppContext);
    when(mockDagAM.getContext().getCurrentDAG()).thenReturn(mockDAG);
    when(mockAppContext.getClock()).thenReturn(new SystemClock());
    DAGClientHandler dagClientHandler = new DAGClientHandler(mockDagAM);
    // getAllDAGs()
    assertEquals(1, dagClientHandler.getAllDAGs().size());
    assertEquals("dag_9999_0001_1", dagClientHandler.getAllDAGs().get(0));
    // getDAGStatus
    try {
        dagClientHandler.getDAGStatus("dag_9999_0001_2", Sets.newSet(StatusGetOpts.GET_COUNTERS));
        fail("should not come here");
    } catch (TezException e) {
        assertTrue(e.getMessage().contains("Unknown dagId"));
    }
    DAGStatus dagStatus = dagClientHandler.getDAGStatus("dag_9999_0001_1", Sets.newSet(StatusGetOpts.GET_COUNTERS));
    assertEquals(mockDagStatusBuilder, dagStatus);
    // getVertexStatus
    try {
        dagClientHandler.getVertexStatus("dag_9999_0001_2", "v1", Sets.newSet(StatusGetOpts.GET_COUNTERS));
        fail("should not come here");
    } catch (TezException e) {
        assertTrue(e.getMessage().contains("Unknown dagId"));
    }
    VertexStatus vertexStatus = dagClientHandler.getVertexStatus("dag_9999_0001_1", "v1", Sets.newSet(StatusGetOpts.GET_COUNTERS));
    assertEquals(mockVertexStatusBuilder, vertexStatus);
    // getTezAppMasterStatus
    when(mockDagAM.isSession()).thenReturn(false);
    assertEquals(TezAppMasterStatus.RUNNING, dagClientHandler.getTezAppMasterStatus());
    when(mockDagAM.isSession()).thenReturn(true);
    when(mockDagAM.getState()).thenReturn(DAGAppMasterState.INITED);
    assertEquals(TezAppMasterStatus.INITIALIZING, dagClientHandler.getTezAppMasterStatus());
    when(mockDagAM.getState()).thenReturn(DAGAppMasterState.ERROR);
    assertEquals(TezAppMasterStatus.SHUTDOWN, dagClientHandler.getTezAppMasterStatus());
    // tryKillDAG
    try {
        dagClientHandler.tryKillDAG("dag_9999_0001_2");
        fail("should not come here");
    } catch (TezException e) {
        assertTrue(e.getMessage().contains("Unknown dagId"));
    }
    dagClientHandler.tryKillDAG("dag_9999_0001_1");
    ArgumentCaptor<DAG> eventCaptor = ArgumentCaptor.forClass(DAG.class);
    verify(mockDagAM, times(1)).tryKillDAG(eventCaptor.capture(), contains("Sending client kill from"));
    assertEquals(1, eventCaptor.getAllValues().size());
    assertTrue(eventCaptor.getAllValues().get(0) instanceof DAG);
    assertEquals("dag_9999_0001_1", ((DAG) eventCaptor.getAllValues().get(0)).getID().toString());
    // submitDAG
    DAGPlan dagPlan = DAGPlan.getDefaultInstance();
    Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
    dagClientHandler.submitDAG(dagPlan, localResources);
    verify(mockDagAM).submitDAGToAppMaster(dagPlan, localResources);
    // shutdown
    dagClientHandler.shutdownAM();
    verify(mockDagAM).shutdownTezAM(contains("Received message to shutdown AM from"));
}
Also used : TezException(org.apache.tez.dag.api.TezException) SystemClock(org.apache.hadoop.yarn.util.SystemClock) HashMap(java.util.HashMap) AppContext(org.apache.tez.dag.app.AppContext) DAG(org.apache.tez.dag.app.dag.DAG) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) DAGPlan(org.apache.tez.dag.api.records.DAGProtos.DAGPlan) DAGAppMaster(org.apache.tez.dag.app.DAGAppMaster) TezDAGID(org.apache.tez.dag.records.TezDAGID) Test(org.junit.Test)

Aggregations

DAG (org.apache.tez.dag.app.dag.DAG)46 Vertex (org.apache.tez.dag.app.dag.Vertex)22 Test (org.junit.Test)16 HashMap (java.util.HashMap)11 TezVertexID (org.apache.tez.dag.records.TezVertexID)11 EventHandler (org.apache.hadoop.yarn.event.EventHandler)10 Set (java.util.Set)9 TreeMap (java.util.TreeMap)8 Event (org.apache.hadoop.yarn.event.Event)8 AppContext (org.apache.tez.dag.app.AppContext)8 TezDAGID (org.apache.tez.dag.records.TezDAGID)7 Configuration (org.apache.hadoop.conf.Configuration)6 Matchers.anyString (org.mockito.Matchers.anyString)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 Map (java.util.Map)5 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)5 TaskAttempt (org.apache.tez.dag.app.dag.TaskAttempt)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4