Repository: zeppelin Updated Branches: refs/heads/master 24f81426c -> d5a3c7444
ZEPPELIN-2988. Zeppelin does not start new Livy session if yarn livy session application is killed ### What is this PR for? This PR will display a warning message when the livy session is dead. It won't restart it automatically, because livy session may be dead due to user code (like driver OOM). Restarting it automatically will hide the root cause and confuse users. ### What type of PR is it? [Improvement] ### Todos * [ ] - Task ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-2988 ### How should this be tested? * Manually tested ### Screenshots (if appropriate) ![image](https://user-images.githubusercontent.com/164491/31598273-4cac4afa-b212-11e7-8d82-7d870bd84c9b.png) ### Questions: * Does the licenses files need update? * Is there breaking changes for older versions? * Does this needs documentation? Author: Jeff Zhang <zjf...@apache.org> Closes #2625 from zjffdu/ZEPPELIN-2988 and squashes the following commits: 0e4d281 [Jeff Zhang] ZEPPELIN-2988. Zeppelin does not start new Livy session if yarn livy session application is killed Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/d5a3c744 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/d5a3c744 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/d5a3c744 Branch: refs/heads/master Commit: d5a3c74442ab9e979a9cc4fb5c76a3426c03051a Parents: 24f8142 Author: Jeff Zhang <zjf...@apache.org> Authored: Fri Oct 13 13:50:00 2017 +0800 Committer: Jeff Zhang <zjf...@apache.org> Committed: Wed Oct 18 11:28:42 2017 +0800 ---------------------------------------------------------------------- .../org/apache/zeppelin/livy/BaseLivyInterpreter.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/d5a3c744/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java ---------------------------------------------------------------------- diff --git a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java index 03a269e..2122f53 100644 --- a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java +++ b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java @@ -48,6 +48,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.security.kerberos.client.KerberosRestTemplate; import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import javax.net.ssl.SSLContext; @@ -290,6 +291,7 @@ public abstract class BaseLivyInterpreter extends Interpreter { } stmtInfo = executeStatement(new ExecuteRequest(code)); } + // pull the statement status while (!stmtInfo.isAvailable()) { if (paragraphId != null && paragraphsToCancel.contains(paragraphId)) { @@ -358,7 +360,7 @@ public abstract class BaseLivyInterpreter extends Interpreter { InterpreterResult result2 = new InterpreterResult(result.code()); result2.add(InterpreterResult.Type.HTML, "<font color=\"red\">Previous livy session is expired, new livy session is created. " + - "Paragraphs that depend on this paragraph need to be re-executed!" + "</font>"); + "Paragraphs that depend on this paragraph need to be re-executed!</font>"); for (InterpreterResultMessage message : result.message()) { result2.add(message.getType(), message.getData()); } @@ -582,6 +584,15 @@ public abstract class BaseLivyInterpreter extends Interpreter { throw new LivyException(cause.getResponseBodyAsString() + "\n" + ExceptionUtils.getFullStackTrace(ExceptionUtils.getRootCause(e))); } + if (e instanceof HttpServerErrorException) { + HttpServerErrorException errorException = (HttpServerErrorException) e; + String errorResponse = errorException.getResponseBodyAsString(); + if (errorResponse.contains("Session is in state dead")) { + throw new LivyException("%html <font color=\"red\">Livy session is dead somehow, " + + "please check log to see why it is dead, and then restart livy interpreter</font>"); + } + throw new LivyException(errorResponse, e); + } throw new LivyException(e); } if (response == null) {