hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r1357777 - in /hadoop/common/branches/branch-2/hadoop-mapreduce-project: ./ hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/ hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/...
Date Thu, 05 Jul 2012 18:10:51 GMT
Author: bobby
Date: Thu Jul  5 18:10:51 2012
New Revision: 1357777

URL: http://svn.apache.org/viewvc?rev=1357777&view=rev
Log:
svn merge -c 1357776 FIXES: MAPREDUCE-4392. Counters.makeCompactString() changed behavior
from 0.20 (Jason Lowe via bobby)

Modified:
    hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java
    hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java

Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt?rev=1357777&r1=1357776&r2=1357777&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt Thu Jul  5 18:10:51
2012
@@ -511,6 +511,9 @@ Release 0.23.3 - UNRELEASED
     MAPREDUCE-4228. mapreduce.job.reduce.slowstart.completedmaps is not working
     properly (Jason Lowe via bobby)
 
+    MAPREDUCE-4392. Counters.makeCompactString() changed behavior from 0.20
+    (Jason Lowe via bobby)
+
 Release 0.23.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java?rev=1357777&r1=1357776&r2=1357777&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java
Thu Jul  5 18:10:51 2012
@@ -90,7 +90,23 @@ public class Counters
   }
 
   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();
   }
   
   /**

Modified: hadoop/common/branches/branch-2/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/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java?rev=1357777&r1=1357776&r2=1357777&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java
Thu Jul  5 18:10:51 2012
@@ -224,6 +224,19 @@ public class TestCounters {
     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 {
     new TestCounters().testCounters();
   }



Mime
View raw message