Author: omalley
Date: Fri Mar  4 03:52:17 2011
New Revision: 1077211

URL: http://svn.apache.org/viewvc?rev=1077211&view=rev
Log:
commit b23f3708d2a462c2c6d6f4fdc8f18fdc9a3b010f
Author: Devaraj Das <[email protected]>
Date:   Tue Feb 23 17:29:15 2010 -0800

    MAPREDUCE:1505 from 
https://issues.apache.org/jira/secure/attachment/12436628/MAPREDUCE-1505_yhadoop20.patch
    
    +++ b/YAHOO-CHANGES.txt
    +    MAPREDUCE-1505. Delays construction of the job client until it is 
really
    +    required. (Arun C Murthy via ddas)
    +

Modified:
    
hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapreduce/Job.java
    
hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapreduce/TestChild.java

Modified: 
hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapreduce/Job.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapreduce/Job.java?rev=1077211&r1=1077210&r2=1077211&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapreduce/Job.java
 (original)
+++ 
hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapreduce/Job.java
 Fri Mar  4 03:52:17 2011
@@ -47,7 +47,6 @@ public class Job extends JobContext {  
 
   public Job(Configuration conf) throws IOException {
     super(conf, null);
-    jobClient = new JobClient((JobConf) getConfiguration());
   }
 
   public Job(Configuration conf, String jobName) throws IOException {
@@ -55,11 +54,20 @@ public class Job extends JobContext {  
     setJobName(jobName);
   }
 
+  JobClient getJobClient() {
+    return jobClient;
+  }
+  
   private void ensureState(JobState state) throws IllegalStateException {
     if (state != this.state) {
       throw new IllegalStateException("Job in state "+ this.state + 
                                       " instead of " + state);
     }
+
+    if (state == JobState.RUNNING && jobClient == null) {
+      throw new IllegalStateException("Job in state " + JobState.RUNNING + 
+                                      " however jobClient is not 
initialized!");
+    }
   }
 
   /**
@@ -450,11 +458,22 @@ public class Job extends JobContext {  
                               ClassNotFoundException {
     ensureState(JobState.DEFINE);
     setUseNewAPI();
+    
+    // Connect to the JobTracker and submit the job
+    connect();
     info = jobClient.submitJobInternal(conf);
     state = JobState.RUNNING;
    }
   
   /**
+   * Open a connection to the JobTracker
+   * @throws IOException
+   */
+  private void connect() throws IOException {
+    jobClient = new JobClient((JobConf) getConfiguration());
+  }
+  
+  /**
    * Submit the job to the cluster and wait for it to finish.
    * @param verbose print the progress to the user
    * @return true if the job succeeded

Modified: 
hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapreduce/TestChild.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapreduce/TestChild.java?rev=1077211&r1=1077210&r2=1077211&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapreduce/TestChild.java
 (original)
+++ 
hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapreduce/TestChild.java
 Fri Mar  4 03:52:17 2011
@@ -112,8 +112,12 @@ public class TestChild extends HadoopTes
                 numMaps, numReds);
     job.setMapperClass(MyMapper.class);
     job.setReducerClass(MyReducer.class);
+    assertNull("Job.jobClient already initialized before job-submission!", 
+               job.getJobClient());
     job.waitForCompletion(true);
     assertTrue(job.isSuccessful());
+    assertNotNull("Job.jobClient not initialized after job-completion!", 
+                  job.getJobClient());
 
     // Check output directory
     FileSystem fs = FileSystem.get(conf);


Reply via email to