hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r387928 - in /lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred: JobClient.java JobConf.java
Date Wed, 22 Mar 2006 20:14:08 GMT
Author: cutting
Date: Wed Mar 22 12:14:06 2006
New Revision: 387928

URL: http://svn.apache.org/viewcvs?rev=387928&view=rev
Log:
Fix for HADOOP-3.  Don't permit jobs to write to a pre-existing output directory.  Contributed
by Owen O'Malley.

Modified:
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobConf.java

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java?rev=387928&r1=387927&r2=387928&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 Wed Mar 22 12:14:06
2006
@@ -247,8 +247,20 @@
           getFs().copyFromLocalFile(new File(originalJarPath), submitJarFile);
         }
 
-        // Write job file to JobTracker's fs
-        FSDataOutputStream out = getFs().create(submitJobFile);
+        FileSystem fs = getFs();
+
+        // Ensure that the output directory is set and not already there
+        File outDir = job.getOutputDir();
+        if (outDir == null && job.getNumReduceTasks() != 0) {
+            throw new IOException("Output directory not set in JobConf.");
+        }
+        if (outDir != null && fs.exists(outDir)) {
+            throw new IOException("Output directory " + outDir + 
+                                  " already exists.");
+        }
+
+        // Write job file to JobTracker's fs        
+        FSDataOutputStream out = fs.create(submitJobFile);
         try {
           job.write(out);
         } finally {
@@ -347,7 +359,6 @@
         }
 
         // Process args
-        String jobTrackerStr = argv[0];
         String jobTrackerSpec = null;
         String submitJobFile = null;
         String jobid = null;

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobConf.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobConf.java?rev=387928&r1=387927&r2=387928&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobConf.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobConf.java Wed Mar 22 12:14:06
2006
@@ -143,7 +143,11 @@
     return result;
   }
 
-  public File getOutputDir() { return new File(get("mapred.output.dir")); }
+  public File getOutputDir() { 
+    String name = get("mapred.output.dir");
+    return name == null ? null: new File(name);
+  }
+
   public void setOutputDir(File dir) { set("mapred.output.dir", dir); }
 
   public InputFormat getInputFormat() {



Mime
View raw message