检查作业状态:Mapreduce作业

时间:2018-01-15 09:57:55

标签: java hadoop mapreduce

我正在尝试查看Mapreduce作业的jobstatus。

当我运行job.iscomplete()时,我会遇到异常 "Job in state DEFINE instead of RUNNING"

try {
                    if (job.isComplete()) {
                        printInfoLog(LOG, this.filename,
                                "** " + job.getTrackingURL());
                        break;
                    }
                } catch (Exception e) {
                    LOG.warn("** " + e.getMessage());

                }

但是我检查Jobstatus(https://hadoop.apache.org/docs/stable/api/org/apache/hadoop/mapreduce/JobStatus.html)

中的所有字段都没有这样的状态

我觉得这份工作尚未提交,这让我有点理解。任何人都可以建议我如何检查作业是否已提交,因为我在API中找不到任何此类方法。

1 个答案:

答案 0 :(得分:0)

我解决了它,如下,

if ( job.getJobState() == JobStatus.State.RUNNING || job.getJobState() == JobStatus.State.SUCCEEDED || job.getJobState() == JobStatus.State.KILLED || job.getJobState() == JobStatus.State.FAILED)
{
try {
        if (job.isComplete()) {
        printInfoLog(LOG, this.filename,
                            "** " + job.getTrackingURL());
         break;
                    }
                } catch (Exception e) {
                    LOG.warn("** " + e.getMessage());

                }
}
}

虽然我同意这是一个粗略的解决方案