Example usage for org.apache.hadoop.mapred JobClient monitorAndPrintJob

List of usage examples for org.apache.hadoop.mapred JobClient monitorAndPrintJob

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred JobClient monitorAndPrintJob.

Prototype

public boolean monitorAndPrintJob(JobConf conf, RunningJob job) throws IOException, InterruptedException 

Source Link

Document

Monitor a job and print status in real-time as progress is made and tasks fail.

Usage

From source file:com.google.mr4c.hadoop.HadoopAlgoRunner.java

License:Open Source License

private void submitJob() throws IOException {
    // most of this method copies JobClient.runJob()
    // addition here is logging the job URI
    JobClient client = new JobClient(m_jobConf);
    RunningJob job = client.submitJob(m_jobConf);
    m_log.info("Job URL is [{}]", job.getTrackingURL());
    try {//from   ww  w. j a v  a 2s  . co  m
        if (!client.monitorAndPrintJob(m_jobConf, job)) {
            throw new IOException("Job failed!");
        }
    } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
    }
}

From source file:com.ibm.jaql.lang.expr.hadoop.Util.java

License:Apache License

public static void submitJob(JsonString submitClassName, JobConf conf) throws Exception {
    JobClient jc = new JobClient(conf);
    RunningJob rj = jc.submitJob(conf);//from   w  w  w.  j  a  va2s. co m
    String sc = JsonUtil.printToString(submitClassName);

    // log to status that a MR job is starting
    mrStatusStart(sc);

    // log to status vital MR job information
    mrStatusInfo(sc, JsonUtil.printToString(new JsonString(rj.getID().toString())),
            JsonUtil.printToString(new JsonString(rj.getJobName())),
            JsonUtil.printToString(new JsonString(rj.getTrackingURL())));
    //STATUS_LOG.info("MAP-REDUCE INFO: " + rj.getID() + "," + rj.getJobName() + "," + rj.getTrackingURL());

    boolean failed = false;
    try {
        if (!jc.monitorAndPrintJob(conf, rj)) {
            LOG.error(new IOException("Job failed!"));
            failed = true;
            //throw new IOException("Job failed!");
        }
    } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
    }

    try {
        if (rj.isSuccessful()) {
            logAllTaskSyslogs(rj, true);
        } else {
            logAllTaskSyslogs(rj, false);
        }
    } catch (Throwable t) {
        // log it, but do not stop the world for this
        LOG.error(t);
    }

    // log to status that a MR job is stopping
    mrStatusStop(sc);

    // if the job failed, then throw an exception
    if (failed) {
        throw new IOException("Job failed!");
    }
}

From source file:org.apache.oozie.action.hadoop.LauncherMainTester.java

License:Apache License

private static void executeJavaMapReduce(String[] args) throws IOException, InterruptedException {
    JobConf jConf = createSleepMapperReducerJobConf();
    final Path input = new Path(args[1]);
    FileInputFormat.setInputPaths(jConf, input);
    FileOutputFormat.setOutputPath(jConf, new Path(args[2]));
    writeToFile(input, jConf, "dummy\n", "data.txt");
    JobClient jc = new JobClient(jConf);
    System.out.println("Submitting MR job");
    RunningJob job = jc.submitJob(jConf);
    System.out.println("Submitted job " + job.getID().toString());
    writeToFile(input, jConf, job.getID().toString(), JOB_ID_FILE_NAME);
    job.waitForCompletion();/*from   www  .  j  a  v  a2 s. co  m*/
    jc.monitorAndPrintJob(jConf, job);
    if (job.getJobState() != JobStatus.SUCCEEDED) {
        System.err.println(job.getJobState() + " job state instead of" + JobStatus.SUCCEEDED);
        System.exit(-1);
    }
}