hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1079204 - in /hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters: AbstractCounters.java CounterGroupFactory.java FileSystemCounterGroup.java
Date Tue, 08 Mar 2011 05:55:27 GMT
Author: omalley
Date: Tue Mar  8 05:55:26 2011
New Revision: 1079204

URL: http://svn.apache.org/viewvc?rev=1079204&view=rev
Log:
commit 2ccbccfe43e8c9c1eae3c379120d137594ea42be
Author: Luke Lu <llu@yahoo-inc.com>
Date:   Tue Dec 7 03:26:12 2010 -0800

     Fix filesystem counters

Modified:
    hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java
    hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/CounterGroupFactory.java
    hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java

Modified: hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java?rev=1079204&r1=1079203&r2=1079204&view=diff
==============================================================================
--- hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java
(original)
+++ hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java
Tue Mar  8 05:55:26 2011
@@ -114,11 +114,12 @@ public abstract class AbstractCounters<C
    */
   @InterfaceAudience.Private
   public synchronized G addGroup(G group) {
-    if (isFrameworkGroup(group)) {
-      fgroups.put(group.getName(), group);
+    String name = group.getName();
+    if (isFrameworkGroup(name)) {
+      fgroups.put(name, group);
     } else {
-      groupFactory.limits().checkGroups(groups.size() + 1);
-      groups.put(group.getName(), group);
+      limits.checkGroups(groups.size() + 1);
+      groups.put(name, group);
     }
     return group;
   }

Modified: hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/CounterGroupFactory.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/CounterGroupFactory.java?rev=1079204&r1=1079203&r2=1079204&view=diff
==============================================================================
--- hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/CounterGroupFactory.java
(original)
+++ hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/CounterGroupFactory.java
Tue Mar  8 05:55:26 2011
@@ -50,6 +50,7 @@ public abstract class CounterGroupFactor
   private static final Map<String, Integer> s2i = Maps.newHashMap();
   private static final List<String> i2s = Lists.newArrayList();
   private static final int VERSION = 1;
+  private static final String FS_GROUP_NAME = FileSystemCounter.class.getName();
 
   private final Map<String, FrameworkGroupFactory<G>> fmap = Maps.newHashMap();
   {
@@ -104,7 +105,7 @@ public abstract class CounterGroupFactor
   public G newGroup(String name, String displayName, Limits limits) {
     FrameworkGroupFactory<G> gf = fmap.get(name);
     if (gf != null) return gf.newGroup(name);
-    if (name.equals(FileSystemCounter.class.getName())) {
+    if (name.equals(FS_GROUP_NAME)) {
       return newFileSystemGroup();
     }
     return newGenericGroup(name, displayName, limits);
@@ -145,21 +146,14 @@ public abstract class CounterGroupFactor
   }
 
   /**
-   * Check whether a group name is a name of a framework group
+   * Check whether a group name is a name of a framework group (including
+   * the filesystem group).
+   *
    * @param name  to check
    * @return true for framework group names
    */
   public static synchronized boolean isFrameworkGroup(String name) {
-    return s2i.get(name) != null;
-  }
-
-  /**
-   * Check whether a group object is name of a framework group
-   * @param group object to check
-   * @return true for framework groups
-   */
-  public static boolean isFrameworkGroup(CounterGroupBase<?> group) {
-    return isFrameworkGroup(group.getName());
+    return s2i.get(name) != null || name.equals(FS_GROUP_NAME);
   }
 
   private static void throwBadFrameGroupIdException(int id) {

Modified: hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java?rev=1079204&r1=1079203&r2=1079204&view=diff
==============================================================================
--- hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java
(original)
+++ hadoop/mapreduce/branches/yahoo-merge/src/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java
Tue Mar  8 05:55:26 2011
@@ -57,6 +57,9 @@ public abstract class FileSystemCounterG
   private final Map<String, Object[]> map = Maps.newTreeMap();
   private String displayName;
 
+  private static final Joiner NAME_JOINER = Joiner.on('_');
+  private static final Joiner DISP_JOINER = Joiner.on(": ");
+
   @InterfaceAudience.Private
   public class FSCounter extends AbstractCounter {
     final String scheme;
@@ -70,12 +73,12 @@ public abstract class FileSystemCounterG
 
     @Override
     public String getName() {
-      return Joiner.on('_').join(scheme, key.name());
+      return NAME_JOINER.join(scheme, key.name());
     }
 
     @Override
     public String getDisplayName() {
-      return Joiner.on(": ").join(scheme, localizeCounterName(key.name()));
+      return DISP_JOINER.join(scheme, localizeCounterName(key.name()));
     }
 
     protected String localizeCounterName(String counterName) {
@@ -155,7 +158,7 @@ public abstract class FileSystemCounterG
     if (schemeEnd < 0) {
       throw new IllegalArgumentException("bad fs counter name");
     }
-    return new String[]{counterName.substring(0, schemeEnd - 1),
+    return new String[]{counterName.substring(0, schemeEnd),
                         counterName.substring(schemeEnd + 1)};
   }
 



Mime
View raw message