Pārlūkot izejas kodu

HADOOP-1906. Warn users about an obsolete mapred-default.xml file.
Contributed by acmurthy.


git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@582394 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 18 gadi atpakaļ
vecāks
revīzija
3052af6628
2 mainītis faili ar 28 papildinājumiem un 2 dzēšanām
  1. 4 1
      CHANGES.txt
  2. 24 1
      src/java/org/apache/hadoop/mapred/JobConf.java

+ 4 - 1
CHANGES.txt

@@ -355,7 +355,10 @@ Trunk (unreleased changes)
     class, and improve documentation.  (Cameron Pope via cutting)
     class, and improve documentation.  (Cameron Pope via cutting)
 
 
     HADOOP-1926. Add a random text writer example/benchmark so that we can
     HADOOP-1926. Add a random text writer example/benchmark so that we can
-    benchmark compression codecs on random data.
+    benchmark compression codecs on random data. (acmurthy via omalley)
+
+    HADOOP-1906. Warn the user if they have an obsolete madred-default.xml
+    file in their configuration directory. (acmurthy via omalley)
 
 
 Release 0.14.2 - unreleased
 Release 0.14.2 - unreleased
 
 

+ 24 - 1
src/java/org/apache/hadoop/mapred/JobConf.java

@@ -29,6 +29,8 @@ import java.util.Enumeration;
 import java.net.URL;
 import java.net.URL;
 import java.net.URLDecoder;
 import java.net.URLDecoder;
 
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
@@ -48,16 +50,21 @@ import org.apache.hadoop.util.ReflectionUtils;
  * of input files, and where the output files should be written. */
  * of input files, and where the output files should be written. */
 public class JobConf extends Configuration {
 public class JobConf extends Configuration {
   
   
+  private static final Log LOG = LogFactory.getLog(JobConf.class);
+
   /**
   /**
    * Construct a map/reduce job configuration.
    * Construct a map/reduce job configuration.
    */
    */
-  public JobConf() {}
+  public JobConf() {
+	  checkWarnAndLoadMapredDefault();
+  }
 
 
   /** 
   /** 
    * Construct a map/reduce job configuration.
    * Construct a map/reduce job configuration.
    * @param exampleClass a class whose containing jar is used as the job's jar.
    * @param exampleClass a class whose containing jar is used as the job's jar.
    */
    */
   public JobConf(Class exampleClass) {
   public JobConf(Class exampleClass) {
+    checkWarnAndLoadMapredDefault();
     setJarByClass(exampleClass);
     setJarByClass(exampleClass);
   }
   }
   
   
@@ -68,6 +75,7 @@ public class JobConf extends Configuration {
    */
    */
   public JobConf(Configuration conf) {
   public JobConf(Configuration conf) {
     super(conf);
     super(conf);
+    checkWarnAndLoadMapredDefault();
   }
   }
 
 
 
 
@@ -96,9 +104,24 @@ public class JobConf extends Configuration {
    */
    */
   public JobConf(Path config) {
   public JobConf(Path config) {
     super();
     super();
+    checkWarnAndLoadMapredDefault();
     addResource(config);
     addResource(config);
   }
   }
 
 
+  /**
+   * Checks if <b>mapred-default.xml</b> is on the CLASSPATH, if so
+   * it warns the user and loads it as a {@link Configuration} resource.
+   * @deprecated Remove in hadoop-0.16.0 via HADOOP-1843
+   */
+  private void checkWarnAndLoadMapredDefault() {
+    URL mapredDefaultConf = getClassLoader().getResource("mapred-default.xml");
+    if (mapredDefaultConf != null) {
+      LOG.warn("Deprecated resource 'mapred-default.xml' is being loaded, " +
+          "please discontinue its usage!");
+      addResource("mapred-default.xml");
+    }
+  }
+  
   public String getJar() { return get("mapred.jar"); }
   public String getJar() { return get("mapred.jar"); }
   public void setJar(String jar) { set("mapred.jar", jar); }
   public void setJar(String jar) { set("mapred.jar", jar); }