Prevent infinitely waiting loop

This commit is contained in:
Lee moon soo 2016-02-23 23:02:31 -08:00
parent 438b212653
commit 45af2dfa93

View file

@ -467,7 +467,17 @@ public class InterpreterFactory {
// if interpreters are already there, wait until they're being removed
synchronized (interpreterGroup) {
long interpreterRemovalWaitStart = System.currentTimeMillis();
// interpreter process supposed to be terminated by RemoteInterpreterProcess.dereference()
// in ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT msec. However, if termination of the process and
// removal from interpreter group take too long, throw an error.
long interpreterRemovalWaitTimeout =
Math.max(10*1000, conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT) * 2);
while (interpreterGroup.containsKey(noteId)) {
if (System.currentTimeMillis() - interpreterRemovalWaitStart >
interpreterRemovalWaitTimeout) {
throw new InterpreterException("Can not create interpreter");
}
try {
interpreterGroup.wait(1000);
} catch (InterruptedException e) {