hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r536313 - in /lucene/hadoop/trunk: ./ src/java/org/apache/hadoop/conf/ src/java/org/apache/hadoop/dfs/ src/test/org/apache/hadoop/conf/
Date Tue, 08 May 2007 20:06:32 GMT
Author: cutting
Date: Tue May  8 13:06:31 2007
New Revision: 536313

URL: http://svn.apache.org/viewvc?view=rev&rev=536313
Log:
HADOOP-1197.  In Configuration, deprecate getObject(), and add getRaw(), which skips variable
expansion.  Contributed by Owen.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/conf/Configuration.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
    lucene/hadoop/trunk/src/test/org/apache/hadoop/conf/TestConfiguration.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=536313&r1=536312&r2=536313
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue May  8 13:06:31 2007
@@ -3,6 +3,12 @@
 
 Trunk (unreleased changes)
 
+  1. HADOOP-1197.  In Configuration, deprecate getObject() and add
+     getRaw(), which skips variable expansion. (omalley via cutting)
+
+
+Branch 0.13 (unreleased changes)
+
  1. HADOOP-1047.  Fix TestReplication to succeed more reliably.
     (Hairong Kuang via cutting)
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/conf/Configuration.java?view=diff&rev=536313&r1=536312&r2=536313
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/conf/Configuration.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/conf/Configuration.java Tue May  8 13:06:31
2007
@@ -151,16 +151,20 @@
   /**
    * Returns the value of the <code>name</code> property, or null if no such
    * property exists.
+   * @deprecated A side map of Configuration to Object should be used instead.
    */
   public Object getObject(String name) { return getProps().get(name);}
 
-  /** Sets the value of the <code>name</code> property. */
+  /** Sets the value of the <code>name</code> property. 
+   * @deprecated
+   */
   public void setObject(String name, Object value) {
     getProps().put(name, value);
   }
 
   /** Returns the value of the <code>name</code> property.  If no such property
    * exists, then <code>defaultValue</code> is returned.
+   * @deprecated A side map of Configuration to Object should be used instead.
    */
   public Object get(String name, Object defaultValue) {
     Object res = getObject(name);
@@ -186,7 +190,7 @@
       var = var.substring(2, var.length()-1); // remove ${ .. }
       String val = System.getProperty(var);
       if (val == null) {
-        val = (String)this.getObject(var);
+        val = getRaw(var);
       }
       if (val == null) {
         return eval; // return literal ${var}: var is unbound
@@ -202,6 +206,16 @@
    * such property exists. */
   public String get(String name) {
     return substituteVars(getProps().getProperty(name));
+  }
+
+  /**
+   * Get the value of the <code>name</code> property, without doing variable
+   * expansion.
+   * @param name the property name
+   * @return the result or null if no such property exists
+   */
+  public String getRaw(String name) {
+    return getProps().getProperty(name);
   }
 
   /** Sets the value of the <code>name</code> property. */

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java?view=diff&rev=536313&r1=536312&r2=536313
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java Tue May  8 13:06:31 2007
@@ -223,8 +223,7 @@
     NamespaceInfo nsInfo = handshake();
 
     // read storage info, lock data dirs and transition fs state if necessary
-    StartupOption startOpt = (StartupOption)conf.get("dfs.datanode.startup", 
-                                                     StartupOption.REGULAR);
+    StartupOption startOpt = getStartupOption(conf);
     assert startOpt != null : "Startup option must be set.";
     storage = new DataStorage();
     storage.recoverTransitionRead(nsInfo, dataDirs, startOpt);
@@ -1246,8 +1245,17 @@
     }
     if (networkLoc != null)
       conf.set("dfs.datanode.rack", NodeBase.normalize(networkLoc));
-    conf.setObject("dfs.datanode.startup", startOpt);
+    setStartupOption(conf, startOpt);
     return true;
+  }
+
+  private static void setStartupOption(Configuration conf, StartupOption opt) {
+    conf.set("dfs.datanode.startup", opt);
+  }
+
+  static StartupOption getStartupOption(Configuration conf) {
+    return StartupOption.valueOf(conf.get("dfs.datanode.startup",
+                                          StartupOption.REGULAR.toString()));
   }
 
   /* Get the network location by running a script configured in conf */

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java?view=diff&rev=536313&r1=536312&r2=536313
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java Tue May  8 13:06:31
2007
@@ -249,8 +249,7 @@
     this.localMachine = hostname;
     this.port = port;
     this.dir = new FSDirectory(this);
-    StartupOption startOpt = (StartupOption)conf.get(
-                                                     "dfs.namenode.startup", StartupOption.REGULAR);
+    StartupOption startOpt = NameNode.getStartupOption(conf);
     this.dir.loadFSImage(getNamespaceDirs(conf), startOpt);
     this.safeMode = new SafeModeInfo(conf);
     setBlockTotal();

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java?view=diff&rev=536313&r1=536312&r2=536313
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java Tue May  8 13:06:31 2007
@@ -781,8 +781,17 @@
       } else
         return null;
     }
-    conf.setObject("dfs.namenode.startup", startOpt);
+    setStartupOption(conf, startOpt);
     return startOpt;
+  }
+
+  private static void setStartupOption(Configuration conf, StartupOption opt) {
+    conf.set("dfs.namenode.startup", opt.toString());
+  }
+
+  static StartupOption getStartupOption(Configuration conf) {
+    return StartupOption.valueOf(conf.get("dfs.namenode.startup",
+                                          StartupOption.REGULAR.toString()));
   }
 
   static NameNode createNameNode(String argv[], 

Modified: lucene/hadoop/trunk/src/test/org/apache/hadoop/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/test/org/apache/hadoop/conf/TestConfiguration.java?view=diff&rev=536313&r1=536312&r2=536313
==============================================================================
--- lucene/hadoop/trunk/src/test/org/apache/hadoop/conf/TestConfiguration.java (original)
+++ lucene/hadoop/trunk/src/test/org/apache/hadoop/conf/TestConfiguration.java Tue May  8
13:06:31 2007
@@ -74,7 +74,7 @@
     for (Prop p : props) {
       System.out.println("p=" + p.name);
       String gotVal = conf.get(p.name);
-      String gotRawVal = (String)conf.getObject(p.name);
+      String gotRawVal = conf.getRaw(p.name);
       assertEq(p.val, gotRawVal);
       if (p.expectEval == UNSPEC) {
         // expansion is system-dependent (uses System properties)



Mime
View raw message