This is an automated email from the ASF dual-hosted git repository. zjffdu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push: new 80de2c8 [ZEPPELIN-5621] add configuration of tmp_path to store compiled files like scala_shell_tmp-xxx.jar (#4328) 80de2c8 is described below commit 80de2c811d1367daad975faa069f24d06871522c Author: Jeff Zhang <zjf...@apache.org> AuthorDate: Thu Mar 31 15:47:23 2022 +0800 [ZEPPELIN-5621] add configuration of tmp_path to store compiled files like scala_shell_tmp-xxx.jar (#4328) * [ZEPPELIN-5621] add configuration of tmp_path to store compiled files like scala_shell_tmp-xxx.jar * Address comment * fix ci --- docs/interpreter/flink.md | 6 +++++- .../src/main/resources/interpreter-setting.json | 7 +++++++ .../apache/zeppelin/flink/internal/FlinkILoop.scala | 18 +++++++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/docs/interpreter/flink.md b/docs/interpreter/flink.md index 8e0476c..029394c 100644 --- a/docs/interpreter/flink.md +++ b/docs/interpreter/flink.md @@ -285,7 +285,11 @@ You can also add and set other Flink properties which are not listed in the tabl <td>true</td> <td>Whether display Scala shell output in colorful format</td> </tr> - + <tr> + <td>zeppelin.flink.scala.shell.tmp_dir</td> + <td></td> + <td>Temp folder for storing scala shell compiled jar</td> + </tr> <tr> <td>zeppelin.flink.enableHive</td> <td>false</td> diff --git a/flink/flink-scala-parent/src/main/resources/interpreter-setting.json b/flink/flink-scala-parent/src/main/resources/interpreter-setting.json index dd67130..9da270a 100644 --- a/flink/flink-scala-parent/src/main/resources/interpreter-setting.json +++ b/flink/flink-scala-parent/src/main/resources/interpreter-setting.json @@ -138,6 +138,13 @@ "description": "Whether display scala shell output in colorful format", "type": "checkbox" }, + "zeppelin.flink.scala.shell.tmp_dir": { + "envName": "zeppelin.flink.scala.shell.tmp_dir", + "propertyName": "zeppelin.flink.scala.shell.tmp_dir", + "defaultValue": "", + "description": "Temp folder for storing scala shell compiled jar", + "type": "string" + }, "zeppelin.flink.enableHive": { "envName": null, "propertyName": null, diff --git a/flink/flink-scala-parent/src/main/scala/org/apache/zeppelin/flink/internal/FlinkILoop.scala b/flink/flink-scala-parent/src/main/scala/org/apache/zeppelin/flink/internal/FlinkILoop.scala index 1be64ab..eedcbe4 100644 --- a/flink/flink-scala-parent/src/main/scala/org/apache/zeppelin/flink/internal/FlinkILoop.scala +++ b/flink/flink-scala-parent/src/main/scala/org/apache/zeppelin/flink/internal/FlinkILoop.scala @@ -22,14 +22,16 @@ package org.apache.zeppelin.flink.internal import org.apache.flink.configuration.Configuration import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment import org.apache.flink.util.AbstractID -import java.io.{BufferedReader, File, FileOutputStream, IOException} +import java.io.{BufferedReader, File, FileOutputStream, IOException} import org.apache.flink.streaming.api.environment.{StreamExecutionEnvironment => JStreamExecutionEnvironment} import org.apache.flink.api.java.{ExecutionEnvironment => JExecutionEnvironment} import org.apache.flink.api.scala.ExecutionEnvironment import org.apache.flink.core.execution.PipelineExecutorServiceLoader import org.apache.zeppelin.flink.{ApplicationModeExecutionEnvironment, ApplicationModeStreamEnvironment, FlinkScalaInterpreter} import FlinkShell.ExecutionMode +import org.apache.commons.lang.StringUtils +import org.slf4j.{Logger, LoggerFactory} import scala.tools.nsc.interpreter._ @@ -45,6 +47,7 @@ class FlinkILoop( flinkScalaInterpreter: FlinkScalaInterpreter) extends ILoop(in0, out0) { + private lazy val LOGGER: Logger = LoggerFactory.getLogger(getClass) // remote environment private val (remoteBenv: ScalaShellEnvironment, @@ -101,11 +104,16 @@ class FlinkILoop( private val tmpDirBase: File = { // get unique temporary folder: val abstractID: String = new AbstractID().toString - val tmpDir: File = new File( - System.getProperty("java.io.tmpdir"), - "scala_shell_tmp-" + abstractID) + var scalaShellTmpParentFolder = flinkScalaInterpreter.properties.getProperty("zeppelin.flink.scala.shell.tmp_dir") + if (StringUtils.isBlank(scalaShellTmpParentFolder)) { + scalaShellTmpParentFolder = System.getProperty("java.io.tmpdir") + } + val tmpDir: File = new File(scalaShellTmpParentFolder, "scala_shell_tmp-" + abstractID) + LOGGER.info("Folder for scala shell compiled jar: {}", tmpDir.getAbsolutePath) if (!tmpDir.exists) { - tmpDir.mkdir + if (!tmpDir.mkdirs()) { + throw new IOException(s"Unable to make tmp dir ${tmpDir.getAbsolutePath} for scala shell") + } } tmpDir }