Example usage for org.apache.hadoop.mapreduce.v2.api.records JobReport getJobId

List of usage examples for org.apache.hadoop.mapreduce.v2.api.records JobReport getJobId

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.v2.api.records JobReport getJobId.

Prototype

public abstract JobId getJobId();

Source Link

Usage

From source file:org.apache.tez.dag.app.JobEndNotifier.java

License:Apache License

/**
 * Notify a server of the completion of a submitted job. The user must have
 * configured MRJobConfig.MR_JOB_END_NOTIFICATION_URL
 * @param jobReport JobReport used to read JobId and JobStatus
 * @throws InterruptedException//from   w w w .j  a  v  a  2s .  c o m
 */
public void notify(JobReport jobReport) throws InterruptedException {
    // Do we need job-end notification?
    if (userUrl == null) {
        Log.info("Job end notification URL not set, skipping.");
        return;
    }

    //Do string replacements for jobId and jobStatus
    if (userUrl.contains(JOB_ID)) {
        userUrl = userUrl.replace(JOB_ID, jobReport.getJobId().toString());
    }
    if (userUrl.contains(JOB_STATUS)) {
        userUrl = userUrl.replace(JOB_STATUS, jobReport.getJobState().toString());
    }

    // Create the URL, ensure sanity
    try {
        urlToNotify = new URL(userUrl);
    } catch (MalformedURLException mue) {
        Log.warn("Job end notification couldn't parse " + userUrl, mue);
        return;
    }

    // Send notification
    boolean success = false;
    while (numTries-- > 0 && !success) {
        Log.info("Job end notification attempts left " + numTries);
        success = notifyURLOnce();
        if (!success) {
            Thread.sleep(waitInterval);
        }
    }
    if (!success) {
        Log.warn("Job end notification failed to notify : " + urlToNotify);
    } else {
        Log.info("Job end notification succeeded for " + jobReport.getJobId());
    }
}