hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r1402678 - in /hadoop/common/branches/branch-1: CHANGES.txt src/core/org/apache/hadoop/conf/Configuration.java src/core/org/apache/hadoop/http/HttpServer.java
Date Fri, 26 Oct 2012 21:44:29 GMT
Author: suresh
Date: Fri Oct 26 21:44:29 2012
New Revision: 1402678

URL: http://svn.apache.org/viewvc?rev=1402678&view=rev
Log:
HADOOP-8567. Reverting the commits r1402641 and r1402639 because of missed files.

Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    hadoop/common/branches/branch-1/src/core/org/apache/hadoop/conf/Configuration.java
    hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1402678&r1=1402677&r2=1402678&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Fri Oct 26 21:44:29 2012
@@ -29,9 +29,6 @@ Release 1.2.0 - unreleased
     HDFS-3912. Detect and avoid stale datanodes for writes.
     (Jing Zhao via suresh)
 
-    HADOOP-8567. Port conf servlet to dump running configuration  to 
-    branch 1.x. (todd, Backported by Jing Zhao via suresh)
-
   IMPROVEMENTS
 
     HDFS-3515. Port HDFS-1457 to branch-1. (eli)

Modified: hadoop/common/branches/branch-1/src/core/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/core/org/apache/hadoop/conf/Configuration.java?rev=1402678&r1=1402677&r2=1402678&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/core/org/apache/hadoop/conf/Configuration.java (original)
+++ hadoop/common/branches/branch-1/src/core/org/apache/hadoop/conf/Configuration.java Fri
Oct 26 21:44:29 2012
@@ -27,7 +27,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
 import java.net.URL;
@@ -52,7 +51,6 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
@@ -67,7 +65,6 @@ import org.apache.hadoop.util.Reflection
 import org.apache.hadoop.util.StringUtils;
 import org.codehaus.jackson.JsonFactory;
 import org.codehaus.jackson.JsonGenerator;
-import org.w3c.dom.Comment;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -174,10 +171,10 @@ public class Configuration implements It
     new CopyOnWriteArrayList<String>();
   
   /**
-   * The value reported as the setting resource when a key is set
-   * by code rather than a file resource.
+   * Flag to indicate if the storage of resource which updates a key needs 
+   * to be stored for each key
    */
-  static final String UNKNOWN_RESOURCE = "Unknown";
+  private boolean storeResource;
   
   /**
    * Stores the mapping of key to the resource which modifies or loads 
@@ -226,13 +223,30 @@ public class Configuration implements It
    */
   public Configuration(boolean loadDefaults) {
     this.loadDefaults = loadDefaults;
-    updatingResource = new HashMap<String, String>();
     if (LOG.isDebugEnabled()) {
       LOG.debug(StringUtils.stringifyException(new IOException("config()")));
     }
     synchronized(Configuration.class) {
       REGISTRY.put(this, null);
     }
+    this.storeResource = false;
+  }
+  
+  /**
+   * A new configuration with the same settings and additional facility for
+   * storage of resource to each key which loads or updates 
+   * the key most recently
+   * @param other the configuration from which to clone settings
+   * @param storeResource flag to indicate if the storage of resource to 
+   * each key is to be stored
+   */
+  private Configuration(Configuration other, boolean storeResource) {
+    this(other);
+    this.loadDefaults = other.loadDefaults;
+    this.storeResource = storeResource;
+    if (storeResource) {
+      updatingResource = new HashMap<String, String>();
+    }
   }
   
   /** 
@@ -246,23 +260,20 @@ public class Configuration implements It
       LOG.debug(StringUtils.stringifyException
                 (new IOException("config(config)")));
     }
-
-    this.resources = (ArrayList) other.resources.clone();
-    synchronized (other) {
-      if (other.properties != null) {
-        this.properties = (Properties) other.properties.clone();
-      }
-
-      if (other.overlay != null) {
-        this.overlay = (Properties) other.overlay.clone();
-      }
-
-      this.updatingResource = new HashMap<String, String>(
-          other.updatingResource);
-    }
-
+   
+   this.resources = (ArrayList)other.resources.clone();
+   synchronized(other) {
+     if (other.properties != null) {
+       this.properties = (Properties)other.properties.clone();
+     }
+
+     if (other.overlay!=null) {
+       this.overlay = (Properties)other.overlay.clone();
+     }
+   }
+   
     this.finalParameters = new HashSet<String>(other.finalParameters);
-    synchronized (Configuration.class) {
+    synchronized(Configuration.class) {
       REGISTRY.put(this, null);
     }
   }
@@ -426,7 +437,6 @@ public class Configuration implements It
   public void set(String name, String value) {
     getOverlay().setProperty(name, value);
     getProps().setProperty(name, value);
-    this.updatingResource.put(name, UNKNOWN_RESOURCE);
   }
  
   /**
@@ -1061,8 +1071,10 @@ public class Configuration implements It
       loadResources(properties, resources, quietmode);
       if (overlay!= null) {
         properties.putAll(overlay);
-        for (Map.Entry<Object,Object> item: overlay.entrySet()) {
-          updatingResource.put((String) item.getKey(), UNKNOWN_RESOURCE);
+        if (storeResource) {
+          for (Map.Entry<Object,Object> item: overlay.entrySet()) {
+            updatingResource.put((String) item.getKey(), "Unknown");
+          }
         }
       }
     }
@@ -1234,7 +1246,9 @@ public class Configuration implements It
           if (value != null) {
             if (!finalParameters.contains(attr)) {
               properties.setProperty(attr, value);
-              updatingResource.put(attr, name.toString());
+              if (storeResource) {
+                updatingResource.put(attr, name.toString());
+              }
             } else if (!value.equals(properties.getProperty(attr))) {
               LOG.warn(name+":a attempt to override final parameter: "+attr
                      +";  Ignoring.");
@@ -1262,22 +1276,12 @@ public class Configuration implements It
   }
 
   /** 
-   * Write out the non-default properties in this configuration to the given
+   * Write out the non-default properties in this configuration to the give
    * {@link OutputStream}.
    * 
    * @param out the output stream to write to.
    */
   public void writeXml(OutputStream out) throws IOException {
-    writeXml(new OutputStreamWriter(out));
-  }
-  
-  /**
-   * Write out the non-default properties in this configuration to the given
-   * {@link Writer}.
-   * 
-   * @param out the writer to write to.
-   */
-  public synchronized void writeXml(Writer out) throws IOException {
     Properties properties = getProps();
     try {
       Document doc =
@@ -1296,11 +1300,7 @@ public class Configuration implements It
         }
         Element propNode = doc.createElement("property");
         conf.appendChild(propNode);
-        if (updatingResource != null) {
-          Comment commentNode = doc.createComment("Loaded from "
-              + updatingResource.get(name));
-          propNode.appendChild(commentNode);
-        }
+      
         Element nameNode = doc.createElement("name");
         nameNode.appendChild(doc.createTextNode(name));
         propNode.appendChild(nameNode);
@@ -1317,10 +1317,8 @@ public class Configuration implements It
       TransformerFactory transFactory = TransformerFactory.newInstance();
       Transformer transformer = transFactory.newTransformer();
       transformer.transform(source, result);
-    } catch (TransformerException te) {
-      throw new IOException(te);
-    } catch (ParserConfigurationException pe) {
-      throw new IOException(pe);
+    } catch (Exception e) {
+      throw new RuntimeException(e);
     }
   }
 
