You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chukwa.apache.org by ey...@apache.org on 2010/06/19 23:45:30 UTC

svn commit: r956300 - in /hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa: database/DatabaseConfig.java inputtools/mdl/DataConfig.java

Author: eyang
Date: Sat Jun 19 21:45:30 2010
New Revision: 956300

URL: http://svn.apache.org/viewvc?rev=956300&view=rev
Log:
CHUKWA-490. Enabling mdl.xml to be split into multiple files for ease of maintenance.  (Kirk True via Eric Yang)

Modified:
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/database/DatabaseConfig.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/mdl/DataConfig.java

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/database/DatabaseConfig.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/database/DatabaseConfig.java?rev=956300&r1=956299&r2=956300&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/database/DatabaseConfig.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/database/DatabaseConfig.java Sat Jun 19 21:45:30 2010
@@ -25,6 +25,8 @@ import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.io.File;
+import java.io.FilenameFilter;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -57,6 +59,27 @@ public class DatabaseConfig {
     Path fileResource = new Path(dataConfig);
     config = new Configuration();
     config.addResource(fileResource);
+    
+    if (System.getenv("CHUKWA_CONF_DIR") != null) {
+      // Allow site-specific MDL files to be included in the 
+      // configuration so as to keep the "main" mdl.xml pure.
+      File confDir = new File(System.getenv("CHUKWA_CONF_DIR"));
+      File[] confFiles = confDir.listFiles(new FilenameFilter() {
+
+        @Override
+        public boolean accept(File dir, String name) {
+          // Implements a naming convention of ending with "mdl.xml"
+          // but is careful not to pick up mdl.xml itself again.
+          return name.endsWith(MDL_XML) && !name.equals(MDL_XML);
+        }
+
+      });
+
+      if (confFiles != null) {
+        for (File confFile : confFiles) 
+          config.addResource(new Path(confFile.getAbsolutePath()));
+      }
+    }
   }
 
   public String get(String key) {

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/mdl/DataConfig.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/mdl/DataConfig.java?rev=956300&r1=956299&r2=956300&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/mdl/DataConfig.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/mdl/DataConfig.java Sat Jun 19 21:45:30 2010
@@ -27,6 +27,7 @@ import java.util.Iterator;
 import java.util.HashMap;
 import java.util.Map;
 import java.io.File;
+import java.io.FilenameFilter;
 
 public class DataConfig {
   private static Configuration config;
@@ -56,6 +57,27 @@ public class DataConfig {
         log.debug("Error reading configuration file:" + dataConfig);
       }
     }
+
+    if (System.getenv("CHUKWA_CONF_DIR") != null) {
+      // Allow site-specific MDL files to be included in the
+      // configuration so as to keep the "main" mdl.xml pure.
+      File confDir = new File(System.getenv("CHUKWA_CONF_DIR"));
+      File[] confFiles = confDir.listFiles(new FilenameFilter() {
+
+        @Override
+        public boolean accept(File dir, String name) {
+          // Implements a naming convention of ending with "mdl.xml"
+          // but is careful not to pick up mdl.xml itself again.
+          return name.endsWith(MDL_XML) && !name.equals(MDL_XML);
+        }
+
+      });
+
+      if (confFiles != null) {
+        for (File confFile : confFiles)
+          config.addResource(new Path(confFile.getAbsolutePath()));
+      }
+    }  
   }
 
   public String get(String key) {