hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1675048 - /hama/trunk/core/src/main/java/org/apache/hama/HamaConfiguration.java
Date Tue, 21 Apr 2015 07:04:48 GMT
Author: edwardyoon
Date: Tue Apr 21 07:04:48 2015
New Revision: 1675048

URL: http://svn.apache.org/r1675048
Log:
HAMA-952: Configuration overrides HamaConfiguration settings

Modified:
    hama/trunk/core/src/main/java/org/apache/hama/HamaConfiguration.java

Modified: hama/trunk/core/src/main/java/org/apache/hama/HamaConfiguration.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/HamaConfiguration.java?rev=1675048&r1=1675047&r2=1675048&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/HamaConfiguration.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/HamaConfiguration.java Tue Apr 21 07:04:48
2015
@@ -31,7 +31,7 @@ public class HamaConfiguration extends C
   /** constructor */
   public HamaConfiguration() {
     super();
-    addHamaResources();
+    addHamaResources(this);
   }
 
   public HamaConfiguration(Path confFile) {
@@ -52,10 +52,44 @@ public class HamaConfiguration extends C
   }
 
   /**
+   * @return a Configuration with Hama resources
+   */
+  public static Configuration create() {
+    Configuration conf = new Configuration();
+    return addHamaResources(conf);
+  }
+
+  /**
+   * @param that Configuration to clone.
+   * @return a Configuration created with the hama-*.xml files plus the given
+   *         configuration.
+   */
+  public static Configuration create(final Configuration that) {
+    Configuration conf = create();
+    merge(conf, that);
+    return conf;
+  }
+
+  /**
+   * Merge two configurations.
+   * 
+   * @param destConf the configuration that will be overwritten with items from
+   *          the srcConf
+   * @param srcConf the source configuration
+   **/
+  public static void merge(Configuration destConf, Configuration srcConf) {
+    for (Entry<String, String> e : srcConf) {
+      destConf.set(e.getKey(), e.getValue());
+    }
+  }
+
+  /**
    * Adds Hama configuration files to a Configuration
    */
-  private static void addHamaResources() {
-    Configuration.addDefaultResource("hama-default.xml");
-    Configuration.addDefaultResource("hama-site.xml");
+  private static Configuration addHamaResources(Configuration conf) {
+    conf.addResource("hama-default.xml");
+    conf.addResource("hama-site.xml");
+    return conf;
+
   }
 }



Mime
View raw message