hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject svn commit: r1365193 - in /hadoop/common/branches/branch-1: ./ src/mapred/org/apache/hadoop/mapreduce/ src/test/org/apache/hadoop/mapreduce/ src/test/org/apache/hadoop/mapreduce/lib/input/ src/test/org/apache/hadoop/mapreduce/lib/output/ src/test/org/a...
Date Tue, 24 Jul 2012 17:54:48 GMT
Author: harsh
Date: Tue Jul 24 17:54:47 2012
New Revision: 1365193

URL: http://svn.apache.org/viewvc?rev=1365193&view=rev
Log:
MAPREDUCE-4415. Backport the Job.getInstance methods from MAPREDUCE-1505 to branch-1. Contributed
by Harsh J. (harsh)

Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapreduce/Job.java
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/MapReduceTestUtil.java
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/input/TestKeyValueTextInputFormat.java
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/output/TestMRSequenceFileAsBinaryOutputFormat.java
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/partition/TestInputSampler.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1365193&r1=1365192&r2=1365193&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Tue Jul 24 17:54:47 2012
@@ -43,6 +43,9 @@ Release 1.2.0 - unreleased
     HDFS-3647. Backport HDFS-2868 (Add number of active transfer
     threads to the DataNode status) to branch-1 (harsh)
 
+    MAPREDUCE-4415. Backport the Job.getInstance methods from
+    MAPREDUCE-1505 to branch-1. (harsh)
+
   BUG FIXES
 
     HADOOP-8460. Document proper setting of HADOOP_PID_DIR and

