Search in sources :

Example 46 with TezVertexID

use of org.apache.tez.dag.records.TezVertexID in project tez by apache.

the class TestDAGImpl method testVertexFailureHandling.

@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testVertexFailureHandling() {
    initDAG(dag);
    startDAG(dag);
    dispatcher.await();
    dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 0), VertexState.SUCCEEDED));
    dispatcher.await();
    Assert.assertEquals(DAGState.RUNNING, dag.getState());
    dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 1), VertexState.SUCCEEDED));
    dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 2), VertexState.FAILED));
    dispatcher.await();
    Assert.assertEquals(DAGState.FAILED, dag.getState());
    Assert.assertEquals(2, dag.getSuccessfulVertices());
    // Expect running vertices to be killed on first failure
    for (int i = 3; i < 6; ++i) {
        TezVertexID vId = TezVertexID.getInstance(dagId, i);
        Vertex v = dag.getVertex(vId);
        Assert.assertEquals(VertexState.KILLED, v.getState());
    }
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) DAGEventVertexCompleted(org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted) PlanTaskLocationHint(org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint) TezVertexID(org.apache.tez.dag.records.TezVertexID) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Example 47 with TezVertexID

use of org.apache.tez.dag.records.TezVertexID in project tez by apache.

the class TestDAGImpl method testKillStartedDAG.

@SuppressWarnings("unchecked")
public void testKillStartedDAG() {
    initDAG(dag);
    startDAG(dag);
    dispatcher.await();
    dispatcher.getEventHandler().handle(new DAGEventTerminateDag(dagId, DAGTerminationCause.DAG_KILL, null));
    dispatcher.await();
    Assert.assertEquals(DAGState.KILLED, dag.getState());
    for (int i = 0; i < 6; ++i) {
        TezVertexID vId = TezVertexID.getInstance(dagId, i);
        Vertex v = dag.getVertex(vId);
        Assert.assertEquals(VertexState.KILLED, v.getState());
    }
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) DAGEventTerminateDag(org.apache.tez.dag.app.dag.event.DAGEventTerminateDag) PlanTaskLocationHint(org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint) TezVertexID(org.apache.tez.dag.records.TezVertexID)

Example 48 with TezVertexID

use of org.apache.tez.dag.records.TezVertexID in project tez by apache.

the class TestDAGImpl method _testDAGTerminate.

// Couple of vertices succeed. DAG_KILLED processed, which causes the rest of the vertices to be
// marked as KILLED.
@SuppressWarnings("unchecked")
private void _testDAGTerminate(DAGTerminationCause terminationCause) {
    initDAG(dag);
    startDAG(dag);
    dispatcher.await();
    dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 0), VertexState.SUCCEEDED));
    dispatcher.await();
    Assert.assertEquals(DAGState.RUNNING, dag.getState());
    dispatcher.getEventHandler().handle(new DAGEventVertexCompleted(TezVertexID.getInstance(dagId, 1), VertexState.SUCCEEDED));
    dispatcher.getEventHandler().handle(new DAGEventTerminateDag(dagId, terminationCause, null));
    dispatcher.await();
    Assert.assertEquals(terminationCause.getFinishedState(), dag.getState());
    Assert.assertEquals(terminationCause, dag.getTerminationCause());
    Assert.assertEquals(2, dag.getSuccessfulVertices());
    int killedCount = 0;
    for (Map.Entry<TezVertexID, Vertex> vEntry : dag.getVertices().entrySet()) {
        if (vEntry.getValue().getState() == VertexState.KILLED) {
            killedCount++;
        }
    }
    Assert.assertEquals(4, killedCount);
    for (Vertex v : dag.getVertices().values()) {
        Assert.assertEquals(VertexTerminationCause.DAG_TERMINATED, v.getTerminationCause());
    }
    Assert.assertEquals(1, dagFinishEventHandler.dagFinishEvents);
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) DAGEventVertexCompleted(org.apache.tez.dag.app.dag.event.DAGEventVertexCompleted) DAGEventTerminateDag(org.apache.tez.dag.app.dag.event.DAGEventTerminateDag) Map(java.util.Map) PlanTaskLocationHint(org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint) TezVertexID(org.apache.tez.dag.records.TezVertexID)

