use of org.apache.tez.dag.app.dag.TaskAttempt in project tez by apache.
the class TestAMWebController method createMockAttempt.
private TaskAttempt createMockAttempt(String attemptIDStr, TaskAttemptState status, float progress) {
TaskAttempt mockAttempt = mock(TaskAttempt.class);
doReturn(TezTaskAttemptID.fromString(attemptIDStr)).when(mockAttempt).getID();
doReturn(status).when(mockAttempt).getState();
doReturn(progress).when(mockAttempt).getProgress();
TezCounters counters = new TezCounters();
counters.addGroup("g1", "g1");
counters.addGroup("g2", "g2");
counters.addGroup("g3", "g3");
counters.addGroup("g4", "g4");
counters.findCounter("g1", "g1_c1").setValue(101);
counters.findCounter("g1", "g1_c2").setValue(102);
counters.findCounter("g2", "g2_c3").setValue(103);
counters.findCounter("g2", "g2_c4").setValue(104);
counters.findCounter("g3", "g3_c5").setValue(105);
counters.findCounter("g3", "g3_c6").setValue(106);
doReturn(counters).when(mockAttempt).getCounters();
return mockAttempt;
}
use of org.apache.tez.dag.app.dag.TaskAttempt in project tez by apache.
the class TestAMWebController method createMockAttempts.
private List<TaskAttempt> createMockAttempts() {
TaskAttempt mockAttempt1 = createMockAttempt("attempt_1441301219877_0109_1_00_000000_0", TaskAttemptState.RUNNING, 0.33f);
TaskAttempt mockAttempt2 = createMockAttempt("attempt_1441301219877_0109_1_00_000000_1", TaskAttemptState.SUCCEEDED, 1.0f);
TaskAttempt mockAttempt3 = createMockAttempt("attempt_1441301219877_0109_1_00_000000_2", TaskAttemptState.FAILED, .8f);
TaskAttempt mockAttempt4 = createMockAttempt("attempt_1441301219877_0109_1_00_000000_3", TaskAttemptState.SUCCEEDED, .8f);
List<TaskAttempt> attempts = Arrays.asList(mockAttempt1, mockAttempt2, mockAttempt3, mockAttempt4);
return attempts;
}
use of org.apache.tez.dag.app.dag.TaskAttempt in project tez by apache.
the class AMWebController method getAttemptsInfo.
/**
* Renders the response JSON for attemptsInfo API
* The JSON will have an array of attempt objects under the key attempts.
*/
public void getAttemptsInfo() {
if (!setupResponse()) {
return;
}
DAG dag = checkAndGetDAGFromRequest();
if (dag == null) {
return;
}
int limit = MAX_QUERIED;
try {
limit = getQueryParamInt(WebUIService.LIMIT);
} catch (NumberFormatException e) {
// Ignore
}
List<TaskAttempt> attempts = getRequestedAttempts(dag, limit);
if (attempts == null) {
return;
}
Map<String, Set<String>> counterNames = getCounterListFromRequest();
ArrayList<Map<String, Object>> attemptsInfo = new ArrayList<Map<String, Object>>();
for (TaskAttempt a : attempts) {
Map<String, Object> attemptInfo = new HashMap<String, Object>();
attemptInfo.put("id", a.getID().toString());
attemptInfo.put("progress", Float.toString(a.getProgress()));
attemptInfo.put("status", a.getState().toString());
try {
TezCounters counters = a.getCounters();
Map<String, Map<String, Long>> counterMap = constructCounterMapInfo(counters, counterNames);
if (counterMap != null && !counterMap.isEmpty()) {
attemptInfo.put("counters", counterMap);
}
} catch (LimitExceededException e) {
// Ignore
// TODO: add an error message instead for counter key
}
attemptsInfo.add(attemptInfo);
}
renderJSON(ImmutableMap.of("attempts", attemptsInfo));
}
use of org.apache.tez.dag.app.dag.TaskAttempt in project tez by apache.
the class TaskImpl method addAndScheduleAttempt.
// This is always called in the Write Lock
private void addAndScheduleAttempt(TezTaskAttemptID schedulingCausalTA) {
TaskAttempt attempt = createAttempt(attempts.size(), schedulingCausalTA);
if (LOG.isDebugEnabled()) {
LOG.debug("Created attempt " + attempt.getID());
}
switch(attempts.size()) {
case 0:
attempts = Collections.singletonMap(attempt.getID(), attempt);
break;
case 1:
Map<TezTaskAttemptID, TaskAttempt> newAttempts = new LinkedHashMap<TezTaskAttemptID, TaskAttempt>(maxFailedAttempts);
newAttempts.putAll(attempts);
attempts = newAttempts;
Preconditions.checkArgument(attempts.put(attempt.getID(), attempt) == null, attempt.getID() + " already existed");
break;
default:
Preconditions.checkArgument(attempts.put(attempt.getID(), attempt) == null, attempt.getID() + " already existed");
break;
}
// TODO: Recovery
/*
// Update nextATtemptNumber
if (taskAttemptsFromPreviousGeneration.isEmpty()) {
++nextAttemptNumber;
} else {
// There are still some TaskAttempts from previous generation, use them
nextAttemptNumber =
taskAttemptsFromPreviousGeneration.remove(0).getAttemptId().getId();
}
*/
this.taskAttemptStatus.put(attempt.getID().getId(), false);
// schedule the nextAttemptNumber
// send event to DAG to assign priority and schedule the attempt with global
// picture in mind
eventHandler.handle(new DAGEventSchedulerUpdate(DAGEventSchedulerUpdate.UpdateType.TA_SCHEDULE, attempt));
}
use of org.apache.tez.dag.app.dag.TaskAttempt in project tez by apache.
the class TaskImpl method getLaunchTime.
// this is always called in read/write lock
private long getLaunchTime() {
long taskLaunchTime = 0;
boolean launchTimeSet = false;
for (TaskAttempt at : attempts.values()) {
// select the least launch time of all attempts
long attemptLaunchTime = at.getLaunchTime();
if (attemptLaunchTime != 0 && !launchTimeSet) {
// For the first non-zero launch time
launchTimeSet = true;
taskLaunchTime = attemptLaunchTime;
} else if (attemptLaunchTime != 0 && taskLaunchTime > attemptLaunchTime) {
taskLaunchTime = attemptLaunchTime;
}
}
if (!launchTimeSet) {
return this.scheduledTime;
}
return taskLaunchTime;
}
Aggregations