hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1357724 - in /hadoop/common/branches/branch-1: CHANGES.txt src/mapred/org/apache/hadoop/mapred/JobClient.java src/mapred/org/apache/hadoop/mapred/RunningJob.java src/test/org/apache/hadoop/mapred/TestNetworkedJob.java
Date Thu, 05 Jul 2012 16:29:26 GMT
Author: tucu
Date: Thu Jul  5 16:29:26 2012
New Revision: 1357724

URL: http://svn.apache.org/viewvc?rev=1357724&view=rev
Log:
MAPREDUCE-4355. Add RunningJob.getJobStatus() (kkambatl via tucu)

Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java
    hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/RunningJob.java
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestNetworkedJob.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1357724&r1=1357723&r2=1357724&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Thu Jul  5 16:29:26 2012
@@ -8,6 +8,8 @@ Release 1.2.0 - unreleased
 
     HADOOP-8023. Add unset() method to Configuration (tucu)
 
+    MAPREDUCE-4355. Add RunningJob.getJobStatus() (kkambatl via tucu)
+
   IMPROVEMENTS
 
     HDFS-3515. Port HDFS-1457 to branch-1. (eli)

Modified: hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java?rev=1357724&r1=1357723&r2=1357724&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java (original)
+++ hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobClient.java Thu
Jul  5 16:29:26 2012
@@ -426,6 +426,12 @@ public class JobClient extends Configure
       ensureFreshStatus();
       return status.getFailureInfo();
     }
+
+    @Override
+    public JobStatus getJobStatus() throws IOException {
+      updateStatus();
+      return status;
+    }
   }
 
   private JobSubmissionProtocol jobSubmitClient;

Modified: hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/RunningJob.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/RunningJob.java?rev=1357724&r1=1357723&r2=1357724&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/RunningJob.java (original)
+++ hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/RunningJob.java Thu
Jul  5 16:29:26 2012
@@ -128,15 +128,22 @@ public interface RunningJob {
 
   /**
    * Returns the current state of the Job.
-   * {@link JobStatus}
    * 
    * @throws IOException
    */
   public int getJobState() throws IOException;
   
   /**
-   * Kill the running job.  Blocks until all job tasks have been
-   * killed as well.  If the job is no longer running, it simply returns.
+   * Returns a snapshot of the current status, {@link JobStatus}, of the Job.
+   * Need to call again for latest information.
+   * 
+   * @throws IOException
+   */
+  public JobStatus getJobStatus() throws IOException;
+
+  /**
+   * Kill the running job. Blocks until all job tasks have been killed as well.
+   * If the job is no longer running, it simply returns.
    * 
    * @throws IOException
    */

Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestNetworkedJob.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestNetworkedJob.java?rev=1357724&r1=1357723&r2=1357724&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestNetworkedJob.java
(original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestNetworkedJob.java
Thu Jul  5 16:29:26 2012
@@ -18,15 +18,16 @@
 
 package org.apache.hadoop.mapred;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import java.io.IOException;
-import java.util.List;
 
-import org.apache.hadoop.mapred.JobID;
-import org.apache.hadoop.mapreduce.Job;
 import org.junit.Test;
-import static org.mockito.Mockito.*;
 
 public class TestNetworkedJob {
 
@@ -50,7 +51,6 @@ public class TestNetworkedJob {
     JobProfile mockProf = mock(JobProfile.class);
     new JobClient.NetworkedJob(mockStatus, mockProf, null);
   }
-  
 
   @SuppressWarnings("deprecation")
   @Test
@@ -96,4 +96,19 @@ public class TestNetworkedJob {
     verify(mockClient).getJobCounters(id);
   }
 
+  @Test
+  public void testGetJobStatus() throws IOException {
+    JobID id = new JobID("test", 0);
+
+    JobStatus mockStatus = mock(JobStatus.class);
+    JobProfile mockProf = mock(JobProfile.class);
+    JobSubmissionProtocol mockClient = mock(JobSubmissionProtocol.class);
+
+    when(mockProf.getJobID()).thenReturn(id);
+    when(mockClient.getJobStatus(id)).thenReturn(mockStatus);
+
+    RunningJob rj = new JobClient.NetworkedJob(mockStatus, mockProf, mockClient);
+    assertEquals("Expected getJobStatus() to return the correct status",
+        rj.getJobStatus(), mockStatus);
+  }
 }



Mime
View raw message