hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r664074 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/mapred/JobClient.java
Date Fri, 06 Jun 2008 18:49:13 GMT
Author: omalley
Date: Fri Jun  6 11:49:13 2008
New Revision: 664074

URL: http://svn.apache.org/viewvc?rev=664074&view=rev
Log:
HADOOP-3230. Add ability to get counter values from command line. Contributed by Tom White.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobClient.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=664074&r1=664073&r2=664074&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Fri Jun  6 11:49:13 2008
@@ -146,6 +146,9 @@
     HADOOP-3460. Add SequenceFileAsBinaryOutputFormat to permit direct
     writes of serialized data. (Koji Noguchi via cdouglas)
 
+    HADOOP-3230. Add ability to get counter values from command
+    line. (tomwhite via omalley)
+
   IMPROVEMENTS
    
     HADOOP-2928. Remove deprecated FileSystem.getContentLength().

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobClient.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobClient.java?rev=664074&r1=664073&r2=664074&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobClient.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/mapred/JobClient.java Fri Jun  6 11:49:13
2008
@@ -58,6 +58,8 @@
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableUtils;
 import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.mapred.Counters.Counter;
+import org.apache.hadoop.mapred.Counters.Group;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.UnixUserGroupInformation;
 import org.apache.hadoop.util.StringUtils;
@@ -1173,6 +1175,8 @@
       System.err.println(prefix + "[" + cmd + " <job-file>]");
     } else if ("-status".equals(cmd) || "-kill".equals(cmd)) {
       System.err.println(prefix + "[" + cmd + " <job-id>]");
+    } else if ("-counter".equals(cmd)) {
+      System.err.println(prefix + "[" + cmd + " <job-id> <group-name> <counter-name>]");
     } else if ("-events".equals(cmd)) {
       System.err.println(prefix + "[" + cmd + " <job-id> <from-event-#> <#-of-events>]");
     } else if ("-history".equals(cmd)) {
@@ -1185,6 +1189,7 @@
       System.err.printf(prefix + "<command> <args>\n");
       System.err.printf("\t[-submit <job-file>]\n");
       System.err.printf("\t[-status <job-id>]\n");
+      System.err.printf("\t[-counter <job-id> <group-name> <counter-name>]\n");
       System.err.printf("\t[-kill <job-id>]\n");
       System.err.printf("\t[-events <job-id> <from-event-#> <#-of-events>]\n");
       System.err.printf("\t[-history <jobOutputDir>]\n");
@@ -1207,9 +1212,12 @@
     String jobid = null;
     String taskid = null;
     String outputDir = null;
+    String counterGroupName = null;
+    String counterName = null;
     int fromEvent = 0;
     int nEvents = 0;
     boolean getStatus = false;
+    boolean getCounter = false;
     boolean killJob = false;
     boolean listEvents = false;
     boolean viewHistory = false;
@@ -1232,6 +1240,15 @@
       }
       jobid = argv[1];
       getStatus = true;
+    } else if("-counter".equals(cmd)) {
+      if (argv.length != 4) {
+        displayUsage(cmd);
+        return exitCode;
+      }
+      getCounter = true;
+      jobid = argv[1];
+      counterGroupName = argv[2];
+      counterName = argv[3];
     } else if ("-kill".equals(cmd)) {
       if (argv.length != 2) {
         displayUsage(cmd);
@@ -1314,6 +1331,17 @@
           System.out.println(job.getCounters());
           exitCode = 0;
         }
+      } else if (getCounter) {
+        RunningJob job = getJob(JobID.forName(jobid));
+        if (job == null) {
+          System.out.println("Could not find job " + jobid);
+        } else {
+          Counters counters = job.getCounters();
+          Group group = counters.getGroup(counterGroupName);
+          Counter counter = group.getCounterForName(counterName);
+          System.out.println(counter.getCounter());
+          exitCode = 0;
+        }
       } else if (killJob) {
         RunningJob job = getJob(JobID.forName(jobid));
         if (job == null) {



Mime
View raw message