Forráskód Böngészése

HADOOP-2132. Only RUNNING/PREP jobs can be killed. Contributed by Jothi Padmanabhan.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@662813 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 17 éve
szülő
commit
c81d850fab

+ 1 - 0
CHANGES.txt

@@ -405,6 +405,7 @@ Trunk (unreleased changes)
     Thus removes the class org.apache.hadoop.mapred.JobShell.
     (Amareshwari Sriramadasu via ddas) 
 
+    HADOOP-2132. Only RUNNING/PREP jobs can be killed. (Jothi Padmanabhan via ddas)
 
 Release 0.17.0 - 2008-05-18
 

+ 13 - 5
src/java/org/apache/hadoop/mapred/JobClient.java

@@ -182,10 +182,18 @@ public class JobClient extends Configured implements MRConstants, Tool  {
      */
     synchronized void ensureFreshStatus() throws IOException {
       if (System.currentTimeMillis() - statustime > MAX_JOBPROFILE_AGE) {
-        this.status = jobSubmitClient.getJobStatus(profile.getJobID());
-        this.statustime = System.currentTimeMillis();
+        updateStatus();
       }
     }
+    
+    /** Some methods need to update status immediately. So, refresh
+     * immediately
+     * @throws IOException
+     */
+    synchronized void updateStatus() throws IOException {
+      this.status = jobSubmitClient.getJobStatus(profile.getJobID());
+      this.statustime = System.currentTimeMillis();
+    }
 
     /**
      * An identifier for the job
@@ -244,7 +252,7 @@ public class JobClient extends Configured implements MRConstants, Tool  {
      * Returns immediately whether the whole job is done yet or not.
      */
     public synchronized boolean isComplete() throws IOException {
-      ensureFreshStatus();
+      updateStatus();
       return (status.getRunState() == JobStatus.SUCCEEDED ||
               status.getRunState() == JobStatus.FAILED);
     }
@@ -253,7 +261,7 @@ public class JobClient extends Configured implements MRConstants, Tool  {
      * True iff job completed successfully.
      */
     public synchronized boolean isSuccessful() throws IOException {
-      ensureFreshStatus();
+      updateStatus();
       return status.getRunState() == JobStatus.SUCCEEDED;
     }
 
@@ -307,7 +315,7 @@ public class JobClient extends Configured implements MRConstants, Tool  {
     @Override
     public String toString() {
       try {
-        ensureFreshStatus();
+        updateStatus();
       } catch (IOException e) {
       }
       return "Job: " + profile.getJobID() + "\n" + 

+ 2 - 1
src/java/org/apache/hadoop/mapred/JobInProgress.java

@@ -1405,7 +1405,8 @@ class JobInProgress {
    * Kill the job and all its component tasks.
    */
   public synchronized void kill() {
-    if (status.getRunState() != JobStatus.FAILED) {
+    if ((status.getRunState() == JobStatus.RUNNING) ||
+         (status.getRunState() == JobStatus.PREP)) {
       LOG.info("Killing job '" + this.status.getJobID() + "'");
       this.status = new JobStatus(status.getJobID(), 1.0f, 1.0f, JobStatus.FAILED);
       this.finishTime = System.currentTimeMillis();