Repository: incubator-zeppelin Updated Branches: refs/heads/master 928d09987 -> 4ca8466ab
Fix 'Scheduler already terminated error' exception after restart interpreter In certain condition, interpreter restart cause 'Scheduler already terminated' exception. This PR fixes the bug. Related issue https://issues.apache.org/jira/browse/ZEPPELIN-85 Author: Lee moon soo <[email protected]> Closes #77 from Leemoonsoo/restart_bug and squashes the following commits: 0808879 [Lee moon soo] ZEPPELIN-85 reset interpretergroup when process is not started yet Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/4ca8466a Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/4ca8466a Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/4ca8466a Branch: refs/heads/master Commit: 4ca8466ab3d2c3bacee957ecf62b4e54f86820d7 Parents: 928d099 Author: Lee moon soo <[email protected]> Authored: Thu May 21 17:10:49 2015 +0900 Committer: Lee moon soo <[email protected]> Committed: Sun May 24 10:21:32 2015 +0900 ---------------------------------------------------------------------- .../interpreter/remote/RemoteInterpreter.java | 4 +- .../remote/RemoteInterpreterTest.java | 52 +++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/4ca8466a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java index 4f1e262..1637e9c 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java @@ -319,6 +319,7 @@ public class RemoteInterpreter extends Interpreter { maxConcurrency); } + @Override public void setInterpreterGroup(InterpreterGroup interpreterGroup) { super.setInterpreterGroup(interpreterGroup); @@ -328,7 +329,8 @@ public class RemoteInterpreter extends Interpreter { .get(getInterpreterGroupKey(interpreterGroup)); // when interpreter process is not created or terminated - if (intpProcess == null || (!intpProcess.isRunning() && intpProcess.getPort() > 0)) { + if (intpProcess == null || (!intpProcess.isRunning() && intpProcess.getPort() > 0) + || (!intpProcess.isRunning() && intpProcess.getPort() == -1)) { interpreterGroupReference.put(getInterpreterGroupKey(interpreterGroup), new RemoteInterpreterProcess(interpreterRunner, interpreterPath, env, interpreterContextRunnerPool)); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/4ca8466a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java index 0661bfa..4d5636d 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java @@ -19,6 +19,7 @@ package org.apache.zeppelin.interpreter.remote; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; import java.io.File; @@ -459,7 +460,7 @@ public class RemoteInterpreterTest { } @Test - public void testProcessCreation() { + public void testInterpreterGroupResetBeforeProcessStarts() { Properties p = new Properties(); RemoteInterpreter intpA = new RemoteInterpreter( @@ -476,6 +477,55 @@ public class RemoteInterpreterTest { intpA.setInterpreterGroup(new InterpreterGroup(intpA.getInterpreterGroup().getId())); RemoteInterpreterProcess processB = intpA.getInterpreterProcess(); + assertNotSame(processA.hashCode(), processB.hashCode()); + } + + @Test + public void testInterpreterGroupResetAfterProcessFinished() { + Properties p = new Properties(); + + RemoteInterpreter intpA = new RemoteInterpreter( + p, + MockInterpreterA.class.getName(), + new File("../bin/interpreter.sh").getAbsolutePath(), + "fake", + env + ); + + intpA.setInterpreterGroup(intpGroup); + RemoteInterpreterProcess processA = intpA.getInterpreterProcess(); + intpA.open(); + + processA.dereference(); // intpA.close(); + + intpA.setInterpreterGroup(new InterpreterGroup(intpA.getInterpreterGroup().getId())); + RemoteInterpreterProcess processB = intpA.getInterpreterProcess(); + + assertNotSame(processA.hashCode(), processB.hashCode()); + } + + @Test + public void testInterpreterGroupResetDuringProcessRunning() { + Properties p = new Properties(); + + RemoteInterpreter intpA = new RemoteInterpreter( + p, + MockInterpreterA.class.getName(), + new File("../bin/interpreter.sh").getAbsolutePath(), + "fake", + env + ); + + intpA.setInterpreterGroup(intpGroup); + RemoteInterpreterProcess processA = intpA.getInterpreterProcess(); + intpA.open(); + + intpA.setInterpreterGroup(new InterpreterGroup(intpA.getInterpreterGroup().getId())); + RemoteInterpreterProcess processB = intpA.getInterpreterProcess(); + assertEquals(processA.hashCode(), processB.hashCode()); + + processA.dereference(); // intpA.close(); + } }
