本文整理汇总了Java中org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskInfo.getTaskId方法的典型用法代码示例。如果您正苦于以下问题:Java TaskInfo.getTaskId方法的具体用法?Java TaskInfo.getTaskId怎么用?Java TaskInfo.getTaskId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskInfo
的用法示例。
在下文中一共展示了TaskInfo.getTaskId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateTaskLevelKeyValuesFormat
import org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskInfo; //导入方法依赖的package包/类
private static void validateTaskLevelKeyValuesFormat(JobInfo job,
boolean splitsCanBeEmpty) {
Map<TaskID, TaskInfo> tasks = job.getAllTasks();
// validate info of each task
for (TaskInfo task : tasks.values()) {
TaskID tid = task.getTaskId();
long startTime = task.getStartTime();
assertTrue("Invalid Start time", startTime > 0);
long finishTime = task.getFinishTime();
assertTrue("Task FINISH_TIME is < START_TIME in history file",
startTime < finishTime);
// Make sure that the Task type exists and it is valid
TaskType type = task.getTaskType();
assertTrue("Unknown Task type \"" + type + "\" is seen in " +
"history file for task " + tid,
(type.equals(TaskType.MAP) ||
type.equals(TaskType.REDUCE) ||
type.equals(TaskType.JOB_CLEANUP) ||
type.equals(TaskType.JOB_SETUP)));
if (type.equals(TaskType.MAP)) {
String splits = task.getSplitLocations();
//order in the condition OR check is important here
if (!splitsCanBeEmpty || splits.length() != 0) {
Matcher m = splitsPattern.matcher(splits);
assertTrue("Unexpected format of SPLITS \"" + splits + "\" is seen" +
" in history file for task " + tid, m.matches());
}
}
// Validate task status
String status = task.getTaskStatus();
assertTrue("Unexpected TASK_STATUS \"" + status + "\" is seen in" +
" history file for task " + tid, (status.equals("SUCCEEDED") ||
status.equals("FAILED") || status.equals("KILLED")));
}
}
示例2: validateTaskLevelKeyValues
import org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskInfo; //导入方法依赖的package包/类
private static void validateTaskLevelKeyValues(MiniMRCluster mr,
RunningJob job, JobInfo jobInfo) throws IOException {
JobTracker jt = mr.getJobTrackerRunner().getJobTracker();
JobInProgress jip = jt.getJob(job.getID());
// Get the 1st map, 1st reduce, cleanup & setup taskIDs and
// validate their history info
TaskID mapTaskId = new TaskID(job.getID(), TaskType.MAP, 0);
TaskID reduceTaskId = new TaskID(job.getID(), TaskType.REDUCE, 0);
TaskInProgress cleanups[] = jip.cleanup;
TaskID cleanupTaskId;
if (cleanups[0].isComplete()) {
cleanupTaskId = cleanups[0].getTIPId();
}
else {
cleanupTaskId = cleanups[1].getTIPId();
}
TaskInProgress setups[] = jip.setup;
TaskID setupTaskId;
if (setups[0].isComplete()) {
setupTaskId = setups[0].getTIPId();
}
else {
setupTaskId = setups[1].getTIPId();
}
Map<TaskID, TaskInfo> tasks = jobInfo.getAllTasks();
// validate info of the 4 tasks(cleanup, setup, 1st map, 1st reduce)
for (TaskInfo task : tasks.values()) {
TaskID tid = task.getTaskId();
if (tid.equals(mapTaskId) ||
tid.equals(reduceTaskId) ||
tid.equals(cleanupTaskId) ||
tid.equals(setupTaskId)) {
TaskInProgress tip = jip.getTaskInProgress
(org.apache.hadoop.mapred.TaskID.downgrade(tid));
assertTrue("START_TIME of Task " + tid + " obtained from history " +
"file did not match the expected value",
tip.getExecStartTime() ==
task.getStartTime());
assertTrue("FINISH_TIME of Task " + tid + " obtained from history " +
"file did not match the expected value",
tip.getExecFinishTime() ==
task.getFinishTime());
if (tid == mapTaskId) {//check splits only for map task
assertTrue("Splits of Task " + tid + " obtained from history file " +
" did not match the expected value",
tip.getSplitNodes().equals(task.getSplitLocations()));
}
TaskAttemptID attemptId = tip.getSuccessfulTaskid();
TaskStatus ts = tip.getTaskStatus(
org.apache.hadoop.mapred.TaskAttemptID.downgrade(attemptId));
// Validate task counters
Counters c = new Counters(ts.getCounters());
assertTrue("Counters of Task " + tid + " obtained from history file " +
" did not match the expected value",
c.equals(task.getCounters()));
}
}
}