Repository: ambari
Updated Branches:
  refs/heads/trunk 76ee1b114 -> 1fdda4913


AMBARI-18387. Unable to delete Hive view. (dipayanb)


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

Branch: refs/heads/trunk
Commit: 1fdda4913adb2318ddfc1406d39fe8d80837a37e
Parents: 76ee1b1
Author: Dipayan Bhowmick <dipayan.bhowm...@gmail.com>
Authored: Wed Sep 14 15:36:56 2016 +0530
Committer: Dipayan Bhowmick <dipayan.bhowm...@gmail.com>
Committed: Mon Sep 19 11:23:12 2016 +0530

----------------------------------------------------------------------
 .../ambari/view/hive2/ConnectionSystem.java     | 23 ++++++++++++--------
 1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1fdda491/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 f534130..88ea3d7 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
@@ -24,6 +24,8 @@ import akka.actor.Inbox;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import com.google.common.collect.Multimap;
+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;
@@ -45,8 +47,9 @@ public class ConnectionSystem {
   private static Map<String, Map<String, ActorRef>> operationControllerMap = 
new ConcurrentHashMap<>();
 
   private ConnectionSystem() {
-    this.actorSystem = ActorSystem.create(ACTOR_SYSTEM_NAME);
-    ;
+    ClassLoader classLoader = getClass().getClassLoader();
+    Config config = ConfigFactory.load(classLoader);
+    this.actorSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, config, 
classLoader);
   }
 
   public static ConnectionSystem getInstance() {
@@ -63,8 +66,8 @@ public class ConnectionSystem {
   private ActorRef createOperationController(ViewContext context) {
     ActorRef deathWatch = actorSystem.actorOf(Props.create(DeathWatch.class));
     return actorSystem.actorOf(
-      Props.create(OperationController.class, actorSystem, deathWatch, context,
-        new ConnectionSupplier(), new DataStorageSupplier(), new 
HdfsApiSupplier()));
+        Props.create(OperationController.class, actorSystem, deathWatch, 
context,
+            new ConnectionSupplier(), new DataStorageSupplier(), new 
HdfsApiSupplier()));
   }
 
   public ActorSystem getActorSystem() {
@@ -82,12 +85,12 @@ public class ConnectionSystem {
     String instanceName = context.getInstanceName();
     ActorRef ref = null;
     Map<String, ActorRef> stringActorRefMap = 
operationControllerMap.get(instanceName);
-    if(stringActorRefMap != null) {
+    if (stringActorRefMap != null) {
       ref = stringActorRefMap.get(context.getUsername());
     }
     if (ref == null) {
       ref = createOperationController(context);
-      if(stringActorRefMap == null) {
+      if (stringActorRefMap == null) {
         stringActorRefMap = new HashMap<>();
         stringActorRefMap.put(context.getUsername(), ref);
         operationControllerMap.put(instanceName, stringActorRefMap);
@@ -100,9 +103,11 @@ public class ConnectionSystem {
 
   public void removeOperationControllerFromCache(String viewInstanceName) {
     Map<String, ActorRef> refs = 
operationControllerMap.remove(viewInstanceName);
-    for (ActorRef ref : refs.values()) {
-      Inbox inbox = Inbox.create(getActorSystem());
-      inbox.send(ref, PoisonPill.getInstance());
+    if (refs != null) {
+      for (ActorRef ref : refs.values()) {
+        Inbox inbox = Inbox.create(getActorSystem());
+        inbox.send(ref, PoisonPill.getInstance());
+      }
     }
   }
 

Reply via email to