ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject git commit: AMBARI-7806 - Views: Instance Data Storage doesn't work
Date Thu, 16 Oct 2014 13:51:39 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 9ab8371a4 -> 6c0d5097e


AMBARI-7806 - Views: Instance Data Storage doesn't work


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

Branch: refs/heads/branch-1.7.0
Commit: 6c0d5097e3b11afb63abb334a895cb979e38cdad
Parents: 9ab8371
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Thu Oct 16 09:50:49 2014 -0400
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Thu Oct 16 09:51:11 2014 -0400

----------------------------------------------------------------------
 .../org/apache/ambari/server/view/ViewRegistry.java | 16 ++--------------
 .../apache/ambari/server/view/ViewRegistryTest.java | 11 ++++++++++-
 2 files changed, 12 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6c0d5097/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 cf15ef1..f2173ac 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
@@ -1097,11 +1097,6 @@ public class ViewRegistry {
       persistedView = viewDAO.merge(view);
     }
 
-    Map<String, ViewInstanceEntity> xmlInstanceEntityMap = new HashMap<String, ViewInstanceEntity>();
-    for( ViewInstanceEntity instance : view.getInstances()) {
-      xmlInstanceEntityMap.put(instance.getName(), instance);
-    }
-
     view.setResourceType(persistedView.getResourceType());
     view.setPermissions(persistedView.getPermissions());
 
@@ -1111,8 +1106,6 @@ public class ViewRegistry {
       String             instanceName = persistedInstance.getName();
       ViewInstanceEntity instance     = view.getInstanceDefinition(instanceName);
 
-      xmlInstanceEntityMap.remove(instanceName);
-
       // if the persisted instance is not in the view ...
       if (instance == null) {
         if (persistedInstance.isXmlDriven()) {
@@ -1128,15 +1121,10 @@ public class ViewRegistry {
         }
       } else {
         instance.setResource(persistedInstance.getResource());
+        instance.setViewInstanceId(persistedInstance.getViewInstanceId());
+        instance.setData(persistedInstance.getData());
       }
     }
-
-    // these instances appear in the view.xml but are not present in the db...
-    // add them to db
-    for (ViewInstanceEntity instance : xmlInstanceEntityMap.values()) {
-      instance.setResource(createViewInstanceResource(resourceType));
-      instanceDAO.merge(instance);
-    }
   }
 
   // create an admin resource to represent a view instance

http://git-wip-us.apache.org/repos/asf/ambari/blob/6c0d5097/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 071f5af..1bd47f3 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
@@ -205,6 +205,10 @@ public class ViewRegistryTest {
     viewDefinition.setResourceType(resourceTypeEntity);
 
     Set<ViewInstanceEntity> viewInstanceEntities = ViewInstanceEntityTest.getViewInstanceEntities(viewDefinition);
+
+    for (ViewInstanceEntity viewInstanceEntity : viewInstanceEntities) {
+      viewInstanceEntity.putInstanceData("p1", "v1");
+    }
     viewDefinition.setInstances(viewInstanceEntities);
 
     Map<File, ViewConfig> viewConfigs =
@@ -308,7 +312,12 @@ public class ViewRegistryTest {
     Assert.assertNotNull(view);
     Assert.assertEquals(ViewDefinition.ViewStatus.DEPLOYED, view.getStatus());
 
-    Assert.assertEquals(2, registry.getInstanceDefinitions(view).size());
+    Collection<ViewInstanceEntity> instanceDefinitions = registry.getInstanceDefinitions(view);
+    Assert.assertEquals(2, instanceDefinitions.size());
+
+    for (ViewInstanceEntity viewInstanceEntity : instanceDefinitions) {
+      Assert.assertEquals("v1", viewInstanceEntity.getInstanceData("p1").getValue());
+    }
 
     // verify mocks
     verify(configuration, viewDir, extractedArchiveDir, viewArchive, archiveDir, entryFile,
classesDir,


Mime
View raw message