hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r1143665 - in /hadoop/common/branches/MR-279/mapreduce: ./ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/ mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v...
Date Thu, 07 Jul 2011 06:23:11 GMT
Author: sharad
Date: Thu Jul  7 06:23:10 2011
New Revision: 1143665

URL: http://svn.apache.org/viewvc?rev=1143665&view=rev
Log:
MAPREDUCE-2633. Add a getCounter(Enum) method to the Counters record. Contributed by Josh
Wills.

Modified:
    hadoop/common/branches/MR-279/mapreduce/CHANGES.txt
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/Counters.java
    hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/impl/pb/CountersPBImpl.java

Modified: hadoop/common/branches/MR-279/mapreduce/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/CHANGES.txt?rev=1143665&r1=1143664&r2=1143665&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/CHANGES.txt (original)
+++ hadoop/common/branches/MR-279/mapreduce/CHANGES.txt Thu Jul  7 06:23:10 2011
@@ -5,6 +5,9 @@ Trunk (unreleased changes)
 
     MAPREDUCE-279
 
+    MAPREDUCE-2633. Add a getCounter(Enum) method to the Counters record. 
+    (Josh Wills via sharad)
+
     Reinstate resolve path fixes for viewfs. (Siddharth Seth via llu)
 
     Major ASM cleanup. Streamlining classes, interface and events. (vinodkv)

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java?rev=1143665&r1=1143664&r2=1143665&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java
Thu Jul  7 06:23:10 2011
@@ -946,43 +946,25 @@ public abstract class TaskAttemptImpl im
             (int) (now - start));
       }
 
-      // TODO Fix the Counter API
-      CounterGroup cpuCounterGroup = counters
-          .getCounterGroup(TaskCounter.CPU_MILLISECONDS.getDeclaringClass()
-              .getName());
-      if (cpuCounterGroup != null) {
-        Counter cpuCounter = cpuCounterGroup
-            .getCounter(TaskCounter.CPU_MILLISECONDS.name());
-        if (cpuCounter != null && cpuCounter.getValue() <= Integer.MAX_VALUE)
{
-          splitsBlock.getProgressCPUTime().extend(newProgress,
-              (int) cpuCounter.getValue());
-        }
-      }
-
-      // TODO Fix the Counter API
-      CounterGroup vbCounterGroup = counters
-          .getCounterGroup(TaskCounter.VIRTUAL_MEMORY_BYTES.getDeclaringClass()
-              .getName());
-      if (vbCounterGroup != null) {
-        Counter virtualBytes = vbCounterGroup
-            .getCounter(TaskCounter.VIRTUAL_MEMORY_BYTES.name());
-        if (virtualBytes != null) {
-          splitsBlock.getProgressVirtualMemoryKbytes().extend(newProgress,
-              (int) (virtualBytes.getValue() / (MEMORY_SPLITS_RESOLUTION)));
-        }
-      }
-
-      // TODO Fix the Counter API
-      CounterGroup pbCounterGroup = counters
-          .getCounterGroup(TaskCounter.PHYSICAL_MEMORY_BYTES
-              .getDeclaringClass().getName());
-      if (pbCounterGroup != null) {
-        Counter physicalBytes = pbCounterGroup
-            .getCounter(TaskCounter.PHYSICAL_MEMORY_BYTES.name());
-        if (physicalBytes != null) {
-          splitsBlock.getProgressPhysicalMemoryKbytes().extend(newProgress,
-              (int) (physicalBytes.getValue() / (MEMORY_SPLITS_RESOLUTION)));
-        }
+      Counter cpuCounter = counters.getCounter(
+          TaskCounter.CPU_MILLISECONDS);
+      if (cpuCounter != null && cpuCounter.getValue() <= Integer.MAX_VALUE) {
+        splitsBlock.getProgressCPUTime().extend(newProgress,
+            (int) cpuCounter.getValue());
+      }
+
+      Counter virtualBytes = counters.getCounter(
+          TaskCounter.VIRTUAL_MEMORY_BYTES);
+      if (virtualBytes != null) {
+        splitsBlock.getProgressVirtualMemoryKbytes().extend(newProgress,
+            (int) (virtualBytes.getValue() / (MEMORY_SPLITS_RESOLUTION)));
+      }
+
+      Counter physicalBytes = counters.getCounter(
+          TaskCounter.PHYSICAL_MEMORY_BYTES);
+      if (physicalBytes != null) {
+        splitsBlock.getProgressPhysicalMemoryKbytes().extend(newProgress,
+            (int) (physicalBytes.getValue() / (MEMORY_SPLITS_RESOLUTION)));
       }
     }
   }

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/Counters.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/Counters.java?rev=1143665&r1=1143664&r2=1143665&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/Counters.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/Counters.java
Thu Jul  7 06:23:10 2011
@@ -5,6 +5,7 @@ import java.util.Map;
 public interface Counters {
   public abstract Map<String, CounterGroup> getAllCounterGroups();
   public abstract CounterGroup getCounterGroup(String key);
+  public abstract Counter getCounter(Enum<?> key);
   
   public abstract void addAllCounterGroups(Map<String, CounterGroup> counterGroups);
   public abstract void setCounterGroup(String key, CounterGroup value);

Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/impl/pb/CountersPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/impl/pb/CountersPBImpl.java?rev=1143665&r1=1143664&r2=1143665&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/impl/pb/CountersPBImpl.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/api/records/impl/pb/CountersPBImpl.java
Thu Jul  7 06:23:10 2011
@@ -6,6 +6,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.hadoop.mapreduce.v2.api.records.Counter;
 import org.apache.hadoop.mapreduce.v2.api.records.CounterGroup;
 import org.apache.hadoop.mapreduce.v2.api.records.Counters;
 import org.apache.hadoop.mapreduce.v2.proto.MRProtos.CounterGroupProto;
@@ -20,9 +21,9 @@ public class CountersPBImpl extends Prot
   CountersProto proto = CountersProto.getDefaultInstance();
   CountersProto.Builder builder = null;
   boolean viaProto = false;
-  
+
   private Map<String, CounterGroup> counterGroups = null;
-  
+
   
   public CountersPBImpl() {
     builder = CountersProto.newBuilder();
@@ -72,7 +73,12 @@ public class CountersPBImpl extends Prot
     initCounterGroups();
     return this.counterGroups.get(key);
   }
-  
+  @Override
+  public Counter getCounter(Enum<?> key) {
+    CounterGroup group = getCounterGroup(key.getDeclaringClass().getName());
+    return group == null ? null : group.getCounter(key.name());
+  }
+ 
   private void initCounterGroups() {
     if (this.counterGroups != null) {
       return;



Mime
View raw message