Example 49 with TezVertexID

use of org.apache.tez.dag.records.TezVertexID in project tez by apache.

the class TestAMWebController method getAttemptsTestHelper.

Map<String, Object> getAttemptsTestHelper(List<TaskAttempt> attempts, List<List<Integer>> attemptMinIds, List<Integer> vertexMinIds, List<Integer> taskMinIds, Integer limit) {
    // Creating mock DAG
    DAG mockDAG = mock(DAG.class);
    doReturn(TezDAGID.fromString("dag_1441301219877_0109_1")).when(mockDAG).getID();
    // Creating mock vertex and attaching to mock DAG
    TezVertexID vertexID = TezVertexID.fromString("vertex_1441301219877_0109_1_00");
    Vertex mockVertex = mock(Vertex.class);
    doReturn(vertexID).when(mockVertex).getVertexId();
    doReturn(mockVertex).when(mockDAG).getVertex(vertexID);
    doReturn(ImmutableMap.of(vertexID, mockVertex)).when(mockDAG).getVertices();
    // Creating mock task and attaching to mock Vertex
    TezTaskID taskID = TezTaskID.fromString("task_1441301219877_0109_1_00_000000");
    Task mockTask = mock(Task.class);
    doReturn(taskID).when(mockTask).getTaskId();
    int taskIndex = taskID.getId();
    doReturn(mockTask).when(mockVertex).getTask(taskIndex);
    doReturn(ImmutableMap.of(taskID, mockTask)).when(mockVertex).getTasks();
    // Creating mock tasks and attaching to mock vertex
    Map<TezTaskAttemptID, TaskAttempt> attemptsMap = Maps.newHashMap();
    for (TaskAttempt attempt : attempts) {
        TezTaskAttemptID attemptId = attempt.getID();
        doReturn(attempt).when(mockTask).getAttempt(attemptId);
        attemptsMap.put(attemptId, attempt);
    }
    doReturn(attemptsMap).when(mockTask).getAttempts();
    // Creates & setup controller spy
    AMWebController amWebController = new AMWebController(mockRequestContext, mockAppContext, "TEST_HISTORY_URL");
    AMWebController spy = spy(amWebController);
    doReturn(true).when(spy).setupResponse();
    doNothing().when(spy).renderJSON(any());
    // Set mock query params
    doReturn(limit).when(spy).getQueryParamInt(WebUIService.LIMIT);
    doReturn(vertexMinIds).when(spy).getIntegersFromRequest(WebUIService.VERTEX_ID, limit);
    doReturn(taskMinIds).when(spy).getIDsFromRequest(WebUIService.TASK_ID, limit, 2);
    doReturn(attemptMinIds).when(spy).getIDsFromRequest(WebUIService.ATTEMPT_ID, limit, 3);
    // Set function mocks
    doReturn(mockDAG).when(spy).checkAndGetDAGFromRequest();
    Map<String, Set<String>> counterList = new TreeMap<String, Set<String>>();
    doReturn(counterList).when(spy).getCounterListFromRequest();
    spy.getAttemptsInfo();
    verify(spy).renderJSON(returnResultCaptor.capture());
    return returnResultCaptor.getValue();
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) Task(org.apache.tez.dag.app.dag.Task) Set(java.util.Set) DAG(org.apache.tez.dag.app.dag.DAG) Matchers.anyString(org.mockito.Matchers.anyString) TreeMap(java.util.TreeMap) TezTaskID(org.apache.tez.dag.records.TezTaskID) TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt) TezVertexID(org.apache.tez.dag.records.TezVertexID) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID)

Example 50 with TezVertexID

use of org.apache.tez.dag.records.TezVertexID in project tez by apache.

