本文整理匯總了Java中org.apache.hadoop.mapred.RunningJob.getTaskCompletionEvents方法的典型用法代碼示例。如果您正苦於以下問題:Java RunningJob.getTaskCompletionEvents方法的具體用法?Java RunningJob.getTaskCompletionEvents怎麽用?Java RunningJob.getTaskCompletionEvents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.mapred.RunningJob
的用法示例。
在下文中一共展示了RunningJob.getTaskCompletionEvents方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: abortJob
import org.apache.hadoop.mapred.RunningJob; //導入方法依賴的package包/類
@Override
public void abortJob(JobContext context, JobStatus.State runState) throws java.io.IOException {
super.abortJob(context, runState);
final JobClient jobClient = new JobClient(new JobConf(context.getConfiguration()));
final RunningJob job = jobClient.getJob((org.apache.hadoop.mapred.JobID) JobID.forName(context.getConfiguration().get("mapred.job.id")));
String diag = "";
for (final TaskCompletionEvent event : job.getTaskCompletionEvents(0))
switch (event.getTaskStatus()) {
case SUCCEEDED:
break;
default:
diag += "Diagnostics for: " + event.getTaskTrackerHttp() + "\n";
for (final String s : job.getTaskDiagnostics(event.getTaskAttemptId()))
diag += s + "\n";
diag += "\n";
break;
}
updateStatus(diag, context.getConfiguration().getInt("boa.hadoop.jobid", 0));
}
示例2: testTaskCompletionEvents
import org.apache.hadoop.mapred.RunningJob; //導入方法依賴的package包/類
public void testTaskCompletionEvents() throws Exception {
LOG.info("Starting SleepJob to test TaskCompletionEvents");
corona = new MiniCoronaCluster.Builder().numTaskTrackers(1).build();
JobConf conf = corona.createJobConf();
SleepJob sleepJob = new SleepJob();
ToolRunner.run(conf, sleepJob, new String[] { "-m", "10", "-r", "10",
"-mt", "5", "-rt", "5" });
List<TaskCompletionEvent> events = new ArrayList<TaskCompletionEvent>();
int index = 0;
int numReduces = 0;
int numMaps = 0;
RunningJob rjob = sleepJob.getRunningJob();
while (true) {
TaskCompletionEvent[] someEvents = rjob.getTaskCompletionEvents(index);
if (someEvents.length == 0) {
break;
}
for (int i = 0; i < someEvents.length; i++) {
if (someEvents[i].isMapTask()) {
numMaps++;
} else {
numReduces++;
}
}
index += someEvents.length;
}
Assert.assertEquals("Num maps is " + numMaps, 10, numMaps);
Assert.assertTrue("Num reduces is " + numReduces, numReduces >= 10);
}