MAPREDUCE-4392. Counters.makeCompactString() changed behavior from 0.20 (Jason Lowe via bobby)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1357776 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72fb517469
commit
c1bf8a3f03
|
@ -635,6 +635,9 @@ Release 0.23.3 - UNRELEASED
|
||||||
MAPREDUCE-4228. mapreduce.job.reduce.slowstart.completedmaps is not working
|
MAPREDUCE-4228. mapreduce.job.reduce.slowstart.completedmaps is not working
|
||||||
properly (Jason Lowe via bobby)
|
properly (Jason Lowe via bobby)
|
||||||
|
|
||||||
|
MAPREDUCE-4392. Counters.makeCompactString() changed behavior from 0.20
|
||||||
|
(Jason Lowe via bobby)
|
||||||
|
|
||||||
Release 0.23.2 - UNRELEASED
|
Release 0.23.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -90,7 +90,23 @@ public class Counters
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String makeCompactString() {
|
public synchronized String makeCompactString() {
|
||||||
return CountersStrings.toEscapedCompactString(this);
|
StringBuilder builder = new StringBuilder();
|
||||||
|
boolean first = true;
|
||||||
|
for(Group group: this){
|
||||||
|
for(Counter counter: group) {
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
builder.append(',');
|
||||||
|
}
|
||||||
|
builder.append(group.getDisplayName());
|
||||||
|
builder.append('.');
|
||||||
|
builder.append(counter.getDisplayName());
|
||||||
|
builder.append(':');
|
||||||
|
builder.append(counter.getCounter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -224,6 +224,19 @@ public class TestCounters {
|
||||||
iterator.next();
|
iterator.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMakeCompactString() {
|
||||||
|
final String GC1 = "group1.counter1:1";
|
||||||
|
final String GC2 = "group2.counter2:3";
|
||||||
|
Counters counters = new Counters();
|
||||||
|
counters.incrCounter("group1", "counter1", 1);
|
||||||
|
assertEquals("group1.counter1:1", counters.makeCompactString());
|
||||||
|
counters.incrCounter("group2", "counter2", 3);
|
||||||
|
String cs = counters.makeCompactString();
|
||||||
|
assertTrue("Bad compact string",
|
||||||
|
cs.equals(GC1 + ',' + GC2) || cs.equals(GC2 + ',' + GC1));
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
new TestCounters().testCounters();
|
new TestCounters().testCounters();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue