Repository: zeppelin Updated Branches: refs/heads/master eb88b0b9e -> 6418d770b
[ZEPPELIN-2116]. livy interpreter needs to restart after previous session timeout in secured cluster What is this PR for? It throw different exception in secured cluster. This PR fix the issue in secured cluster What type of PR is it? [Bug Fix] Todos - Task What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-2116 How should this be tested? Tested manually. 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 #2021 from zjffdu/ZEPPELIN-2116 and squashes the following commits: 05e6a3c [Jeff Zhang] address comments 96a7cfe [Jeff Zhang] update 63c693b [Jeff Zhang] add more acurrate detection for session expire 7949b51 [Jeff Zhang] [ZEPPELIN-2116]. livy interpreter needs to restart after previous session timeout in secured cluster Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/6418d770 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/6418d770 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/6418d770 Branch: refs/heads/master Commit: 6418d770b23ddf877a7117fffe5d61ddb2d846b0 Parents: eb88b0b Author: Jeff Zhang <zjf...@apache.org> Authored: Sat Feb 18 17:13:10 2017 +0800 Committer: Felix Cheung <felixche...@apache.org> Committed: Mon Feb 20 10:45:11 2017 -0800 ---------------------------------------------------------------------- .../apache/zeppelin/livy/BaseLivyInterprereter.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6418d770/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java ---------------------------------------------------------------------- diff --git a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java index 27e8aaf..7f92127 100644 --- a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java +++ b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterprereter.java @@ -30,6 +30,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.security.kerberos.client.KerberosRestTemplate; import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import java.util.HashMap; @@ -46,6 +47,7 @@ public abstract class BaseLivyInterprereter extends Interpreter { protected static final Logger LOGGER = LoggerFactory.getLogger(BaseLivyInterprereter.class); private static Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); + private static String SESSION_NOT_FOUND_PATTERN = "\"Session '\\d+' not found.\""; protected volatile SessionInfo sessionInfo; private String livyURL; @@ -413,6 +415,15 @@ public abstract class BaseLivyInterprereter extends Interpreter { response = new ResponseEntity(e.getResponseBodyAsString(), e.getStatusCode()); LOGGER.error(String.format("Error with %s StatusCode: %s", response.getStatusCode().value(), e.getResponseBodyAsString())); + } catch (RestClientException e) { + // Exception happens when kerberos is enabled. + if (e.getCause() instanceof HttpClientErrorException) { + HttpClientErrorException cause = (HttpClientErrorException) e.getCause(); + if (cause.getResponseBodyAsString().matches(SESSION_NOT_FOUND_PATTERN)) { + throw new SessionNotFoundException(cause.getResponseBodyAsString()); + } + } + throw new LivyException(e); } if (response == null) { throw new LivyException("No http response returned"); @@ -423,7 +434,7 @@ public abstract class BaseLivyInterprereter extends Interpreter { || response.getStatusCode().value() == 201) { return response.getBody(); } else if (response.getStatusCode().value() == 404) { - if (response.getBody().matches("\"Session '\\d+' not found.\"")) { + if (response.getBody().matches(SESSION_NOT_FOUND_PATTERN)) { throw new SessionNotFoundException(response.getBody()); } else { throw new APINotFoundException("No rest api found for " + targetURL +