Repository: zeppelin Updated Branches: refs/heads/master 09dc9fcae -> 176f26faf
ZEPPELIN-3865. Paragraph cancel is broken ### What is this PR for? Paragraph cancel is broken due to previous code refactoring, This PR fix it in straightforward way and add system test as well. ### What type of PR is it? [Bug Fix ] ### Todos * [ ] - Task ### What is the Jira issue? * https://jira.apache.org/jira/browse/ZEPPELIN-3865 ### How should this be tested? * CI pass ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jeff Zhang <zjf...@apache.org> Closes #3228 from zjffdu/ZEPPELIN-3865 and squashes the following commits: 574a1b9a6 [Jeff Zhang] ZEPPELIN-3865. Paragraph cancel is broken Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/176f26fa Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/176f26fa Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/176f26fa Branch: refs/heads/master Commit: 176f26faf8ab12c36cd3916abbb1fb02999c0883 Parents: 09dc9fc Author: Jeff Zhang <zjf...@apache.org> Authored: Fri Nov 16 13:16:26 2018 +0800 Committer: jeffzhang.zjf <jeffzhang....@alibaba-inc.com> Committed: Mon Nov 26 10:01:57 2018 +0800 ---------------------------------------------------------------------- .../zeppelin/rest/ZeppelinSparkClusterTest.java | 25 +++++++++++++++++--- .../org/apache/zeppelin/notebook/Paragraph.java | 7 +++--- 2 files changed, 26 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/176f26fa/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java index 932d077..49b8599 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java @@ -136,8 +136,18 @@ public class ZeppelinSparkClusterTest extends AbstractTestRestApi { private void waitForFinish(Paragraph p) { while (p.getStatus() != Status.FINISHED - && p.getStatus() != Status.ERROR - && p.getStatus() != Status.ABORT) { + && p.getStatus() != Status.ERROR + && p.getStatus() != Status.ABORT) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + LOG.error("Exception in WebDriverManager while getWebDriver ", e); + } + } + } + + private void waitForRunning(Paragraph p) { + while (p.getStatus() != Status.RUNNING) { try { Thread.sleep(100); } catch (InterruptedException e) { @@ -147,7 +157,7 @@ public class ZeppelinSparkClusterTest extends AbstractTestRestApi { } @Test - public void scalaOutputTest() throws IOException { + public void scalaOutputTest() throws IOException, InterruptedException { // create new note Note note = ZeppelinServer.notebook.createNote("note1", anonymous); Paragraph p = note.addNewParagraph(anonymous); @@ -176,6 +186,15 @@ public class ZeppelinSparkClusterTest extends AbstractTestRestApi { // test code completion List<InterpreterCompletion> completions = note.completion(p.getId(), "sc.", 2); assertTrue(completions.size() > 0); + + // test cancel + p.setText("%spark sc.range(1,10).map(e=>{Thread.sleep(1000); e}).collect()"); + note.run(p.getId(), false); + waitForRunning(p); + p.abort(); + waitForFinish(p); + assertEquals(Status.ABORT, p.getStatus()); + ZeppelinServer.notebook.removeNote(note.getId(), anonymous); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/176f26fa/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java index cfec18b..bd3104f 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java @@ -461,9 +461,10 @@ public class Paragraph extends JobWithProgressPoller<InterpreterResult> implemen if (interpreter == null) { return true; } - Scheduler scheduler = interpreter.getScheduler(); - if (scheduler == null) { - return true; + try { + interpreter.cancel(getInterpreterContext(null)); + } catch (InterpreterException e) { + throw new RuntimeException(e); } return true;