Repository: zeppelin Updated Branches: refs/heads/branch-0.6 1fcfe5dca -> d74e5d0e3
[ZEPPELIN-1196] Fix for bug ZEPPELIN-1196 ### What is this PR for? Fixed issue related to connecting to remote running interpreter process with multiple interpreters in interpreter group throws illegal thread state exception ### What type of PR is it? Bug Fix ### Todos ### What is the Jira issue? [ZEPPELIN-1196] https://issues.apache.org/jira/browse/ZEPPELIN-1196 ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Sachin <[email protected]> Closes #1197 from SachinJanani/branch-0.6 and squashes the following commits: b3f2aa4 [Sachin] Removed unused variable and incorporated review comments cf971ab [Sachin] Junit test for ZEPPELIN-1196 b922b8f [Sachin] [ZEPPELIN-1196] Fix for bug ZEPPELIN-1196 Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/d74e5d0e Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/d74e5d0e Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/d74e5d0e Branch: refs/heads/branch-0.6 Commit: d74e5d0e317fbc200fbf9ebd4ebfb77e39f40b6e Parents: 1fcfe5d Author: Sachin <[email protected]> Authored: Tue Jul 19 14:13:45 2016 +0530 Committer: Jongyoul Lee <[email protected]> Committed: Fri Jul 22 13:39:12 2016 +0900 ---------------------------------------------------------------------- .../remote/RemoteInterpreterProcess.java | 5 +++ .../remote/RemoteInterpreterProcessTest.java | 32 ++++++++++++++++++++ 2 files changed, 37 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/d74e5d0e/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcess.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcess.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcess.java index 05baf62..b4579bc 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcess.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcess.java @@ -113,6 +113,11 @@ public class RemoteInterpreterProcess implements ExecuteResultHandler { + "Please specify the port on which interpreter is listening"); } } + executor = new DefaultExecutor(); + + watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT); + executor.setWatchdog(watchdog); + running = true; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/d74e5d0e/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcessTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcessTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcessTest.java index f9d7d39..77571a9 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcessTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterProcessTest.java @@ -103,4 +103,36 @@ public class RemoteInterpreterProcessTest { assertEquals(1, rip.reference(intpGroup)); assertEquals(true, rip.isRunning()); } + + + @Test + public void testRemoteInterpreterWithMultipleInterpreterInGroup() throws TException, InterruptedException { + RemoteInterpreterServer server = new RemoteInterpreterServer(3679); + server.start(); + long startTime = System.currentTimeMillis(); + /*If RemoteInterpreterServer didn't start within 30 seconds than this test may fail + * which might be due to issue in RemoteInterpreterServer + */ + while (System.currentTimeMillis() - startTime < 30 * 1000) { + if (server.isRunning()) { + break; + } else { + Thread.sleep(200); + } + } + Properties properties = new Properties(); + properties.setProperty(Constants.ZEPPELIN_INTERPRETER_PORT, "3679"); + properties.setProperty(Constants.ZEPPELIN_INTERPRETER_HOST, "localhost"); + InterpreterGroup intpGroup = mock(InterpreterGroup.class); + when(intpGroup.getProperty()).thenReturn(properties); + when(intpGroup.containsKey(Constants.EXISTING_PROCESS)).thenReturn(true); + RemoteInterpreterProcess rip = new RemoteInterpreterProcess(INTERPRETER_SCRIPT, "nonexists", + "fakeRepo", new HashMap<String, String>(), 30 * 1000, null); + assertFalse(rip.isRunning()); + assertEquals(0, rip.referenceCount()); + assertEquals(1, rip.reference(intpGroup)); + // Calling reference once again to depict multiple intrepreters in a group + assertEquals(2, rip.reference(intpGroup)); + assertEquals(true, rip.isRunning()); + } }
