Author: tgraves Date: Mon Aug 13 21:48:33 2012 New Revision: 1372636 URL: http://svn.apache.org/viewvc?rev=1372636&view=rev Log: MAPREDUCE-4053. Counters group names deprecation is wrong, iterating over group names deprecated names don't show up (Robert Evans via tgraves)
Modified: hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java Modified: hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt?rev=1372636&r1=1372635&r2=1372636&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt Mon Aug 13 21:48:33 2012 @@ -809,6 +809,9 @@ Release 0.23.3 - UNRELEASED MAPREDUCE-3782. teragen terasort jobs fail when using webhdfs:// (Jason Lowe via bobby) + MAPREDUCE-4053. Counters group names deprecation is wrong, iterating over + group names deprecated names don't show up (Robert Evans via tgraves) + Release 0.23.2 - UNRELEASED INCOMPATIBLE CHANGES Modified: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java?rev=1372636&r1=1372635&r2=1372636&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java (original) +++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java Mon Aug 13 21:48:33 2012 @@ -24,6 +24,7 @@ import static org.apache.hadoop.mapreduc import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentSkipListMap; @@ -185,7 +186,15 @@ public abstract class AbstractCounters<C * @return Set of counter names. */ public synchronized Iterable<String> getGroupNames() { - return Iterables.concat(fgroups.keySet(), groups.keySet()); + HashSet<String> deprecated = new HashSet<String>(); + for(Map.Entry<String, String> entry : legacyMap.entrySet()) { + String newGroup = entry.getValue(); + boolean isFGroup = isFrameworkGroup(newGroup); + if(isFGroup ? fgroups.containsKey(newGroup) : groups.containsKey(newGroup)) { + deprecated.add(entry.getKey()); + } + } + return Iterables.concat(fgroups.keySet(), groups.keySet(), deprecated); } @Override Modified: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java?rev=1372636&r1=1372635&r2=1372636&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java (original) +++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java Mon Aug 13 21:48:33 2012 @@ -22,6 +22,7 @@ import static org.junit.Assert.assertTru import java.io.IOException; import java.text.ParseException; +import java.util.HashSet; import java.util.Iterator; import java.util.Random; @@ -225,6 +226,23 @@ public class TestCounters { } @Test + public void testLegacyGetGroupNames() { + Counters counters = new Counters(); + // create 2 filesystem counter groups + counters.findCounter("fs1", FileSystemCounter.BYTES_READ).increment(1); + counters.findCounter("fs2", FileSystemCounter.BYTES_READ).increment(1); + counters.incrCounter("group1", "counter1", 1); + + HashSet<String> groups = new HashSet<String>(counters.getGroupNames()); + HashSet<String> expectedGroups = new HashSet<String>(); + expectedGroups.add("group1"); + expectedGroups.add("FileSystemCounter"); //Legacy Name + expectedGroups.add("org.apache.hadoop.mapreduce.FileSystemCounter"); + + assertEquals(expectedGroups, groups); + } + + @Test public void testMakeCompactString() { final String GC1 = "group1.counter1:1"; final String GC2 = "group2.counter2:3";