You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2016/04/11 10:54:18 UTC

incubator-zeppelin git commit: Generate unique temporary files for Python and R Spark Interpreters.

Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master cf34b68d2 -> f43228bd1


Generate unique temporary files for Python and R Spark Interpreters.

### What is this PR for?
Generate unique temporary files for Python and R Spark interpreters using java.io.File.createTempFile.
Remove the temporary file for the Python interpreter when the interpreter is closed (is already being done in the R interpreter).
Without this fix it is not possible to run more than one Zeppelin interpreter on the same server due to file owner conflicts between instances.

### What type of PR is it?
Bug Fix

### Todos

### What is the Jira issue?
No Jira opened for this

### How should this be tested?

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Johan Muedsam <jm...@att.com>

Closes #823 from mudsam/master and squashes the following commits:

0c018b4 [Johan Muedsam] Generate unique temporary files for Python and R Spark Interpreters. Add cleanup of Python temporary file on close().


Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/f43228bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/f43228bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/f43228bd

Branch: refs/heads/master
Commit: f43228bd19cd02f6b8e6bb0a4c372c0944bc6517
Parents: cf34b68
Author: Johan Muedsam <jm...@att.com>
Authored: Wed Apr 6 23:52:57 2016 -0500
Committer: Lee moon soo <mo...@apache.org>
Committed: Mon Apr 11 17:55:02 2016 +0900

----------------------------------------------------------------------
 .../java/org/apache/zeppelin/spark/PySparkInterpreter.java   | 8 +++++++-
 spark/src/main/java/org/apache/zeppelin/spark/ZeppelinR.java | 8 ++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f43228bd/spark/src/main/java/org/apache/zeppelin/spark/PySparkInterpreter.java
----------------------------------------------------------------------
diff --git a/spark/src/main/java/org/apache/zeppelin/spark/PySparkInterpreter.java b/spark/src/main/java/org/apache/zeppelin/spark/PySparkInterpreter.java
index 152f70c..ea00541 100644
--- a/spark/src/main/java/org/apache/zeppelin/spark/PySparkInterpreter.java
+++ b/spark/src/main/java/org/apache/zeppelin/spark/PySparkInterpreter.java
@@ -91,7 +91,12 @@ public class PySparkInterpreter extends Interpreter implements ExecuteResultHand
   public PySparkInterpreter(Properties property) {
     super(property);
 
-    scriptPath = System.getProperty("java.io.tmpdir") + "/zeppelin_pyspark.py";
+    try {
+      File scriptFile = File.createTempFile("zeppelin_pyspark-", ".py");
+      scriptPath = scriptFile.getAbsolutePath();
+    } catch (IOException e) {
+      throw new InterpreterException(e);
+    }
   }
 
   private void createPythonScript() {
@@ -235,6 +240,7 @@ public class PySparkInterpreter extends Interpreter implements ExecuteResultHand
   @Override
   public void close() {
     executor.getWatchdog().destroyProcess();
+    new File(scriptPath).delete();
     gatewayServer.shutdown();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f43228bd/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinR.java
----------------------------------------------------------------------
diff --git a/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinR.java b/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinR.java
index 8d92c96..93a3bcb 100644
--- a/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinR.java
+++ b/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinR.java
@@ -111,8 +111,12 @@ public class ZeppelinR implements ExecuteResultHandler {
     this.rCmdPath = rCmdPath;
     this.libPath = libPath;
     this.port = sparkRBackendPort;
-    scriptPath = System.getProperty("java.io.tmpdir") + "/zeppelin_sparkr.R";
-
+    try {
+      File scriptFile = File.createTempFile("zeppelin_sparkr-", ".R");
+      scriptPath = scriptFile.getAbsolutePath();
+    } catch (IOException e) {
+      throw new InterpreterException(e);
+    }
   }
 
   /**