the class TestAMWebController method getTasksTestHelper.

Map<String, Object> getTasksTestHelper(List<Task> tasks, List<List<Integer>> taskMinIds, List<Integer> vertexMinIds, Integer limit) {
    // Creating mock DAG
    DAG mockDAG = mock(DAG.class);
    doReturn(TezDAGID.fromString("dag_1441301219877_0109_1")).when(mockDAG).getID();
    // Creating mock vertex and attaching to mock DAG
    TezVertexID vertexID = TezVertexID.fromString("vertex_1441301219877_0109_1_00");
    Vertex mockVertex = mock(Vertex.class);
    doReturn(vertexID).when(mockVertex).getVertexId();
    doReturn(mockVertex).when(mockDAG).getVertex(vertexID);
    doReturn(ImmutableMap.of(vertexID, mockVertex)).when(mockDAG).getVertices();
    // Creating mock tasks and attaching to mock vertex
    Map<TezTaskID, Task> taskMap = Maps.newHashMap();
    for (Task task : tasks) {
        TezTaskID taskId = task.getTaskId();
        int taskIndex = taskId.getId();
        doReturn(task).when(mockVertex).getTask(taskIndex);
        taskMap.put(taskId, task);
    }
    doReturn(taskMap).when(mockVertex).getTasks();
    // Creates & setup controller spy
    AMWebController amWebController = new AMWebController(mockRequestContext, mockAppContext, "TEST_HISTORY_URL");
    AMWebController spy = spy(amWebController);
    doReturn(true).when(spy).setupResponse();
    doNothing().when(spy).renderJSON(any());
    // Set mock query params
    doReturn(limit).when(spy).getQueryParamInt(WebUIService.LIMIT);
    doReturn(vertexMinIds).when(spy).getIntegersFromRequest(WebUIService.VERTEX_ID, limit);
    doReturn(taskMinIds).when(spy).getIDsFromRequest(WebUIService.TASK_ID, limit, 2);
    // Set function mocks
    doReturn(mockDAG).when(spy).checkAndGetDAGFromRequest();
    Map<String, Set<String>> counterList = new TreeMap<String, Set<String>>();
    doReturn(counterList).when(spy).getCounterListFromRequest();
    spy.getTasksInfo();
    verify(spy).renderJSON(returnResultCaptor.capture());
    return returnResultCaptor.getValue();
}
Also used : Vertex(org.apache.tez.dag.app.dag.Vertex) Task(org.apache.tez.dag.app.dag.Task) Set(java.util.Set) DAG(org.apache.tez.dag.app.dag.DAG) Matchers.anyString(org.mockito.Matchers.anyString) TreeMap(java.util.TreeMap) TezVertexID(org.apache.tez.dag.records.TezVertexID) TezTaskID(org.apache.tez.dag.records.TezTaskID)

Aggregations

TezVertexID (org.apache.tez.dag.records.TezVertexID)117 Test (org.junit.Test)64 TezDAGID (org.apache.tez.dag.records.TezDAGID)61 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)54 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)46 Configuration (org.apache.hadoop.conf.Configuration)43 TezTaskID (org.apache.tez.dag.records.TezTaskID)43 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)40 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)31 Resource (org.apache.hadoop.yarn.api.records.Resource)29 Container (org.apache.hadoop.yarn.api.records.Container)28 ClusterInfo (org.apache.tez.dag.app.ClusterInfo)28 TaskCommunicatorManagerInterface (org.apache.tez.dag.app.TaskCommunicatorManagerInterface)28 ContainerHeartbeatHandler (org.apache.tez.dag.app.ContainerHeartbeatHandler)27 AMContainerMap (org.apache.tez.dag.app.rm.container.AMContainerMap)27 ContainerContextMatcher (org.apache.tez.dag.app.rm.container.ContainerContextMatcher)27 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)24 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)24 SystemClock (org.apache.hadoop.yarn.util.SystemClock)22 Vertex (org.apache.tez.dag.app.dag.Vertex)22