ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [1/2] ambari git commit: AMBARI-13358. Ambari throwing ganglia errors after upgrade (aonishuk)
Date Fri, 09 Oct 2015 11:53:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 40242bcfa -> 811d2316e
  refs/heads/trunk 800e42597 -> 9ea0ffd0f


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/9ea0ffd0
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9ea0ffd0
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9ea0ffd0

Branch: refs/heads/trunk
Commit: 9ea0ffd0f41f510d683da7da9e3fb32605f15033
Parents: 800e425
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Fri Oct 9 14:52:37 2015 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Fri Oct 9 14:52:37 2015 +0300

----------------------------------------------------------------------
 .../ambari/server/orm/dao/ClusterDAO.java       | 14 ++++++++++++++
 .../apache/ambari/server/state/ServiceImpl.java | 20 +++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9ea0ffd0/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 609d0de..1523f3a 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
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.orm.dao;
 
+import java.util.Collections;
 import java.util.List;
 
 import javax.persistence.EntityManager;
@@ -127,6 +128,19 @@ 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

http://git-wip-us.apache.org/repos/asf/ambari/blob/9ea0ffd0/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 9a91e4c..1d3f051 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
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.state;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,6 +38,8 @@ import org.apache.ambari.server.orm.dao.ClusterServiceDAO;
 import org.apache.ambari.server.orm.dao.ServiceConfigDAO;
 import org.apache.ambari.server.orm.dao.ServiceDesiredStateDAO;
 import org.apache.ambari.server.orm.dao.StackDAO;
+import org.apache.ambari.server.orm.entities.ClusterConfigEntity;
+import org.apache.ambari.server.orm.entities.ClusterConfigMappingEntity;
 import org.apache.ambari.server.orm.entities.ClusterEntity;
 import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
 import org.apache.ambari.server.orm.entities.ClusterServiceEntityPK;
@@ -551,10 +554,25 @@ public class ServiceImpl implements Service {
     
     List<ServiceConfigEntity> serviceConfigEntities = serviceConfigDAO.findByService(cluster.getClusterId(),
getName());
 
+    Long maxServiceConfigEntityId = -1L;
+    ServiceConfigEntity lastServiceConfigEntity = null; // last service config by id, should
have all needed clusterConfigEntities
+    
     for (ServiceConfigEntity serviceConfigEntity : serviceConfigEntities) {
+      if(serviceConfigEntity.getServiceConfigId() > maxServiceConfigEntityId) {
+        maxServiceConfigEntityId = serviceConfigEntity.getServiceConfigId();
+        lastServiceConfigEntity = serviceConfigEntity;
+      }
       serviceConfigDAO.remove(serviceConfigEntity);
     }
-
+    
+    if(lastServiceConfigEntity != null) {
+      for(ClusterConfigEntity clusterConfigEntity:lastServiceConfigEntity.getClusterConfigEntities())
{
+        List<ClusterConfigMappingEntity> clusterConfigMappingEntities = clusterDAO.findClusterConfigMappingEntitiesByType(cluster.getClusterId()
,clusterConfigEntity.getType());
+        for(ClusterConfigMappingEntity clusterConfigMappingEntity:clusterConfigMappingEntities)
{
+          clusterDAO.removeConfigMapping(clusterConfigMappingEntity);
+        }
+      }
+    }
   }
   
   @Override


Mime
View raw message