pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject svn commit: r944076 - in /hadoop/pig/branches/branch-0.7: CHANGES.txt build.xml conf/pig.properties src/org/apache/pig/impl/util/PropertiesUtil.java test/org/apache/pig/test/TestPigServer.java
Date Fri, 14 May 2010 01:38:29 GMT
Author: daijy
Date: Fri May 14 01:38:29 2010
New Revision: 944076

URL: http://svn.apache.org/viewvc?rev=944076&view=rev
Log:
PIG-1381: Need a way for Pig to take an alternative property file

Modified:
    hadoop/pig/branches/branch-0.7/CHANGES.txt
    hadoop/pig/branches/branch-0.7/build.xml
    hadoop/pig/branches/branch-0.7/conf/pig.properties
    hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/util/PropertiesUtil.java
    hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java

Modified: hadoop/pig/branches/branch-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/CHANGES.txt?rev=944076&r1=944075&r2=944076&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/CHANGES.txt (original)
+++ hadoop/pig/branches/branch-0.7/CHANGES.txt Fri May 14 01:38:29 2010
@@ -68,6 +68,8 @@ manner (rding via pradeepkth)
 
 IMPROVEMENTS
 
+PIG-1381: Need a way for Pig to take an alternative property file (daijy)
+
 PIG-1384: Adding contrib javadoc to main Pig javadoc (daijy)
 
 PIG-1320: final documentation updates for Pig 0.7.0 (chandec via olgan)

Modified: hadoop/pig/branches/branch-0.7/build.xml
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/build.xml?rev=944076&r1=944075&r2=944076&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/build.xml (original)
+++ hadoop/pig/branches/branch-0.7/build.xml Fri May 14 01:38:29 2010
@@ -623,6 +623,7 @@
             <fileset dir="${build.docs}" />
         </copy>
 
+		<copy todir="${dist.dir}/conf" file="conf/pig-default.properties"/>
 		<copy todir="${dist.dir}/conf" file="conf/pig.properties"/>
 
         <copy todir="${dist.dir}/src" includeEmptyDirs="true">

Modified: hadoop/pig/branches/branch-0.7/conf/pig.properties
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/conf/pig.properties?rev=944076&r1=944075&r2=944076&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/conf/pig.properties (original)
+++ hadoop/pig/branches/branch-0.7/conf/pig.properties Fri May 14 01:38:29 2010
@@ -1,18 +1,8 @@
 # Pig configuration file. All values can be overwritten by command line arguments.
-# see bin/pig -help
 
 # log4jconf log4j configuration file
 # log4jconf=./conf/log4j.properties
 
-# brief logging (no timestamps)
-brief=false
-
-# clustername, name of the hadoop jobtracker. If no port is defined port 50020 will be used.

-#cluster
-
-#debug level, INFO is default
-debug=INFO
-
 # a file that contains pig script
 #file=
 
@@ -20,23 +10,15 @@ debug=INFO
 #jar=
 
 #verbose print all log messages to screen (default to print only INFO and above to screen)
-verbose=false
+#verbose=true
 
 #exectype local|mapreduce, mapreduce is default
-exectype=mapreduce
-# hod realted properties
-#ssh.gateway
-#hod.expect.root
-#hod.expect.uselatest
-#hod.command
-#hod.config.dir
-#hod.param
+#exectype=local
 
 #pig.logfile=
 
-
 #Do not spill temp files smaller than this size (bytes)
-pig.spill.size.threshold=5000000
+#pig.spill.size.threshold=5000000
 #EXPERIMENT: Activate garbage collection when spilling a file bigger than this size (bytes)
 #This should help reduce the number of files being spilled.
-pig.spill.gc.activation.size=40000000
+#pig.spill.gc.activation.size=40000000

Modified: hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/util/PropertiesUtil.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/util/PropertiesUtil.java?rev=944076&r1=944075&r2=944076&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/util/PropertiesUtil.java (original)
+++ hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/util/PropertiesUtil.java Fri May
14 01:38:29 2010
@@ -31,16 +31,33 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 public class PropertiesUtil {
+    private static final String DEFAULT_PROPERTIES_FILE = "/pig-default.properties";
     private static final String PROPERTIES_FILE = "/pig.properties";
     private final static Log log = LogFactory.getLog(PropertiesUtil.class);
 
     public static void loadPropertiesFromFile(Properties properties) {
         InputStream inputStream = null;
         BufferedInputStream bis = null;
+        Class<PropertiesUtil> clazz = PropertiesUtil.class;
         try {
-            Class<PropertiesUtil> clazz = PropertiesUtil.class;
             inputStream = clazz
-                    .getResourceAsStream(PROPERTIES_FILE);
+                    .getResourceAsStream(DEFAULT_PROPERTIES_FILE);
+            if (inputStream == null) {
+                String msg = "no pig-default.properties configuration file available in the
classpath";
+                log.debug(msg);
+            } else {
+                properties.load(inputStream);
+            }
+        } catch (Exception e) {
+            log.error("unable to parse pig-default.properties :", e);
+        } finally {
+            if (inputStream != null) try {inputStream.close();} catch (Exception e) {}
+        }
+        
+        try {
+            inputStream = null;
+            inputStream = clazz
+                .getResourceAsStream(PROPERTIES_FILE);
             if (inputStream == null) {
                 String msg = "no pig.properties configuration file available in the classpath";
                 log.debug(msg);

Modified: hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java?rev=944076&r1=944075&r2=944076&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java (original)
+++ hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java Fri May 14
01:38:29 2010
@@ -19,6 +19,7 @@
 package org.apache.pig.test;
 
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
@@ -30,8 +31,10 @@ import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
+import java.io.PrintWriter;
 import java.util.List;
 import java.util.Iterator;
+import java.util.Properties;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.lang.reflect.Method;
@@ -39,6 +42,7 @@ import java.lang.reflect.Method;
 import org.apache.pig.ExecType;
 import org.apache.pig.PigServer;
 import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.util.PropertiesUtil;
 
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -570,4 +574,30 @@ public class TestPigServer extends TestC
         }
         fileWithStdOutContents.close();
     }
+    
+    @Test
+    public void testPigProperties() throws Throwable {
+        File defaultPropertyFile = new File("pig-default.properties");
+        File propertyFile = new File("pig.properties");
+        
+        Properties properties = PropertiesUtil.loadPropertiesFromFile();
+        assertTrue(properties.getProperty("test123")==null);
+
+        PrintWriter out = new PrintWriter(new FileWriter(defaultPropertyFile));
+        out.println("test123=defaultproperties");
+        out.close();
+        
+        properties = PropertiesUtil.loadPropertiesFromFile();
+        assertTrue(properties.getProperty("test123").equals("defaultproperties"));
+
+        out = new PrintWriter(new FileWriter(propertyFile));
+        out.println("test123=properties");
+        out.close();
+
+        properties = PropertiesUtil.loadPropertiesFromFile();
+        assertTrue(properties.getProperty("test123").equals("properties"));
+        
+        defaultPropertyFile.delete();
+        propertyFile.delete();
+    }
 }



Mime
View raw message