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

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

Introduction

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

Prototype

public JobStatus[] jobsToComplete() throws IOException 

Source Link

Document

Get the jobs that are not completed and not failed.

Usage

From source file:org.openflamingo.engine.monitoring.hadoop.JobTrackerMonitor.java

License:Apache License

public void printJobs() throws IOException {
    JobConf conf = new JobConf();
    conf.set("mapred.job,tracker", "localhost:9001");

    JobClient jobClient = new JobClient(conf);
    JobStatus[] allJobs = jobClient.getAllJobs();
    if (allJobs != null) {
        for (JobStatus status : allJobs) {
            System.out.println(status.getJobID());
            System.out.println(status.getSchedulingInfo());
        }//from   w  w  w .j a  v a 2  s. c  o m
    }

    System.out.println(jobClient.getClusterStatus().getMapTasks());

    JobQueueInfo[] queues = jobClient.getQueues();
    if (queues != null)
        for (JobQueueInfo queue : queues) {
            System.out.println(queue.getQueueName());
            System.out.println(queue.getSchedulingInfo());
            System.out.println(queue.getQueueState());
        }

    JobStatus[] jobStatuses = jobClient.jobsToComplete();
    if (jobStatuses != null)
        for (JobStatus jobStatus : jobStatuses) {
            System.out.println(jobStatus.getJobID().getId());
            System.out.println(jobStatus.getSchedulingInfo());
        }
}