ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbhowm...@apache.org
Subject ambari git commit: AMBARI-17515. Hive View 2.0.0 Instance - Query is not returning result. (dipayanb)
Date Mon, 04 Jul 2016 06:18:53 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d2a008070 -> 74a2afd2f


AMBARI-17515. Hive View 2.0.0 Instance - Query is not returning result. (dipayanb)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/74a2afd2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/74a2afd2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/74a2afd2

Branch: refs/heads/trunk
Commit: 74a2afd2f383da8905a147e6992c1d1042a75fed
Parents: d2a0080
Author: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Authored: Fri Jul 1 13:05:35 2016 +0530
Committer: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Committed: Mon Jul 4 11:48:31 2016 +0530

----------------------------------------------------------------------
 .../ambari/view/hive2/ConnectionSystem.java      | 19 +++++++++++--------
 .../apache/ambari/view/hive2/HiveViewImpl.java   |  2 ++
 .../view/hive2/internal/HdfsApiSupplier.java     | 12 ++++++++----
 .../src/main/resources/application.conf          |  2 +-
 4 files changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/74a2afd2/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionSystem.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionSystem.java
b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionSystem.java
index 860a49c..3b85459 100644
--- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionSystem.java
+++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/ConnectionSystem.java
@@ -20,9 +20,9 @@ package org.apache.ambari.view.hive2;
 
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
+import akka.actor.Inbox;
+import akka.actor.PoisonPill;
 import akka.actor.Props;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
 import org.apache.ambari.view.ViewContext;
 import org.apache.ambari.view.hive2.actor.DeathWatch;
 import org.apache.ambari.view.hive2.actor.OperationController;
@@ -30,21 +30,16 @@ import org.apache.ambari.view.hive2.internal.ConnectionSupplier;
 import org.apache.ambari.view.hive2.internal.DataStorageSupplier;
 import org.apache.ambari.view.hive2.internal.HdfsApiSupplier;
 
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 
 public class ConnectionSystem {
 
-  private static final String ACTOR_CONF_FILE = "application.conf";
   private static final String ACTOR_SYSTEM_NAME = "HiveViewActorSystem";
   private ActorSystem actorSystem = null;
   private static volatile ConnectionSystem instance = null;
   private static final Object lock = new Object();
-  private static Map<String, ActorRef> operationControllerMap = new HashMap<>();
+  private static Map<String, ActorRef> operationControllerMap = new ConcurrentHashMap<>();
 
   private ConnectionSystem() {
     this.actorSystem = ActorSystem.create(ACTOR_SYSTEM_NAME);
@@ -94,6 +89,14 @@ public class ConnectionSystem {
     return ref;
   }
 
+  public void removeOperationControllerFromCache(String viewInstanceName) {
+    ActorRef ref = operationControllerMap.remove(viewInstanceName);
+    if (ref != null) {
+      Inbox inbox = Inbox.create(getActorSystem());
+      inbox.send(ref, PoisonPill.getInstance());
+    }
+  }
+
   public void shutdown() {
     if (!actorSystem.isTerminated()) {
       actorSystem.shutdown();

http://git-wip-us.apache.org/repos/asf/ambari/blob/74a2afd2/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/HiveViewImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/HiveViewImpl.java
b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/HiveViewImpl.java
index 695c0ab..ca8202e 100644
--- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/HiveViewImpl.java
+++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/HiveViewImpl.java
@@ -39,6 +39,7 @@ public class HiveViewImpl implements View {
   @Override
   public void onDestroy(ViewInstanceDefinition definition) {
     SharedObjectsFactory.dropInstanceCache(definition.getInstanceName());
+    ConnectionSystem.getInstance().removeOperationControllerFromCache(definition.getInstanceName());
   }
 
   @Override
@@ -46,5 +47,6 @@ public class HiveViewImpl implements View {
     //drop all cached connection for instance
     UserLocal.dropInstanceCache(definition.getInstanceName());
     SharedObjectsFactory.dropInstanceCache(definition.getInstanceName());
+    ConnectionSystem.getInstance().removeOperationControllerFromCache(definition.getInstanceName());
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/74a2afd2/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/internal/HdfsApiSupplier.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/internal/HdfsApiSupplier.java
b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/internal/HdfsApiSupplier.java
index 25df8ce..1cc1211 100644
--- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/internal/HdfsApiSupplier.java
+++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/internal/HdfsApiSupplier.java
@@ -40,20 +40,24 @@ public class HdfsApiSupplier implements ContextSupplier<Optional<HdfsApi>>
{
   @Override
   public Optional<HdfsApi> get(ViewContext context) {
     try {
-      if(!hdfsApiMap.containsKey(context.getInstanceName())) {
+      if(!hdfsApiMap.containsKey(getKey(context))) {
         synchronized (lock) {
-          if(!hdfsApiMap.containsKey(context.getInstanceName())) {
+          if(!hdfsApiMap.containsKey(getKey(context))) {
             LOG.debug("Creating HDFSApi instance for Viewname: {}, Instance Name: {}", context.getViewName(),
context.getInstanceName());
             HdfsApi api = HdfsUtil.connectToHDFSApi(context);
-            hdfsApiMap.put(context.getInstanceName(), api);
+            hdfsApiMap.put(getKey(context), api);
             return Optional.of(api);
           }
         }
       }
-      return Optional.of(hdfsApiMap.get(context.getInstanceName()));
+      return Optional.of(hdfsApiMap.get(getKey(context)));
     } catch (HdfsApiException e) {
       LOG.error("Cannot get the HDFS API", e);
       return Optional.absent();
     }
   }
+
+  private String getKey(ViewContext context) {
+    return context.getUsername() + ":" + context.getInstanceName();
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/74a2afd2/contrib/views/hive-next/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/resources/application.conf b/contrib/views/hive-next/src/main/resources/application.conf
index cb0cc7b..fd65430 100644
--- a/contrib/views/hive-next/src/main/resources/application.conf
+++ b/contrib/views/hive-next/src/main/resources/application.conf
@@ -28,7 +28,7 @@ akka {
   # Log level for the very basic logger activated during ActorSystem startup.
   # This logger prints the log messages to stdout (System.out).
   # Options: OFF, ERROR, WARNING, INFO, DEBUG
-  stdout-loglevel = "INFO"
+  stdout-loglevel = "WARN"
 
   actor {
 


Mime
View raw message