Author: rding
Date: Mon Aug  9 22:27:16 2010
New Revision: 983835

URL: http://svn.apache.org/viewvc?rev=983835&view=rev
Log:
PIG-103: Shared Job /tmp location should be configurable

Modified:
    hadoop/pig/trunk/CHANGES.txt
    hadoop/pig/trunk/conf/pig-default.properties
    hadoop/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java
    hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=983835&r1=983834&r2=983835&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon Aug  9 22:27:16 2010
@@ -26,6 +26,8 @@ PIG-1249: Safe-guards against misconfigu
 
 IMPROVEMENTS
 
+PIG-103: Shared Job /tmp location should be configurable (niraj via rding)
+
 PIG-1496: Mandatory rule ImplicitSplitInserter (yanz via daijy)
 
 PIG-346: grant help command cleanup (olgan)

Modified: hadoop/pig/trunk/conf/pig-default.properties
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/conf/pig-default.properties?rev=983835&r1=983834&r2=983835&view=diff
==============================================================================
--- hadoop/pig/trunk/conf/pig-default.properties (original)
+++ hadoop/pig/trunk/conf/pig-default.properties Mon Aug  9 22:27:16 2010
@@ -24,4 +24,7 @@ pig.spill.gc.activation.size=40000000
 
 #the following two parameters are to help estimate the reducer number
 pig.exec.reducers.bytes.per.reducer=1000000000
-pig.exec.reducers.max=999
\ No newline at end of file
+pig.exec.reducers.max=999
+
+#Temporary location to store the intermediate data.
+pig.temp.dir=/tmp/

Modified: hadoop/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java?rev=983835&r1=983834&r2=983835&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java (original)
+++ hadoop/pig/trunk/src/org/apache/pig/impl/io/FileLocalizer.java Mon Aug  9 
22:27:16 2010
@@ -478,7 +478,8 @@ public class FileLocalizer {
             throws DataStorageException {
 
         if (relativeRoot.get() == null) {
-            relativeRoot.set(pigContext.getDfs().asContainer("/tmp/temp" + 
r.nextInt()));
+            String tdir= 
pigContext.getProperties().getProperty("pig.temp.dir", "/tmp");
+            relativeRoot.set(pigContext.getDfs().asContainer(tdir + "/temp" + 
r.nextInt()));
             toDelete().push(relativeRoot.get());
         }
 

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java?rev=983835&r1=983834&r2=983835&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java Mon Aug  9 
22:27:16 2010
@@ -41,12 +41,14 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import org.apache.pig.impl.PigContext;
 
 import junit.framework.TestCase;
 
 import org.apache.pig.ExecType;
 import org.apache.pig.PigServer;
 import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.io.FileLocalizer;
 import org.apache.pig.impl.logicalLayer.schema.Schema;
 import org.apache.pig.impl.util.PropertiesUtil;
 import org.junit.After;
@@ -658,4 +660,21 @@ public class TestPigServer extends TestC
         propertyFile.delete();
         cliPropertyFile.delete();
     }
+
+    @Test
+    public void testPigTempDir() throws Throwable {
+        File defaultPropertyFile = new File("pig-default.properties");
+        PrintWriter out = new PrintWriter(new FileWriter(defaultPropertyFile));
+        out.println("pig.temp.dir=/opt/temp");
+        out.close();
+        Properties properties = PropertiesUtil.loadDefaultProperties();
+        PigContext pigContext=new PigContext(ExecType.LOCAL, properties);
+        pigContext.connect();
+        FileLocalizer.setInitialized(false);
+        String tempPath= FileLocalizer.getTemporaryPath(pigContext).toString();
+        assertTrue(tempPath.startsWith("file:/opt/temp"));
+        defaultPropertyFile.delete();
+        FileLocalizer.setInitialized(false);
+    }
+
 }


Reply via email to