Search in sources :

Example 11 with Counter

use of org.apache.hadoop.mapreduce.v2.api.records.Counter in project hadoop by apache.

the class CountersPBImpl method incrCounter.

@Override
public void incrCounter(Enum<?> key, long amount) {
    String groupName = key.getDeclaringClass().getName();
    if (getCounterGroup(groupName) == null) {
        CounterGroup cGrp = new CounterGroupPBImpl();
        cGrp.setName(groupName);
        cGrp.setDisplayName(groupName);
        setCounterGroup(groupName, cGrp);
    }
    if (getCounterGroup(groupName).getCounter(key.name()) == null) {
        Counter c = new CounterPBImpl();
        c.setName(key.name());
        c.setDisplayName(key.name());
        c.setValue(0l);
        getCounterGroup(groupName).setCounter(key.name(), c);
    }
    Counter counter = getCounterGroup(groupName).getCounter(key.name());
    counter.setValue(counter.getValue() + amount);
}
Also used : Counter(org.apache.hadoop.mapreduce.v2.api.records.Counter) CounterGroup(org.apache.hadoop.mapreduce.v2.api.records.CounterGroup)

Example 12 with Counter

use of org.apache.hadoop.mapreduce.v2.api.records.Counter in project hadoop by apache.

the class TestClientServiceDelegate method getCountersResponseFromHistoryServer.

private GetCountersResponse getCountersResponseFromHistoryServer() {
    GetCountersResponse countersResponse = Records.newRecord(GetCountersResponse.class);
    Counter counter = Records.newRecord(Counter.class);
    CounterGroup counterGroup = Records.newRecord(CounterGroup.class);
    Counters counters = Records.newRecord(Counters.class);
    counter.setDisplayName("dummyCounter");
    counter.setName("dummyCounter");
    counter.setValue(1001);
    counterGroup.setName("dummyCounters");
    counterGroup.setDisplayName("dummyCounters");
    counterGroup.setCounter("dummyCounter", counter);
    counters.setCounterGroup("dummyCounters", counterGroup);
    countersResponse.setCounters(counters);
    return countersResponse;
}
Also used : GetCountersResponse(org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetCountersResponse) Counter(org.apache.hadoop.mapreduce.v2.api.records.Counter) CounterGroup(org.apache.hadoop.mapreduce.v2.api.records.CounterGroup) Counters(org.apache.hadoop.mapreduce.v2.api.records.Counters)

Aggregations

Counter (org.apache.hadoop.mapreduce.v2.api.records.Counter)6 CounterGroup (org.apache.hadoop.mapreduce.v2.api.records.CounterGroup)5 Counters (org.apache.hadoop.mapreduce.Counters)4 Counters (org.apache.hadoop.mapreduce.v2.api.records.Counters)4 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)3 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)3 Test (org.junit.Test)3 Path (org.apache.hadoop.fs.Path)2 Counter (org.apache.hadoop.mapreduce.Counter)2 Job (org.apache.hadoop.mapreduce.Job)2 TaskAttemptId (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 RemoteException (org.apache.hadoop.ipc.RemoteException)1 Counter (org.apache.hadoop.mapred.Counters.Counter)1