ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject ambari git commit: AMBARI-13358. Ambari throwing ganglia errors after upgrade (aonishuk)
Date Fri, 09 Oct 2015 12:22:30 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9ea0ffd0f -> a64c46971


AMBARI-13358. Ambari throwing ganglia errors after upgrade (aonishuk)


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

Branch: refs/heads/trunk
Commit: a64c469718a5395e9adfdabf46fe15b7040adf89
Parents: 9ea0ffd
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Fri Oct 9 15:21:38 2015 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Fri Oct 9 15:21:38 2015 +0300

----------------------------------------------------------------------
 .../ambari/server/orm/dao/ClusterDAO.java       | 36 +++++++++++++-------
 .../apache/ambari/server/state/ServiceImpl.java |  7 ++--
 2 files changed, 26 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a64c4697/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
index 1523f3a..b79d5e3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
@@ -128,19 +128,6 @@ public class ClusterDAO {
     TypedQuery<ClusterConfigEntity> query = entityManagerProvider.get().createQuery(cq);
     return daoUtils.selectOne(query);
   }
-  
-  @RequiresSession
-  public List<ClusterConfigMappingEntity> findClusterConfigMappingEntitiesByType(Long
clusterId, String type) {
-    CriteriaBuilder cb = entityManagerProvider.get().getCriteriaBuilder();
-    CriteriaQuery<ClusterConfigMappingEntity> cq = cb.createQuery(ClusterConfigMappingEntity.class);
-    Root<ClusterConfigMappingEntity> config = cq.from(ClusterConfigMappingEntity.class);
-    cq.where(cb.and(
-        cb.equal(config.get("clusterId"), clusterId)),
-      cb.equal(config.get("typeName"), type)
-    );
-    TypedQuery<ClusterConfigMappingEntity> query = entityManagerProvider.get().createQuery(cq);
-    return daoUtils.selectList(query);
-  }
 
   /**
    * Gets the next version that will be created for a given
@@ -274,6 +261,29 @@ public class ClusterDAO {
   public void removeConfigMapping(ClusterConfigMappingEntity entity) {
     entityManagerProvider.get().remove(entity);
   }
+  
+  
+  /**
+   * Sets selected = 0, for clusterConfigEntities which has type_name which is in the given
types list
+   * 
+   * @param clusterId
+   *          the cluster that the service is a part of.
+   * @param types
+   *          the names of the configuration types.
+   */
+    @Transactional
+    public void removeClusterConfigMappingEntityByTypes(Long clusterId, List<String>
types) {
+      if(types.isEmpty()) {
+        return;
+      }
+      
+      TypedQuery<Long> query = entityManagerProvider.get().createQuery
+          ("DELETE FROM ClusterConfigMappingEntity configs WHERE configs" +
+            ".clusterId=?1 AND configs.typeName IN ?2", Long.class);
+
+      daoUtils.executeUpdate(query, clusterId, types);
+    }
+
 
   /**
    * Retrieve entity data from DB

http://git-wip-us.apache.org/repos/asf/ambari/blob/a64c4697/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
index 1d3f051..9d5fa85 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
@@ -566,12 +566,11 @@ public class ServiceImpl implements Service {
     }
     
     if(lastServiceConfigEntity != null) {
+      List<String> configTypesToDisable = new ArrayList<String>();
       for(ClusterConfigEntity clusterConfigEntity:lastServiceConfigEntity.getClusterConfigEntities())
{
-        List<ClusterConfigMappingEntity> clusterConfigMappingEntities = clusterDAO.findClusterConfigMappingEntitiesByType(cluster.getClusterId()
,clusterConfigEntity.getType());
-        for(ClusterConfigMappingEntity clusterConfigMappingEntity:clusterConfigMappingEntities)
{
-          clusterDAO.removeConfigMapping(clusterConfigMappingEntity);
-        }
+        configTypesToDisable.add(clusterConfigEntity.getType());
       }
+      clusterDAO.removeClusterConfigMappingEntityByTypes(cluster.getClusterId(), configTypesToDisable);
     }
   }
   


Mime
View raw message