Search in sources :

Example 41 with Counter

use of org.apache.hadoop.mapreduce.Counter in project hadoop by apache.

the class JSONHistoryViewerPrinter method printTaskCounters.

private void printTaskCounters(JSONObject jTask, Counters taskCounters) throws JSONException {
    // Killed tasks might not have counters
    if (taskCounters != null) {
        JSONObject jGroups = new JSONObject();
        for (String groupName : taskCounters.getGroupNames()) {
            CounterGroup group = taskCounters.getGroup(groupName);
            Iterator<Counter> ctrItr = group.iterator();
            JSONArray jGroup = new JSONArray();
            while (ctrItr.hasNext()) {
                JSONObject jCounter = new JSONObject();
                org.apache.hadoop.mapreduce.Counter counter = ctrItr.next();
                jCounter.put("counterName", counter.getName());
                jCounter.put("value", counter.getValue());
                jGroup.put(jCounter);
            }
            jGroups.put(fixGroupNameForShuffleErrors(group.getName()), jGroup);
        }
        jTask.put("counters", jGroups);
    }
}
Also used : Counter(org.apache.hadoop.mapreduce.Counter) JSONObject(org.codehaus.jettison.json.JSONObject) CounterGroup(org.apache.hadoop.mapreduce.CounterGroup) Counter(org.apache.hadoop.mapreduce.Counter) JSONArray(org.codehaus.jettison.json.JSONArray)

Example 42 with Counter

use of org.apache.hadoop.mapreduce.Counter in project hadoop by apache.

the class AbstractCounterGroup method incrAllCounters.

@Override
public void incrAllCounters(CounterGroupBase<T> rightGroup) {
    try {
        for (Counter right : rightGroup) {
            Counter left = findCounter(right.getName(), right.getDisplayName());
            left.increment(right.getValue());
        }
    } catch (LimitExceededException e) {
        counters.clear();
        throw e;
    }
}
Also used : Counter(org.apache.hadoop.mapreduce.Counter)

Example 43 with Counter

use of org.apache.hadoop.mapreduce.Counter in project hadoop by apache.

the class JobHistoryEventUtils method countersToJSON.

public static JsonNode countersToJSON(Counters counters) {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode nodes = mapper.createArrayNode();
    if (counters != null) {
        for (CounterGroup counterGroup : counters) {
            ObjectNode groupNode = nodes.addObject();
            groupNode.put("NAME", counterGroup.getName());
            groupNode.put("DISPLAY_NAME", counterGroup.getDisplayName());
            ArrayNode countersNode = groupNode.putArray("COUNTERS");
            for (Counter counter : counterGroup) {
                ObjectNode counterNode = countersNode.addObject();
                counterNode.put("NAME", counter.getName());
                counterNode.put("DISPLAY_NAME", counter.getDisplayName());
                counterNode.put("VALUE", counter.getValue());
            }
        }
    }
    return nodes;
}
Also used : Counter(org.apache.hadoop.mapreduce.Counter) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) CounterGroup(org.apache.hadoop.mapreduce.CounterGroup) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 44 with Counter

use of org.apache.hadoop.mapreduce.Counter in project hadoop by apache.

the class OldAPICombinerTest method testWordCountCombinerWithOldAPI.

@Test
public void testWordCountCombinerWithOldAPI() throws Exception {
    final Configuration nativeConf = ScenarioConfiguration.getNativeConfiguration();
    nativeConf.addResource(TestConstants.COMBINER_CONF_PATH);
    final String nativeoutput = TestConstants.NATIVETASK_OLDAPI_COMBINER_TEST_NATIVE_OUTPUTPATH;
    final JobConf nativeJob = getOldAPIJobconf(nativeConf, "nativeCombinerWithOldAPI", inputpath, nativeoutput);
    RunningJob nativeRunning = JobClient.runJob(nativeJob);
    Counter nativeReduceGroups = nativeRunning.getCounters().findCounter(TaskCounter.REDUCE_INPUT_RECORDS);
    final Configuration normalConf = ScenarioConfiguration.getNormalConfiguration();
    normalConf.addResource(TestConstants.COMBINER_CONF_PATH);
    final String normaloutput = TestConstants.NATIVETASK_OLDAPI_COMBINER_TEST_NORMAL_OUTPUTPATH;
    final JobConf normalJob = getOldAPIJobconf(normalConf, "normalCombinerWithOldAPI", inputpath, normaloutput);
    RunningJob normalRunning = JobClient.runJob(normalJob);
    Counter normalReduceGroups = normalRunning.getCounters().findCounter(TaskCounter.REDUCE_INPUT_RECORDS);
    final boolean compareRet = ResultVerifier.verify(nativeoutput, normaloutput);
    assertEquals("file compare result: if they are the same ,then return true", true, compareRet);
    assertEquals("The input reduce record count must be same", nativeReduceGroups.getValue(), normalReduceGroups.getValue());
}
Also used : Counter(org.apache.hadoop.mapreduce.Counter) TaskCounter(org.apache.hadoop.mapreduce.TaskCounter) Configuration(org.apache.hadoop.conf.Configuration) ScenarioConfiguration(org.apache.hadoop.mapred.nativetask.testutil.ScenarioConfiguration) RunningJob(org.apache.hadoop.mapred.RunningJob) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Example 45 with Counter

use of org.apache.hadoop.mapreduce.Counter in project ignite by apache.

the class HadoopMapReduceCounterGroup method addCounter.

/**
 * {@inheritDoc}
 */
@Override
public Counter addCounter(String name, String displayName, long value) {
    final Counter counter = cntrs.findCounter(this.name, name);
    counter.setValue(value);
    return counter;
}
Also used : Counter(org.apache.hadoop.mapreduce.Counter)

Aggregations

Counter (org.apache.hadoop.mapreduce.Counter)51 Configuration (org.apache.hadoop.conf.Configuration)15 CounterGroup (org.apache.hadoop.mapreduce.CounterGroup)13 Job (org.apache.hadoop.mapreduce.Job)12 Counters (org.apache.hadoop.mapreduce.Counters)11 IOException (java.io.IOException)8 Path (org.apache.hadoop.fs.Path)7 Map (java.util.Map)4 FileSystem (org.apache.hadoop.fs.FileSystem)4 Test (org.junit.Test)4 TaskCounter (org.apache.hadoop.mapreduce.TaskCounter)3 FileNotFoundException (java.io.FileNotFoundException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 ExecutionException (java.util.concurrent.ExecutionException)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 Schema (org.apache.avro.Schema)2 CustomOutputCommitter (org.apache.hadoop.CustomOutputCommitter)2 BytesWritable (org.apache.hadoop.io.BytesWritable)2