如何从Java程序检查hdfs作业的状态?

时间:2019-06-03 02:48:46

标签: java hadoop oozie

我要检查作业的状态。完成后,我要执行其他操作。问题是我还想检查作业是否被杀死或中止,因为hdfs中可以存在许多作业并进行相应的报告。

https://www.programcreek.com/java-api-examples/index.php?api=org.apache.hadoop.mapred.JobStatus 通过链接去了! Aslo请在此链接上查看源代码。

private void printJobAnalysis() {
 if (!job.getJobStatus().equals
  (JobStatus.getJobRunState(JobStatus.SUCCEEDED))) {
System.out.println("No Analysis available as job did not finish");
return;

}

AnalyzedJob avg = new AnalyzedJob(job);

System.out.println("\nAnalysis");
System.out.println("=========");
printAnalysis(avg.getMapTasks(), cMap, "map", avg.getAvgMapTime(), 
10);
printLast(avg.getMapTasks(), "map", cFinishMapRed);

if (avg.getReduceTasks().length > 0) {
 printAnalysis(avg.getReduceTasks(), cShuffle, "shuffle", 
    avg.getAvgShuffleTime(), 10);
 printLast(avg.getReduceTasks(), "shuffle", cFinishShuffle);

 printAnalysis(avg.getReduceTasks(), cReduce, "reduce",
    avg.getAvgReduceTime(), 10);
 printLast(avg.getReduceTasks(), "reduce", cFinishMapRed);
}
System.out.println("=========");
}

0 个答案:

没有答案