hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r420764 - in /lucene/hadoop/trunk: ./ src/java/org/apache/hadoop/mapred/
Date Tue, 11 Jul 2006 08:43:30 GMT
Author: cutting
Date: Tue Jul 11 01:43:29 2006
New Revision: 420764

URL: http://svn.apache.org/viewvc?rev=420764&view=rev
Log:
HADOOP-339.  Add a method to the JobClient API listing jobs that are not yet complete.  Contributed
by Mahadev.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobSubmissionProtocol.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/LocalJobRunner.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=420764&r1=420763&r2=420764&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue Jul 11 01:43:29 2006
@@ -10,6 +10,10 @@
  2. HADOOP-313.  Permit task state to be saved so that single tasks
     may be manually re-executed when debugging.  (omalley via cutting)
 
+ 3. HADOOP-339.  Add method to JobClient API listing jobs that are
+    not yet complete, i.e., that are queued or running.
+    (Mahadev Konar via cutting)
+
 
 Release 0.4.0 - 2006-06-28
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java?rev=420764&r1=420763&r2=420764&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java Tue Jul 11 01:43:29
2006
@@ -314,6 +314,10 @@
       return jobSubmitClient.getClusterStatus();
     }
     
+    public JobStatus[] jobsToComplete() throws IOException {
+	return jobSubmitClient.jobsToComplete();
+    }
+    
     /** Utility that submits a job, then polls for progress until the job is
      * complete. */
     public static void runJob(JobConf job) throws IOException {

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java?rev=420764&r1=420763&r2=420764&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java Tue Jul 11 01:43:29
2006
@@ -26,7 +26,7 @@
  *
  * @author Mike Cafarella
  **************************************************/
-class JobStatus implements Writable {
+public class JobStatus implements Writable {
 
     static {                                      // register a ctor
       WritableFactories.setFactory
@@ -45,13 +45,18 @@
     float mapProgress;
     float reduceProgress;
     int runState;
-
+    long startTime;
     /**
      */
     public JobStatus() {
     }
 
     /**
+     * Create a job status object for a given jobid.
+     * @param jobid The jobid of the job
+     * @param mapProgress The progress made on the maps
+     * @param reduceProgress The progress made on the reduces
+     * @param runState The current state of the job
      */
     public JobStatus(String jobid, float mapProgress, float reduceProgress, int runState)
{
         this.jobid = jobid;
@@ -61,14 +66,47 @@
     }
 
     /**
+     * @return The jobid of the Job
      */
     public String getJobId() { return jobid; }
+    
+    /**
+     * @return Percentage of progress in maps 
+     */
     public float mapProgress() { return mapProgress; }
-    public void setMapProgress(float p) { this.mapProgress = p; }
+    
+    /**
+     * Sets the map progress of this job
+     * @param p The value of map progress to set to
+     */
+    void setMapProgress(float p) { this.mapProgress = p; }
+    
+    /**
+     * @return Percentage of progress in reduce 
+     */
     public float reduceProgress() { return reduceProgress; }
-    public void setReduceProgress(float p) { this.reduceProgress = p; }
+    
+    /**
+     * Sets the reduce progress of this Job
+     * @param p The value of reduce progress to set to
+     */
+    void setReduceProgress(float p) { this.reduceProgress = p; }
+    
+    /**
+     * @return running state of the job
+     */
     public int getRunState() { return runState; }
-
+    
+    /** 
+     * Set the start time of the job
+     * @param startTime The startTime of the job
+     */
+    void setStartTime(long startTime) { this.startTime = startTime;};
+    
+    /**
+     * @return start time of the job
+     */
+    public long getStartTime() { return startTime;};
     ///////////////////////////////////////
     // Writable
     ///////////////////////////////////////
@@ -77,11 +115,13 @@
         out.writeFloat(mapProgress);
         out.writeFloat(reduceProgress);
         out.writeInt(runState);
+        out.writeLong(startTime);
     }
     public void readFields(DataInput in) throws IOException {
         this.jobid = UTF8.readString(in);
         this.mapProgress = in.readFloat();
         this.reduceProgress = in.readFloat();
         this.runState = in.readInt();
+        this.startTime = in.readLong();
     }
 }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobSubmissionProtocol.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobSubmissionProtocol.java?rev=420764&r1=420763&r2=420764&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobSubmissionProtocol.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobSubmissionProtocol.java Tue Jul
11 01:43:29 2006
@@ -17,6 +17,7 @@
 package org.apache.hadoop.mapred;
 
 import java.io.*;
+import java.util.*;
 
 /** 
  * Protocol that a JobClient and the central JobTracker use to communicate.  The
@@ -64,4 +65,11 @@
      * prior to submitting the job.
      */
     public String getFilesystemName() throws IOException;
+
+    /** 
+     * Get the jobs that are not completed and not failed
+     * @return array of JobStatus for the running/to-be-run
+     * jobs.
+     */
+    public JobStatus[] jobsToComplete() throws IOException;
 }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java?rev=420764&r1=420763&r2=420764&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java Tue Jul 11 01:43:29
2006
@@ -1038,6 +1038,20 @@
       return (String) taskidToTrackerMap.get(taskId);
     }
     
+    public JobStatus[] jobsToComplete() {
+        Vector v = new Vector();
+        for (Iterator it = jobs.values().iterator(); it.hasNext(); ) {
+            JobInProgress jip = (JobInProgress) it.next();
+            JobStatus status = jip.getStatus();
+            if (status.getRunState() == JobStatus.RUNNING 
+		|| status.getRunState() == JobStatus.PREP) {
+		status.setStartTime(jip.getStartTime());
+                v.add(status);
+            }
+        }
+        return (JobStatus[]) v.toArray(new JobStatus[v.size()]);
+    } 
+    
     ///////////////////////////////////////////////////////////////
     // JobTracker methods
     ///////////////////////////////////////////////////////////////

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/LocalJobRunner.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/LocalJobRunner.java?rev=420764&r1=420763&r2=420764&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/LocalJobRunner.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/LocalJobRunner.java Tue Jul 11 01:43:29
2006
@@ -210,4 +210,6 @@
   public ClusterStatus getClusterStatus() {
     return new ClusterStatus(1, map_tasks, reduce_tasks, 1);
   }
+
+  public JobStatus[] jobsToComplete() {return null;};
 }



Mime
View raw message