mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
ZEPPELIN-2999: Cannot create shell interpreter without timeout property
This commit is contained in:
parent
84cb4b5fb9
commit
e2a62f63d2
1 changed files with 12 additions and 1 deletions
|
|
@ -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 Long DEFAULT_TIMEOUT_PROPERTY = 60000l;
|
||||
|
||||
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,15 @@ 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))));
|
||||
|
||||
Long timeOutProperty;
|
||||
try {
|
||||
timeOutProperty = Long.valueOf(getProperty(TIMEOUT_PROPERTY));
|
||||
} catch (Exception e) {
|
||||
timeOutProperty = DEFAULT_TIMEOUT_PROPERTY;
|
||||
LOGGER.error("Cannot convert TIMEOUT_PROPERTY to Long value, switching to default value", e);
|
||||
}
|
||||
executor.setWatchdog(new ExecuteWatchdog(timeOutProperty));
|
||||
executors.put(contextInterpreter.getParagraphId(), executor);
|
||||
if (Boolean.valueOf(getProperty(DIRECTORY_USER_HOME))) {
|
||||
executor.setWorkingDirectory(new File(System.getProperty("user.home")));
|
||||
|
|
|
|||
Loading…
Reference in a new issue