Example usage for org.apache.hadoop.mapreduce Counter getDisplayName

List of usage examples for org.apache.hadoop.mapreduce Counter getDisplayName

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce Counter getDisplayName.

Prototype

String getDisplayName();

Source Link

Document

Get the display name of the counter.

Usage

From source file:org.apache.tez.mapreduce.hadoop.mapred.MRCounters.java

License:Apache License

static org.apache.tez.common.counters.TezCounter convert(org.apache.hadoop.mapred.Counters.Counter counter) {
    org.apache.hadoop.mapreduce.Counter underlyingCounter = counter.getUnderlyingCounter();
    if (underlyingCounter instanceof org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup.FrameworkCounter) {
        org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup.FrameworkCounter real = (org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup.FrameworkCounter) underlyingCounter;
        return new org.apache.tez.common.counters.FrameworkCounterGroup.FrameworkCounter(real.getKey(),
                real.getGroupName());//w  ww.jav a 2 s . com
    } else if (underlyingCounter instanceof org.apache.hadoop.mapreduce.counters.FileSystemCounterGroup.FSCounter) {
        org.apache.hadoop.mapreduce.counters.FileSystemCounterGroup.FSCounter real = (org.apache.hadoop.mapreduce.counters.FileSystemCounterGroup.FSCounter) underlyingCounter;
        return new org.apache.tez.common.counters.FileSystemCounterGroup.FSCounter(real.getScheme(),
                convert(real.getFileSystemCounter()));
    } else {
        return new org.apache.tez.common.counters.GenericCounter(underlyingCounter.getName(),
                underlyingCounter.getDisplayName(), underlyingCounter.getValue());
    }
}

From source file:org.godhuli.rhipe.RHMR.java

License:Apache License

public static REXP buildListFromCounters(org.apache.hadoop.mapreduce.Counters counters, double tt) {
    //      String[] groupnames = counters.getGroupNames().toArray(new String[] {});
    List<String> list = new ArrayList<String>();
    for (String groupName : counters.getGroupNames()) {
        list.add(groupName);// w w w.j  a v  a2s  .  c  om
    }
    String[] groupnames = new String[list.size()];
    groupnames = list.toArray(groupnames);

    String[] groupdispname = new String[groupnames.length + 1];
    Vector<REXP> cn = new Vector<REXP>();
    for (int i = 0; i < groupnames.length; i++) {
        org.apache.hadoop.mapreduce.CounterGroup cgroup = counters.getGroup(groupnames[i]);
        groupdispname[i] = cgroup.getDisplayName();
        REXP.Builder cvalues = REXP.newBuilder();
        Vector<String> cnames = new Vector<String>();
        cvalues.setRclass(REXP.RClass.REAL);
        for (org.apache.hadoop.mapreduce.Counter counter : cgroup) {
            cvalues.addRealValue((double) counter.getValue());
            cnames.add(counter.getDisplayName());
        }
        cvalues.addAttrName("names");
        cvalues.addAttrValue(RObjects.makeStringVector(cnames.toArray(new String[] {})));
        cn.add(cvalues.build());
    }
    groupdispname[groupnames.length] = "job_time";
    REXP.Builder cvalues = REXP.newBuilder();
    cvalues.setRclass(REXP.RClass.REAL);
    cvalues.addRealValue(tt);
    cn.add(cvalues.build());
    return (RObjects.makeList(groupdispname, cn));
}

From source file:org.huahinframework.manager.rest.service.JobService.java

License:Apache License

/**
 * @param jobId/*from ww w. ja va 2s. co  m*/
 * @return {@link JSONObject}
 * @throws IOException
 * @throws InterruptedException
 */
private Map<String, Object> getStatus(String jobId) throws IOException, InterruptedException {
    Map<String, Object> job = null;

    Cluster cluster = new Cluster(getJobConf());
    for (JobStatus jobStatus : cluster.getAllJobStatuses()) {
        if (jobStatus.getJobID().toString().equals(jobId)) {
            job = JobUtils.getJob(jobStatus);
            Job j = cluster.getJob(jobStatus.getJobID());
            if (j == null) {
                break;
            }

            Calendar finishTime = Calendar.getInstance();
            finishTime.setTimeInMillis(j.getFinishTime());
            job.put(Response.FINISH_TIME, finishTime.getTime().toString());

            Map<String, Map<String, Long>> groups = new HashMap<String, Map<String, Long>>();
            for (String s : j.getCounters().getGroupNames()) {
                CounterGroup counterGroup = j.getCounters().getGroup(s);
                Iterator<Counter> ite = counterGroup.iterator();

                Map<String, Long> counters = new HashMap<String, Long>();
                groups.put(counterGroup.getDisplayName(), counters);
                while (ite.hasNext()) {
                    Counter counter = (Counter) ite.next();
                    counters.put(counter.getDisplayName(), counter.getValue());
                }
            }

            job.put(Response.GROUPS, groups);
            break;
        }
    }

    return job;
}

From source file:org.springframework.data.hadoop.batch.mapreduce.JobTasklet.java

License:Apache License

private static void saveJobStats(Job job, StepExecution stepExecution) {
    if (stepExecution == null) {
        return;/* w  w  w  .j  a  v  a 2s .  c o  m*/
    }
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    String statusPrefix = "Job Status::";
    executionContext.put(statusPrefix + "ID", JobUtils.getJobId(job).toString());
    executionContext.put(statusPrefix + "Name", job.getJobName());
    executionContext.put(statusPrefix + "Tracking URL", job.getTrackingURL());
    executionContext.put(statusPrefix + "State", JobUtils.getStatus(job).toString());
    try {
        for (String cgName : job.getCounters().getGroupNames()) {
            CounterGroup group = job.getCounters().getGroup(cgName);
            Iterator<Counter> ci = group.iterator();
            while (ci.hasNext()) {
                Counter c = ci.next();
                executionContext.put(group.getDisplayName().trim() + "::" + c.getDisplayName().trim(),
                        c.getValue());
            }
        }
    } catch (Exception ignore) {
    }
}