/** * Create a new framework group * @param id of the group * @return a new framework group */ public G newFrameworkGroup(int id) { String name; synchronized(CounterGroupFactory.class) { if (id < 0 || id >= i2s.size()) throwBadFrameGroupIdException(id); name = i2s.get(id); // should not throw here. } FrameworkGroupFactory<G> gf = fmap.get(name); if (gf == null) throwBadFrameGroupIdException(id); return gf.newGroup(name); }
/** * Create a new framework group * @param id of the group * @return a new framework group */ public G newFrameworkGroup(int id) { String name; synchronized(CounterGroupFactory.class) { if (id < 0 || id >= i2s.size()) throwBadFrameGroupIdException(id); name = i2s.get(id); // should not throw here. } FrameworkGroupFactory<G> gf = fmap.get(name); if (gf == null) throwBadFrameGroupIdException(id); return gf.newGroup(name); }
/** * Create a new framework group * @param id of the group * @return a new framework group */ public G newFrameworkGroup(int id) { String name; synchronized(CounterGroupFactory.class) { if (id < 0 || id >= i2s.size()) throwBadFrameGroupIdException(id); name = i2s.get(id); // should not throw here. } FrameworkGroupFactory<G> gf = fmap.get(name); if (gf == null) throwBadFrameGroupIdException(id); return gf.newGroup(name); }
/** * Create a new counter group * @param name of the group * @param displayName of the group * @param limits the counters limits policy object * @return a new counter group */ public G newGroup(String name, String displayName, Limits limits) { FrameworkGroupFactory<G> gf = fmap.get(name); if (gf != null) return gf.newGroup(name); if (name.equals(FS_GROUP_NAME)) { return newFileSystemGroup(); } else if (s2i.get(name) != null) { return newFrameworkGroup(s2i.get(name)); } return newGenericGroup(name, displayName, limits); }
/** * Create a new counter group * @param name of the group * @param displayName of the group * @param limits the counters limits policy object * @return a new counter group */ public G newGroup(String name, String displayName, Limits limits) { FrameworkGroupFactory<G> gf = fmap.get(name); if (gf != null) return gf.newGroup(name); if (name.equals(FS_GROUP_NAME)) { return newFileSystemGroup(); } else if (s2i.get(name) != null) { return newFrameworkGroup(s2i.get(name)); } return newGenericGroup(name, displayName, limits); }
/** * Create a new counter group * @param name of the group * @param displayName of the group * @param limits the counters limits policy object * @return a new counter group */ public G newGroup(String name, String displayName, Limits limits) { FrameworkGroupFactory<G> gf = fmap.get(name); if (gf != null) return gf.newGroup(name); if (name.equals(FS_GROUP_NAME)) { return newFileSystemGroup(); } else if (s2i.get(name) != null) { return newFrameworkGroup(s2i.get(name)); } return newGenericGroup(name, displayName, limits); }
/** * Create a new counter group * @param name of the group * @param displayName of the group * @param limits the counters limits policy object * @return a new counter group */ public G newGroup(String name, String displayName, Limits limits) { FrameworkGroupFactory<G> gf = fmap.get(name); if (gf != null) return gf.newGroup(name); if (name.equals(FS_GROUP_NAME)) { return newFileSystemGroup(); } else if (s2i.get(name) != null) { return newFrameworkGroup(s2i.get(name)); } return newGenericGroup(name, displayName, limits); }
/** * Create a new framework group * @param id of the group * @return a new framework group */ public G newFrameworkGroup(int id) { String name; synchronized(CounterGroupFactory.class) { if (id < 0 || id >= i2s.size()) throwBadFrameGroupIdException(id); name = i2s.get(id); // should not throw here. } FrameworkGroupFactory<G> gf = fmap.get(name); if (gf == null) throwBadFrameGroupIdException(id); return gf.newGroup(name); }
@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()); }
@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); }