Repository: zeppelin Updated Branches: refs/heads/master 49ccc29b6 -> fc7c7b46e
[ZEPPELIN-2999] Cannot create shell interpreter without timeout property ### What is this PR for? A user can not run any shell interpreter if "shell.command.timeout.millisecs" is not present in interpreter setting. ### What type of PR is it? [Improvement] ### What is the Jira issue? * [https://issues.apache.org/jira/browse/ZEPPELIN-2999](https://issues.apache.org/jira/browse/ZEPPELIN-2999) ### How should this be tested? * Remove "shell.command.timeout.millisecs" from sh interpreter settings and then try to run any sh paragraph, it should run without any error. ### Questions: * Does the licenses files need update? N/A * Is there breaking changes for older versions? N/A * Does this needs documentation? N/A Author: Prabhjyot Singh <[email protected]> Closes #2628 from prabhjyotsingh/ZEPPELIN-2999 and squashes the following commits: 4406157d2 [Prabhjyot Singh] use "getProperty(String key, String defaultValue)" instead of "getProperty(String key)" e2a62f63d [Prabhjyot Singh] ZEPPELIN-2999: Cannot create shell interpreter without timeout property Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/fc7c7b46 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/fc7c7b46 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/fc7c7b46 Branch: refs/heads/master Commit: fc7c7b46e4875e51ada65a964a975fa3cde45c28 Parents: 49ccc29 Author: Prabhjyot Singh <[email protected]> Authored: Mon Oct 23 13:01:19 2017 +0530 Committer: Prabhjyot Singh <[email protected]> Committed: Sun Oct 29 09:27:05 2017 +0530 ---------------------------------------------------------------------- .../main/java/org/apache/zeppelin/shell/ShellInterpreter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fc7c7b46/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java ---------------------------------------------------------------------- diff --git a/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java b/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java index b7c0043..9707205 100644 --- a/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java +++ b/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java @@ -47,7 +47,10 @@ import org.slf4j.LoggerFactory; */ public class ShellInterpreter extends KerberosInterpreter { private static final Logger LOGGER = LoggerFactory.getLogger(ShellInterpreter.class); + private static final String TIMEOUT_PROPERTY = "shell.command.timeout.millisecs"; + private String DEFAULT_TIMEOUT_PROPERTY = "60000"; + private static final String DIRECTORY_USER_HOME = "shell.working.directory.user.home"; private final boolean isWindows = System.getProperty("os.name").startsWith("Windows"); private final String shell = isWindows ? "cmd /c" : "bash -c"; @@ -98,7 +101,9 @@ public class ShellInterpreter extends KerberosInterpreter { DefaultExecutor executor = new DefaultExecutor(); executor.setStreamHandler(new PumpStreamHandler( contextInterpreter.out, contextInterpreter.out)); - executor.setWatchdog(new ExecuteWatchdog(Long.valueOf(getProperty(TIMEOUT_PROPERTY)))); + + executor.setWatchdog(new ExecuteWatchdog( + Long.valueOf(getProperty(TIMEOUT_PROPERTY, DEFAULT_TIMEOUT_PROPERTY)))); executors.put(contextInterpreter.getParagraphId(), executor); if (Boolean.valueOf(getProperty(DIRECTORY_USER_HOME))) { executor.setWorkingDirectory(new File(System.getProperty("user.home")));
