ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject git commit: AMBARI-7190 - Views: attempting to access views during extraction throws exception (reopened)
Date Tue, 16 Sep 2014 00:35:21 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 26cd2f4b0 -> a412da83c


AMBARI-7190 - Views: attempting to access views during extraction throws exception (reopened)


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

Branch: refs/heads/trunk
Commit: a412da83c531ab4c6b0034c4dc087c5b58dff74c
Parents: 26cd2f4
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Mon Sep 15 17:58:19 2014 -0400
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Mon Sep 15 20:34:54 2014 -0400

----------------------------------------------------------------------
 .../apache/ambari/server/view/ViewRegistry.java |  6 +++--
 .../ambari/server/view/ViewRegistryTest.java    | 23 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a412da83/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
index 17d77a6..8f6774e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
@@ -261,8 +261,10 @@ public class ViewRegistry {
   public ViewEntity getDefinition(ResourceTypeEntity resourceTypeEntity) {
 
     for (ViewEntity viewEntity : viewDefinitions.values()) {
-      if (viewEntity.getResourceType().equals(resourceTypeEntity)) {
-        return viewEntity;
+      if (viewEntity.isDeployed()) {
+        if (viewEntity.getResourceType().equals(resourceTypeEntity)) {
+          return viewEntity;
+        }
       }
     }
     return null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/a412da83/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
index 8e36dba..eba0c25 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
@@ -533,6 +533,29 @@ public class ViewRegistryTest {
   }
 
   @Test
+  public void testGetDefinition() throws Exception {
+    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
+
+    ViewRegistry registry = ViewRegistry.getInstance();
+
+    ResourceTypeEntity resourceTypeEntity = new ResourceTypeEntity();
+    resourceTypeEntity.setId(10);
+    resourceTypeEntity.setName(viewDefinition.getName());
+
+    viewDefinition.setResourceType(resourceTypeEntity);
+
+    registry.addDefinition(viewDefinition);
+
+    viewDefinition.setStatus(ViewDefinition.ViewStatus.DEPLOYING);
+
+    Assert.assertNull(registry.getDefinition(resourceTypeEntity));
+
+    viewDefinition.setStatus(ViewDefinition.ViewStatus.DEPLOYED);
+
+    Assert.assertEquals(viewDefinition, registry.getDefinition(resourceTypeEntity));
+  }
+
+  @Test
   public void testAddGetInstanceDefinitions() throws Exception {
     ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
     ViewInstanceEntity viewInstanceDefinition = ViewInstanceEntityTest.getViewInstanceEntity();


Mime
View raw message