@@ -1335,26 +1333,26 @@ public class Configuration implements It
    * @param out the Writer to write to
    * @throws IOException
    */
-  public static void dumpConfiguration(Configuration config, 
+  public static void dumpConfiguration(Configuration conf, 
       Writer out) throws IOException {
+    Configuration config = new Configuration(conf,true);
+    config.reloadConfiguration();
     JsonFactory dumpFactory = new JsonFactory();
     JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
     dumpGenerator.writeStartObject();
     dumpGenerator.writeFieldName("properties");
     dumpGenerator.writeStartArray();
     dumpGenerator.flush();
-    synchronized (config) {
-      for (Map.Entry<Object,Object> item: config.getProps().entrySet()) {
-        dumpGenerator.writeStartObject();
-        dumpGenerator.writeStringField("key", (String) item.getKey());
-        dumpGenerator.writeStringField("value", 
-            config.get((String) item.getKey()));
-        dumpGenerator.writeBooleanField("isFinal",
-            config.finalParameters.contains(item.getKey()));
-        dumpGenerator.writeStringField("resource",
-            config.updatingResource.get(item.getKey()));
-        dumpGenerator.writeEndObject();
-      }
+    for (Map.Entry<Object,Object> item: config.getProps().entrySet()) {
+      dumpGenerator.writeStartObject();
+      dumpGenerator.writeStringField("key", (String) item.getKey());
+      dumpGenerator.writeStringField("value", 
+          config.get((String) item.getKey()));
+      dumpGenerator.writeBooleanField("isFinal",
+          config.finalParameters.contains(item.getKey()));
+      dumpGenerator.writeStringField("resource",
+          config.updatingResource.get(item.getKey()));
+      dumpGenerator.writeEndObject();
     }
     dumpGenerator.writeEndArray();
     dumpGenerator.writeEndObject();

Modified: hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java?rev=1402678&r1=1402677&r2=1402678&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java (original)
+++ hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java Fri Oct
26 21:44:29 2012
@@ -85,10 +85,10 @@ public class HttpServer implements Filte
 
   static final String FILTER_INITIALIZER_PROPERTY
       = "hadoop.http.filter.initializers";
- 
+
   // The ServletContext attribute where the daemon Configuration
   // gets stored.
-  public static final String CONF_CONTEXT_ATTRIBUTE = "hadoop.conf";
+  static final String CONF_CONTEXT_ATTRIBUTE = "hadoop.conf";
   static final String ADMINS_ACL = "admins.acl";
   public static final String SPNEGO_FILTER = "SpnegoFilter";
   public static final String KRB5_FILTER = "krb5Filter";



Mime
View raw message