Repository: ambari Updated Branches: refs/heads/branch-2.4 3eccddb4e -> 9aa19d427
AMBARI-17076 Hive view 2.0.0 Instance has issues connecting to database in secure mode. (Ashween 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/9aa19d42 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9aa19d42 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9aa19d42 Branch: refs/heads/branch-2.4 Commit: 9aa19d427953a9dd7c109fd6ceafbc04e9e9c69b Parents: 3eccddb Author: Dipayan Bhowmick <[email protected]> Authored: Tue Jun 7 23:48:22 2016 +0530 Committer: Dipayan Bhowmick <[email protected]> Committed: Tue Jun 7 23:48:22 2016 +0530 ---------------------------------------------------------------------- .../ambari/view/hive2/ConnectionFactory.java | 34 ++++++++++++-------- .../view/hive2/actor/AsyncJdbcConnector.java | 19 ++++++----- .../ambari/view/hive2/actor/DeathWatch.java | 2 +- .../ambari/view/hive2/actor/HiveActor.java | 9 +++--- .../view/hive2/actor/OperationController.java | 4 +-- .../jobs/ResultsPaginationController.java | 15 --------- 6 files changed, 37 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9aa19d42/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java index 3390b28..2f7ffe0 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionFactory.java @@ -20,6 +20,7 @@ package org.apache.ambari.view.hive2; import com.google.common.base.Function; import com.google.common.base.Joiner; +import com.google.common.base.Strings; import com.google.common.collect.FluentIterable; import org.apache.ambari.view.ViewContext; import org.apache.ambari.view.hive2.client.ConnectionConfig; @@ -28,23 +29,23 @@ import java.util.List; public class ConnectionFactory { - private static String ZK_HIVE_DYN_SERVICE_DISCOVERY_KEY = "hive.server2.support.dynamic.service.discovery"; - private static String ZK_HIVE_NAMESPACE_KEY = "hive.server2.zookeeper.namespace"; - private static String ZK_HIVE_QUORUM = "hive.zookeeper.quorum"; + private static final String ZK_HIVE_DYN_SERVICE_DISCOVERY_KEY = "hive.server2.support.dynamic.service.discovery"; + private static final String ZK_HIVE_NAMESPACE_KEY = "hive.server2.zookeeper.namespace"; + private static final String ZK_HIVE_QUORUM = "hive.zookeeper.quorum"; - private static String AMBARI_HIVE_SERVICE_NAME = "HIVE"; - private static String AMBARI_HIVESERVER_COMPONENT_NAME = "HIVE_SERVER"; + private static final String AMBARI_HIVE_SERVICE_NAME = "HIVE"; + private static final String AMBARI_HIVESERVER_COMPONENT_NAME = "HIVE_SERVER"; - private static String HIVE_SITE = "hive-site"; - private static String HIVE_INTERACTIVE_SITE = "hive-interactive-site"; + private static final String HIVE_SITE = "hive-site"; + private static final String HIVE_INTERACTIVE_SITE = "hive-interactive-site"; - private static String HIVE_JDBC_URL_KEY = "hive.jdbc.url"; + private static final String HIVE_JDBC_URL_KEY = "hive.jdbc.url"; private static final String HIVE_SESSION_PARAMS = "hive.session.params"; - private static String BINARY_PORT_KEY = "hive.server2.thrift.port"; - private static String HTTP_PORT_KEY = "hive.server2.thrift.http.port"; - private static String HIVE_TRANSPORT_MODE_KEY = "hive.server2.transport.mode"; - private static String HTTP_PATH_KEY = "hive.server2.thrift.http.path"; + private static final String BINARY_PORT_KEY = "hive.server2.thrift.port"; + private static final String HTTP_PORT_KEY = "hive.server2.thrift.http.port"; + private static final String HIVE_TRANSPORT_MODE_KEY = "hive.server2.transport.mode"; + private static final String HTTP_PATH_KEY = "hive.server2.thrift.http.path"; public static ConnectionConfig create(ViewContext context) { @@ -106,7 +107,14 @@ public class ConnectionFactory { if (namespace == null) { namespace = context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, ZK_HIVE_NAMESPACE_KEY); } - return String.format("jdbc:hive2://%s/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=%s", quorum, namespace); + + String sessionParams = context.getProperties().get(HIVE_SESSION_PARAMS); + + String formatted = String.format("jdbc:hive2://%s/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=%s", quorum, namespace); + if(!Strings.isNullOrEmpty(sessionParams)){ + return formatted + ";" + sessionParams; + } + return formatted; } private static boolean zookeeperConfigured(ViewContext context) { http://git-wip-us.apache.org/repos/asf/ambari/blob/9aa19d42/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/AsyncJdbcConnector.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/AsyncJdbcConnector.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/AsyncJdbcConnector.java index 2133cd6..9d3517f 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/AsyncJdbcConnector.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/AsyncJdbcConnector.java @@ -24,19 +24,19 @@ import akka.actor.PoisonPill; import akka.actor.Props; import com.google.common.base.Optional; import org.apache.ambari.view.ViewContext; -import org.apache.ambari.view.hive2.actor.message.RegisterActor; -import org.apache.ambari.view.hive2.persistence.Storage; -import org.apache.ambari.view.hive2.persistence.utils.ItemNotFound; -import org.apache.ambari.view.hive2.resources.jobs.viewJobs.Job; -import org.apache.ambari.view.hive2.resources.jobs.viewJobs.JobImpl; import org.apache.ambari.view.hive2.ConnectionDelegate; import org.apache.ambari.view.hive2.actor.message.AsyncJob; import org.apache.ambari.view.hive2.actor.message.HiveMessage; +import org.apache.ambari.view.hive2.actor.message.RegisterActor; import org.apache.ambari.view.hive2.actor.message.ResultReady; +import org.apache.ambari.view.hive2.actor.message.StartLogAggregation; import org.apache.ambari.view.hive2.actor.message.job.AsyncExecutionFailed; import org.apache.ambari.view.hive2.actor.message.lifecycle.InactivityCheck; -import org.apache.ambari.view.hive2.actor.message.StartLogAggregation; import org.apache.ambari.view.hive2.internal.Either; +import org.apache.ambari.view.hive2.persistence.Storage; +import org.apache.ambari.view.hive2.persistence.utils.ItemNotFound; +import org.apache.ambari.view.hive2.resources.jobs.viewJobs.Job; +import org.apache.ambari.view.hive2.resources.jobs.viewJobs.JobImpl; import org.apache.ambari.view.utils.hdfs.HdfsApi; import org.apache.hive.jdbc.HiveConnection; import org.apache.hive.jdbc.HiveStatement; @@ -46,7 +46,6 @@ import scala.concurrent.duration.Duration; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.UUID; import java.util.concurrent.TimeUnit; public class AsyncJdbcConnector extends JdbcConnector { @@ -123,7 +122,7 @@ public class AsyncJdbcConnector extends JdbcConnector { logAggregator = getContext().actorOf( Props.create(LogAggregator.class, system, hdfsApi, currentStatement.get(), message.getLogFile()) - .withDispatcher("akka.actor.misc-dispatcher"), message.getUsername() + ":" + message.getJobId() + "-logAggregator" + .withDispatcher("akka.actor.misc-dispatcher"), message.getJobId() + ":" +"-logAggregator" ); deathWatch.tell(new RegisterActor(logAggregator),self()); @@ -135,7 +134,7 @@ public class AsyncJdbcConnector extends JdbcConnector { // tell the result holder to assign the result set for further operations resultSetActor = getContext().actorOf(Props.create(ResultSetIterator.class, self(), resultSetOptional.get(),storage).withDispatcher("akka.actor.result-dispatcher"), - "ResultSetActor:ResultSetIterator:JobId:"+ jobId+":" + UUID.randomUUID().toString()); + "ResultSetActor:ResultSetIterator:JobId:"+ jobId ); deathWatch.tell(new RegisterActor(resultSetActor),self()); parent.tell(new ResultReady(jobId,username, Either.<ActorRef, ActorRef>left(resultSetActor)), self()); @@ -147,7 +146,7 @@ public class AsyncJdbcConnector extends JdbcConnector { ActorRef asyncQueryExecutor = getContext().actorOf( Props.create(AsyncQueryExecutor.class, parent, currentStatement.get(),storage,jobId,username) .withDispatcher("akka.actor.result-dispatcher"), - message.getUsername() + ":" + message.getJobId() + "-asyncQueryExecutor"); + message.getJobId() + "-asyncQueryExecutor"); deathWatch.tell(new RegisterActor(asyncQueryExecutor),self()); parent.tell(new ResultReady(jobId,username, Either.<ActorRef, ActorRef>right(asyncQueryExecutor)), self()); http://git-wip-us.apache.org/repos/asf/ambari/blob/9aa19d42/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/DeathWatch.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/DeathWatch.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/DeathWatch.java index ffca691..c146dd0 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/DeathWatch.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/DeathWatch.java @@ -45,7 +45,7 @@ public class DeathWatch extends HiveActor { if(message instanceof Terminated){ Terminated terminated = (Terminated) message; ActorRef actor = terminated.actor(); - LOG.info("Received deathwatch for actor "+ actor); + LOG.info("Received terminate for actor "+ actor); LOG.info("Termination for {} at {}", actor,new Date()); } http://git-wip-us.apache.org/repos/asf/ambari/blob/9aa19d42/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/HiveActor.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/HiveActor.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/HiveActor.java index 8bf2df8..63e5dd1 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/HiveActor.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/HiveActor.java @@ -30,18 +30,17 @@ public abstract class HiveActor extends UntypedActor { @Override final public void onReceive(Object message) throws Exception { HiveMessage hiveMessage = new HiveMessage(message); - /*if(LOG.isDebugEnabled()){ + if(LOG.isDebugEnabled()){ LOG.debug("Received message: " + message.getClass().getName() + ", generated id: " + hiveMessage.getId() + " sent by: " + sender() + ", recieved by" + self()); - }*/ + } handleMessage(hiveMessage); - /*if(LOG.isDebugEnabled()){ + if(LOG.isDebugEnabled()){ LOG.debug("Message submitted: " + hiveMessage.getId()); - }*/ - + } } abstract void handleMessage(HiveMessage hiveMessage); http://git-wip-us.apache.org/repos/asf/ambari/blob/9aa19d42/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/OperationController.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/OperationController.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/OperationController.java index 63a45d5..ac62cf7 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/OperationController.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/OperationController.java @@ -235,7 +235,7 @@ public class OperationController extends HiveActor { Props.create(AsyncJdbcConnector.class, viewContext, hdfsApi, system, self(), deathWatch, connectionSupplier.get(viewContext), storageSupplier.get(viewContext)).withDispatcher("akka.actor.jdbc-connector-dispatcher"), - username + ":" + "jobId:" + jobId + ":" + UUID.randomUUID().toString() + ":asyncjdbcConnector"); + "jobId:" + jobId + ":-asyncjdbcConnector"); deathWatch.tell(new RegisterActor(subActor),self()); } @@ -300,7 +300,7 @@ public class OperationController extends HiveActor { Props.create(SyncJdbcConnector.class, viewContext, hdfsApi, system, self(), deathWatch, connectionSupplier.get(viewContext), storageSupplier.get(viewContext)).withDispatcher("akka.actor.jdbc-connector-dispatcher"), - username + ":" + UUID.randomUUID().toString() + ":SyncjdbcConnector" ); + UUID.randomUUID().toString() + ":SyncjdbcConnector" ); deathWatch.tell(new RegisterActor(subActor),self()); } http://git-wip-us.apache.org/repos/asf/ambari/blob/9aa19d42/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/ResultsPaginationController.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/ResultsPaginationController.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/ResultsPaginationController.java index 4e4e7ff..6131d03 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/ResultsPaginationController.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/ResultsPaginationController.java @@ -190,17 +190,6 @@ public class ResultsPaginationController { } } - public static Response.ResponseBuilder emptyResponse() { - ResultsResponse resultsResponse = new ResultsResponse(); - resultsResponse.setSchema(new ArrayList<ColumnDescription>()); - resultsResponse.setRows(new ArrayList<Object[]>()); - resultsResponse.setReadCount(0); - resultsResponse.setHasNext(false); - resultsResponse.setOffset(0); - resultsResponse.setHasResults(false); - return Response.ok(resultsResponse); - } - private <T> List<T> filter(List<T> list, Set<Integer> selectedColumns) { List<T> filtered = Lists.newArrayList(); for(int i: selectedColumns) { @@ -268,10 +257,6 @@ public class ResultsPaginationController { this.readCount = readCount; } - public int getReadCount() { - return readCount; - } - public void setHasNext(boolean hasNext) { this.hasNext = hasNext; }
