merge -r 1372635:1372636 from trunk. FIXES: MAPREDUCE-4053
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1372638 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c8abfa4305
commit
6f516ea1bf
|
@ -685,6 +685,9 @@ Release 0.23.3 - UNRELEASED
|
||||||
MAPREDUCE-3782. teragen terasort jobs fail when using webhdfs:// (Jason
|
MAPREDUCE-3782. teragen terasort jobs fail when using webhdfs:// (Jason
|
||||||
Lowe via bobby)
|
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
|
Release 0.23.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.apache.hadoop.mapreduce.counters.CounterGroupFactory.isFramewo
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
|
@ -185,7 +186,15 @@ public abstract class AbstractCounters<C extends Counter,
|
||||||
* @return Set of counter names.
|
* @return Set of counter names.
|
||||||
*/
|
*/
|
||||||
public synchronized Iterable<String> getGroupNames() {
|
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
|
@Override
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -224,6 +225,23 @@ public class TestCounters {
|
||||||
iterator.next();
|
iterator.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void testMakeCompactString() {
|
public void testMakeCompactString() {
|
||||||
final String GC1 = "group1.counter1:1";
|
final String GC1 = "group1.counter1:1";
|
||||||
|
|
Loading…
Reference in New Issue