Modified: hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapreduce/Job.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapreduce/Job.java?rev=1365193&r1=1365192&r2=1365193&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapreduce/Job.java (original)
+++ hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapreduce/Job.java Tue Jul
24 17:54:47 2012
@@ -42,6 +42,56 @@ public class Job extends JobContext {  
   private JobClient jobClient;
   private RunningJob info;
 
+  /**
+   * Creates a new {@link Job}
+   * A Job will be created with a generic {@link Configuration}.
+   *
+   * @return the {@link Job}
+   * @throws IOException
+   */
+  public static Job getInstance() throws IOException {
+    // create with a null Cluster
+    return getInstance(new Configuration());
+  }
+
+  /**
+   * Creates a new {@link Job} with a given {@link Configuration}.
+   *
+   * The <code>Job</code> makes a copy of the <code>Configuration</code>
so
+   * that any necessary internal modifications do not reflect on the incoming
+   * parameter.
+   *
+   * @param conf the {@link Configuration}
+   * @return the {@link Job}
+   * @throws IOException
+   */
+  public static Job getInstance(Configuration conf) throws IOException {
+    // create with a null Cluster
+    JobConf jobConf = new JobConf(conf);
+    return new Job(jobConf);
+  }
+
+  /**
+   * Creates a new {@link Job} with a given {@link Configuration}
+   * and a given jobName.
+   *
+   * The <code>Job</code> makes a copy of the <code>Configuration</code>
so
+   * that any necessary internal modifications do not reflect on the incoming
+   * parameter.
+   *
+   * @param conf the {@link Configuration}
+   * @param jobName the job instance's name
+   * @return the {@link Job}
+   * @throws IOException
+   */
+  public static Job getInstance(Configuration conf, String jobName)
+           throws IOException {
+    // create with a null Cluster
+    Job result = getInstance(conf);
+    result.setJobName(jobName);
+    return result;
+  }
+
   public Job() throws IOException {
     this(new Configuration());
   }

Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/MapReduceTestUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/MapReduceTestUtil.java?rev=1365193&r1=1365192&r2=1365193&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/MapReduceTestUtil.java
(original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/MapReduceTestUtil.java
Tue Jul 24 17:54:47 2012
@@ -127,7 +127,7 @@ public class MapReduceTestUtil {
   public static Job createCopyJob(Configuration conf, Path outdir, 
       Path... indirs) throws Exception {
     conf.setInt("mapred.map.tasks", 3);
-    Job theJob = new Job(conf);
+    Job theJob = Job.getInstance(conf);
     theJob.setJobName("DataMoveJob");
 
     FileInputFormat.setInputPaths(theJob, indirs);
@@ -157,7 +157,7 @@ public class MapReduceTestUtil {
       fs.delete(outdir, true);
     }
     conf.setInt("mapred.map.max.attempts", 2);
-    Job theJob = new Job(conf);
+    Job theJob = Job.getInstance(conf);
     theJob.setJobName("Fail-Job");
 
     FileInputFormat.setInputPaths(theJob, indirs);
@@ -182,7 +182,7 @@ public class MapReduceTestUtil {
   public static Job createKillJob(Configuration conf, Path outdir, 
       Path... indirs) throws Exception {
 
-    Job theJob = new Job(conf);
+    Job theJob = Job.getInstance(conf);
     theJob.setJobName("Kill-Job");
 
     FileInputFormat.setInputPaths(theJob, indirs);
@@ -251,7 +251,7 @@ public class MapReduceTestUtil {
 
   public static Job createJob(Configuration conf, Path inDir, Path outDir, 
       int numInputFiles, int numReds, String input) throws IOException {
-    Job job = new Job(conf);
+    Job job = Job.getInstance(conf);
     FileSystem fs = FileSystem.get(conf);
     if (fs.exists(outDir)) {
       fs.delete(outDir, true);

Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/input/TestKeyValueTextInputFormat.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/input/TestKeyValueTextInputFormat.java?rev=1365193&r1=1365192&r2=1365193&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/input/TestKeyValueTextInputFormat.java
(original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/input/TestKeyValueTextInputFormat.java
Tue Jul 24 17:54:47 2012
@@ -190,7 +190,7 @@ public class TestKeyValueTextInputFormat
    * Test using the gzip codec for reading
    */
   public static void testGzip() throws Exception {
-    Job job = new Job();
+    Job job = Job.getInstance();
     CompressionCodec gzip = new GzipCodec();
     ReflectionUtils.setConf(gzip, job.getConfiguration());
     localFs.delete(workDir, true);

Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/output/TestMRSequenceFileAsBinaryOutputFormat.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/output/TestMRSequenceFileAsBinaryOutputFormat.java?rev=1365193&r1=1365192&r2=1365193&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/output/TestMRSequenceFileAsBinaryOutputFormat.java
(original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/output/TestMRSequenceFileAsBinaryOutputFormat.java
Tue Jul 24 17:54:47 2012
@@ -173,7 +173,8 @@ public class TestMRSequenceFileAsBinaryO
 
   public void testcheckOutputSpecsForbidRecordCompression() 
       throws IOException {
-    Job job = new Job();
+    Job job = Job.getInstance(new Configuration(),
+        "testcheckOutputSpecsForbidRecordCompression");
     FileSystem fs = FileSystem.getLocal(job.getConfiguration());
     Path outputdir = new Path(System.getProperty("test.build.data", "/tmp") 
                               + "/output");

Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/partition/TestInputSampler.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/partition/TestInputSampler.java?rev=1365193&r1=1365192&r2=1365193&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/partition/TestInputSampler.java
(original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapreduce/lib/partition/TestInputSampler.java
Tue Jul 24 17:54:47 2012
@@ -136,7 +136,7 @@ public class TestInputSampler {
     for (int i = 0; i < TOT_SPLITS; ++i) {
       inits[i] = i;
     }
-    Job ignored = new Job();
+    Job ignored = Job.getInstance();
     Object[] samples = sampler.getSample(new TestInputSamplerIF(
           NUM_SAMPLES, TOT_SPLITS, inits), ignored);
     assertEquals(NUM_SAMPLES, samples.length);



Mime
View raw message