Updated Branches: refs/heads/trunk 11de6a5c6 -> 33092de45
AMBARI-4402. Delete Config Group Host mapping broken due to error introduced by perf patch. (swagle) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/33092de4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/33092de4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/33092de4 Branch: refs/heads/trunk Commit: 33092de45a23331b39e855fbcd0d6bbca48d6c99 Parents: cd25d7b Author: Siddharth Wagle <[email protected]> Authored: Thu Jan 23 09:59:05 2014 -0800 Committer: Siddharth Wagle <[email protected]> Committed: Thu Jan 23 10:00:07 2014 -0800 ---------------------------------------------------------------------- .../orm/dao/ConfigGroupHostMappingDAO.java | 36 +++++++------------- .../ambari/server/state/ConfigGroupTest.java | 1 - 2 files changed, 13 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/33092de4/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ConfigGroupHostMappingDAO.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ConfigGroupHostMappingDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ConfigGroupHostMappingDAO.java index f4ea328..8ff21b5 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ConfigGroupHostMappingDAO.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ConfigGroupHostMappingDAO.java @@ -105,29 +105,19 @@ public class ConfigGroupHostMappingDAO { } } - + + /** + * Return entity object which can be used for operations like remove + * directly. + * @param configGroupHostMappingEntityPK + * @return + */ @Transactional - public ConfigGroupHostMapping findByPK(final ConfigGroupHostMappingEntityPK + public ConfigGroupHostMappingEntity findByPK(final ConfigGroupHostMappingEntityPK configGroupHostMappingEntityPK) { - populateCache(); - - if (!configGroupHostMappingByHost.containsKey(configGroupHostMappingEntityPK.getHostname())) - return null; - - Set<ConfigGroupHostMapping> set = - new HashSet<ConfigGroupHostMapping>(configGroupHostMappingByHost.get(configGroupHostMappingEntityPK.getHostname())); - - ConfigGroupHostMapping itemByPk = (ConfigGroupHostMapping) CollectionUtils.find(set, new Predicate() { - - @Override - public boolean evaluate(Object arg0) { - return ((ConfigGroupHostMapping) arg0).getConfigGroupId(). - equals(configGroupHostMappingEntityPK.getConfigGroupId()); - } - }); - - return itemByPk; + return entityManagerProvider.get() + .find(ConfigGroupHostMappingEntity.class, configGroupHostMappingEntityPK); } @Transactional @@ -247,10 +237,10 @@ public class ConfigGroupHostMappingDAO { configGroupHostMappingEntityPK) { populateCache(); - entityManagerProvider.get().remove(findByPK - (configGroupHostMappingEntityPK)); + entityManagerProvider.get().remove(findByPK(configGroupHostMappingEntityPK)); - Set<ConfigGroupHostMapping> setByHost = configGroupHostMappingByHost.get(configGroupHostMappingEntityPK.getHostname()); + Set<ConfigGroupHostMapping> setByHost = configGroupHostMappingByHost + .get(configGroupHostMappingEntityPK.getHostname()); if (setByHost != null) { CollectionUtils.filter(setByHost, new Predicate() { http://git-wip-us.apache.org/repos/asf/ambari/blob/33092de4/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java index 96b9421..b67b78e 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java @@ -193,7 +193,6 @@ public class ConfigGroupTest { Assert.assertNull(cluster.getConfigGroups().get(id)); } - @Ignore @Test public void testRemoveHost() throws Exception { ConfigGroup configGroup = createConfigGroup();
