MAPREDUCE-3686. Fixed two bugs in Counters because of which web app displays zero counter values for framework counters. Contributed by Bhallamudi Venkata Siva Kamesh.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1293775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f3cc891148
commit
f071323343
@ -174,6 +174,10 @@ Release 0.23.2 - UNRELEASED
|
||||
|
||||
MAPREDUCE-3910. Fixed a bug in CapacityScheduler LeafQueue which was causing
|
||||
app-submission to fail. (John George via vinodkv)
|
||||
|
||||
MAPREDUCE-3686. Fixed two bugs in Counters because of which web app displays
|
||||
zero counter values for framework counters. (Bhallamudi Venkata Siva Kamesh
|
||||
via vinodkv)
|
||||
|
||||
Release 0.23.1 - 2012-02-17
|
||||
|
||||
|
@ -326,12 +326,10 @@ public synchronized String toString() {
|
||||
*/
|
||||
public synchronized void incrAllCounters(AbstractCounters<C, G> other) {
|
||||
for(G right : other) {
|
||||
G left = groups.get(right.getName());
|
||||
String groupName = right.getName();
|
||||
G left = (isFrameworkGroup(groupName) ? fgroups : groups).get(groupName);
|
||||
if (left == null) {
|
||||
limits.checkGroups(groups.size() + 1);
|
||||
left = groupFactory.newGroup(right.getName(), right.getDisplayName(),
|
||||
limits);
|
||||
groups.put(right.getName(), left);
|
||||
left = addGroup(groupName, right.getDisplayName());
|
||||
}
|
||||
left.incrAllCounters(right);
|
||||
}
|
||||
|
@ -107,6 +107,8 @@ public G newGroup(String name, String displayName, Limits limits) {
|
||||
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);
|
||||
}
|
||||
|
@ -70,6 +70,29 @@ public void testCounterValue() {
|
||||
testMaxGroups(new Counters());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountersIncrement() {
|
||||
Counters fCounters = new Counters();
|
||||
Counter fCounter = fCounters.findCounter(FRAMEWORK_COUNTER);
|
||||
fCounter.setValue(100);
|
||||
Counter gCounter = fCounters.findCounter("test", "foo");
|
||||
gCounter.setValue(200);
|
||||
|
||||
Counters counters = new Counters();
|
||||
counters.incrAllCounters(fCounters);
|
||||
Counter counter;
|
||||
for (CounterGroup cg : fCounters) {
|
||||
CounterGroup group = counters.getGroup(cg.getName());
|
||||
if (group.getName().equals("test")) {
|
||||
counter = counters.findCounter("test", "foo");
|
||||
assertEquals(200, counter.getValue());
|
||||
} else {
|
||||
counter = counters.findCounter(FRAMEWORK_COUNTER);
|
||||
assertEquals(100, counter.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final Enum<?> FRAMEWORK_COUNTER = TaskCounter.CPU_MILLISECONDS;
|
||||
static final long FRAMEWORK_COUNTER_VALUE = 8;
|
||||
|
Loading…
Reference in New Issue
Block a user