use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.
the class TestAMContainer method testTaskAssignedToCompletedContainer.
@SuppressWarnings("rawtypes")
@Test(timeout = 5000)
public void testTaskAssignedToCompletedContainer() {
WrappedContainer wc = new WrappedContainer();
List<Event> outgoingEvents;
wc.launchContainer();
wc.containerLaunched();
wc.assignTaskAttempt(wc.taskAttemptID);
wc.taskAttemptSucceeded(wc.taskAttemptID);
wc.containerCompleted();
wc.verifyState(AMContainerState.COMPLETED);
TezTaskAttemptID taID2 = TezTaskAttemptID.getInstance(wc.taskID, 2);
wc.assignTaskAttempt(taID2);
outgoingEvents = wc.verifyCountAndGetOutgoingEvents(1);
verifyUnOrderedOutgoingEventTypes(outgoingEvents, TaskAttemptEventType.TA_CONTAINER_TERMINATED);
TaskAttemptEventContainerTerminated ctEvent = (TaskAttemptEventContainerTerminated) outgoingEvents.get(0);
assertEquals(taID2, ctEvent.getTaskAttemptID());
wc.verifyHistoryStopEvent();
// Allocation to a completed Container is considered an error.
// TODO Is this valid ?
assertTrue(wc.amContainer.isInErrorState());
}
use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.
the class TestAMNodeTracker method _testSingleNodeNotBlacklisted.
private void _testSingleNodeNotBlacklisted(AMNodeTracker amNodeTracker, TestEventHandler handler, int schedulerId) {
amNodeTracker.handle(new AMNodeEventNodeCountUpdated(1, schedulerId));
NodeId nodeId = NodeId.newInstance("host1", 1234);
amNodeTracker.nodeSeen(nodeId, schedulerId);
AMNodeImpl node = (AMNodeImpl) amNodeTracker.get(nodeId, schedulerId);
ContainerId cId1 = mock(ContainerId.class);
ContainerId cId2 = mock(ContainerId.class);
amNodeTracker.handle(new AMNodeEventContainerAllocated(nodeId, schedulerId, cId1));
amNodeTracker.handle(new AMNodeEventContainerAllocated(nodeId, schedulerId, cId2));
TezTaskAttemptID ta1 = mock(TezTaskAttemptID.class);
TezTaskAttemptID ta2 = mock(TezTaskAttemptID.class);
amNodeTracker.handle(new AMNodeEventTaskAttemptEnded(nodeId, schedulerId, cId1, ta1, true));
dispatcher.await();
assertEquals(1, node.numFailedTAs);
assertEquals(AMNodeState.ACTIVE, node.getState());
amNodeTracker.handle(new AMNodeEventTaskAttemptEnded(nodeId, schedulerId, cId2, ta2, true));
dispatcher.await();
assertEquals(2, node.numFailedTAs);
assertEquals(1, handler.events.size());
assertEquals(AMNodeEventType.N_IGNORE_BLACKLISTING_ENABLED, handler.events.get(0).getType());
assertEquals(AMNodeState.FORCED_ACTIVE, node.getState());
// Blacklisting should be ignored since the node should have been blacklisted, but has not been
// as a result of being a single node for the source
assertTrue(amNodeTracker.isBlacklistingIgnored(schedulerId));
}
use of org.apache.tez.dag.records.TezTaskAttemptID 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();
}
use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.
the class TezTypeConverters method toYarn.
public static TaskAttemptId toYarn(TezTaskAttemptID taskAttemptId) {
TaskAttemptID mrTaskAttemptId = IDConverter.toMRTaskAttemptId(taskAttemptId);
TaskAttemptId mrv2TaskAttemptId = TypeConverter.toYarn(mrTaskAttemptId);
return mrv2TaskAttemptId;
}
use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.
the class TezTypeConverters method toTez.
public static TezTaskAttemptID toTez(TaskAttemptId taskAttemptId) {
TaskAttemptID mrTaskAttemptId = TypeConverter.fromYarn(taskAttemptId);
TezTaskAttemptID tezTaskAttemptId = IDConverter.fromMRTaskAttemptId(mrTaskAttemptId);
return tezTaskAttemptId;
}
Aggregations