AMBARI-18768. Session invalidation for hive view. (Ashwin Rajeev via dipayanb)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a8727af8 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a8727af8 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a8727af8 Branch: refs/heads/branch-feature-AMBARI-18634 Commit: a8727af88fd5f6ba5d889854589093e19efdf27a Parents: e9b2512 Author: Dipayan Bhowmick <[email protected]> Authored: Thu Nov 3 00:37:05 2016 +0530 Committer: Dipayan Bhowmick <[email protected]> Committed: Thu Nov 3 00:37:53 2016 +0530 ---------------------------------------------------------------------- .../apache/ambari/view/hive2/actor/JdbcConnector.java | 2 +- .../ambari/view/hive2/client/AsyncJobRunnerImpl.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/a8727af8/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/JdbcConnector.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/JdbcConnector.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/JdbcConnector.java index bb438d2..fcbef81 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/JdbcConnector.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/JdbcConnector.java @@ -385,8 +385,8 @@ public class JdbcConnector extends HiveActor { updateJobStatus(jobId.get(), Job.JOB_STATE_ERROR); } else { sender().tell(new ExecutionFailed("Cannot connect to hive"), ActorRef.noSender()); - cleanUpWithTermination(); } + cleanUpWithTermination(); } private void keepAlive() { http://git-wip-us.apache.org/repos/asf/ambari/blob/a8727af8/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/client/AsyncJobRunnerImpl.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/client/AsyncJobRunnerImpl.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/client/AsyncJobRunnerImpl.java index 182dfbc..82e3df5 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/client/AsyncJobRunnerImpl.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/client/AsyncJobRunnerImpl.java @@ -33,6 +33,8 @@ import org.apache.ambari.view.hive2.actor.message.ResultNotReady; import org.apache.ambari.view.hive2.actor.message.SQLStatementJob; import org.apache.ambari.view.hive2.actor.message.job.CancelJob; import org.apache.ambari.view.hive2.actor.message.job.Failure; +import org.apache.ambari.view.hive2.actor.message.job.FetchFailed; +import org.apache.ambari.view.hive2.internal.ConnectionException; import org.apache.ambari.view.hive2.resources.jobs.viewJobs.Job; import org.apache.ambari.view.hive2.utils.ResultFetchFormattedException; import org.apache.ambari.view.hive2.utils.ResultNotReadyFormattedException; @@ -40,6 +42,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.duration.Duration; +import java.sql.SQLException; import java.util.concurrent.TimeUnit; public class AsyncJobRunnerImpl implements AsyncJobRunner { @@ -124,9 +127,17 @@ public class AsyncJobRunnerImpl implements AsyncJobRunner { Inbox inbox = Inbox.create(system); inbox.send(controller, new FetchError(jobId, username)); Object receive = inbox.receive(Duration.create(1, TimeUnit.MINUTES)); + if(receive instanceof FetchFailed){ + FetchFailed fetchFailed = (FetchFailed) receive; + return Optional.of(new Failure(fetchFailed.getMessage(), getExceptionForRetry())); + } Optional<Failure> result = (Optional<Failure>) receive; return result; } + private ConnectionException getExceptionForRetry() { + return new ConnectionException(new SQLException("Cannot connect"),"Connection attempt failed, Please retry"); + } + }
