Example usage for org.apache.hadoop.mapreduce JobStatus getStartTime

List of usage examples for org.apache.hadoop.mapreduce JobStatus getStartTime

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce JobStatus getStartTime.

Prototype

synchronized public long getStartTime() 

Source Link

Usage

From source file:org.huahinframework.manager.util.JobUtils.java

License:Apache License

/**
 * @param jobStatus//  w w  w  .j  a  va 2  s . c  o  m
 * @return JSON map
 * @throws IOException
 */
public static Map<String, Object> getJob(JobStatus jobStatus) throws IOException {
    int numUsedSlots = jobStatus.getNumUsedSlots();
    int numReservedSlots = jobStatus.getNumReservedSlots();
    int usedMem = jobStatus.getUsedMem();
    int rsvdMem = jobStatus.getReservedMem();
    int neededMem = jobStatus.getNeededMem();

    Map<String, Object> m = new HashMap<String, Object>();
    m.put(Response.JOBID, jobStatus.getJobID().toString());
    m.put(Response.NAME, jobStatus.getJobName());
    m.put(Response.STATE, jobStatus.getState());

    Calendar startTime = Calendar.getInstance();
    startTime.setTimeInMillis(jobStatus.getStartTime());
    m.put(Response.START_TIME, startTime.getTime().toString());

    m.put(Response.USER, jobStatus.getUsername());
    m.put(Response.QUEUE, jobStatus.getQueue());
    m.put(Response.PRIORITY, jobStatus.getPriority().name());
    m.put(Response.USED_CONTAINERS, numUsedSlots < 0 ? UNAVAILABLE : numUsedSlots);
    m.put(Response.RSVD_CONTAINERS, numReservedSlots < 0 ? UNAVAILABLE : numReservedSlots);
    m.put(Response.USED_MEM, usedMem < 0 ? UNAVAILABLE : String.format(memPattern, usedMem));
    m.put(Response.RSVD_MEM, rsvdMem < 0 ? UNAVAILABLE : String.format(memPattern, rsvdMem));
    m.put(Response.NEEDED_MEM, neededMem < 0 ? UNAVAILABLE : String.format(memPattern, neededMem));
    m.put(Response.AM_INFO, jobStatus.getSchedulingInfo());
    return m;
}