Search in sources :

Example 1 with FrameworkCounterGroup

use of org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup in project hadoop by apache.

the class GroupFactoryForTest method testTaskCounter.

@SuppressWarnings("rawtypes")
@Test
public void testTaskCounter() {
    GroupFactory groupFactory = new GroupFactoryForTest();
    FrameworkGroupFactory frameworkGroupFactory = groupFactory.newFrameworkGroupFactory(TaskCounter.class);
    Group group = (Group) frameworkGroupFactory.newGroup("TaskCounter");
    FrameworkCounterGroup counterGroup = (FrameworkCounterGroup) group.getUnderlyingGroup();
    org.apache.hadoop.mapreduce.Counter count1 = counterGroup.findCounter(TaskCounter.PHYSICAL_MEMORY_BYTES.toString());
    Assert.assertNotNull(count1);
    count1.increment(10);
    count1.increment(10);
    Assert.assertEquals(20, count1.getValue());
    // Verify no exception get thrown when finding an unknown counter
    org.apache.hadoop.mapreduce.Counter count2 = counterGroup.findCounter(TaskCounter.MAP_PHYSICAL_MEMORY_BYTES_MAX.toString());
    Assert.assertNotNull(count2);
    count2.increment(5);
    count2.increment(10);
    Assert.assertEquals(10, count2.getValue());
}
Also used : FrameworkCounterGroup(org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup) Group(org.apache.hadoop.mapred.Counters.Group) FrameworkCounterGroup(org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup) FrameworkGroupFactory(org.apache.hadoop.mapreduce.counters.CounterGroupFactory.FrameworkGroupFactory) GroupFactory(org.apache.hadoop.mapred.Counters.GroupFactory) FrameworkGroupFactory(org.apache.hadoop.mapreduce.counters.CounterGroupFactory.FrameworkGroupFactory) Test(org.junit.Test)

Example 2 with FrameworkCounterGroup

use of org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup in project hadoop by apache.

the class GroupFactoryForTest method testFrameworkCounter.

@SuppressWarnings("rawtypes")
@Test
public void testFrameworkCounter() {
    GroupFactory groupFactory = new GroupFactoryForTest();
    FrameworkGroupFactory frameworkGroupFactory = groupFactory.newFrameworkGroupFactory(JobCounter.class);
    Group group = (Group) frameworkGroupFactory.newGroup("JobCounter");
    FrameworkCounterGroup counterGroup = (FrameworkCounterGroup) group.getUnderlyingGroup();
    org.apache.hadoop.mapreduce.Counter count1 = counterGroup.findCounter(JobCounter.NUM_FAILED_MAPS.toString());
    Assert.assertNotNull(count1);
    // Verify no exception get thrown when finding an unknown counter
    org.apache.hadoop.mapreduce.Counter count2 = counterGroup.findCounter("Unknown");
    Assert.assertNull(count2);
}
Also used : FrameworkCounterGroup(org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup) Group(org.apache.hadoop.mapred.Counters.Group) FrameworkCounterGroup(org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup) FrameworkGroupFactory(org.apache.hadoop.mapreduce.counters.CounterGroupFactory.FrameworkGroupFactory) GroupFactory(org.apache.hadoop.mapred.Counters.GroupFactory) FrameworkGroupFactory(org.apache.hadoop.mapreduce.counters.CounterGroupFactory.FrameworkGroupFactory) Test(org.junit.Test)

Aggregations

Group (org.apache.hadoop.mapred.Counters.Group)2 GroupFactory (org.apache.hadoop.mapred.Counters.GroupFactory)2 FrameworkGroupFactory (org.apache.hadoop.mapreduce.counters.CounterGroupFactory.FrameworkGroupFactory)2 FrameworkCounterGroup (org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup)2 Test (org.junit.Test)2