ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject ambari git commit: AMBARI-20805. Autofix db leads to dangling entries in ClusterConfigMapping table (dlysnichenko)
Date Fri, 21 Apr 2017 15:03:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 712b3d21c -> 23f8b85b8


AMBARI-20805. Autofix db leads to dangling entries in ClusterConfigMapping table (dlysnichenko)


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

Branch: refs/heads/branch-2.5
Commit: 23f8b85b8b6175b57086f2ec20f614ed40ba4274
Parents: 712b3d2
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Fri Apr 21 18:02:47 2017 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Fri Apr 21 18:02:47 2017 +0300

----------------------------------------------------------------------
 .../checks/DatabaseConsistencyCheckHelper.java       |  9 +++------
 .../org/apache/ambari/server/orm/dao/ClusterDAO.java | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/23f8b85b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
index 4cdeecb..c33c4e3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
@@ -527,12 +527,9 @@ public class DatabaseConsistencyCheckHelper {
     List<ClusterConfigEntity> notMappedClusterConfigs = getNotMappedClusterConfigsToService();
 
     for (ClusterConfigEntity clusterConfigEntity : notMappedClusterConfigs){
-      List<String> types = new ArrayList<>();
-      String type = clusterConfigEntity.getType();
-      types.add(type);
-      LOG.error("Removing cluster config mapping of type {} that is not mapped to any service",
type);
-      clusterDAO.removeClusterConfigMappingEntityByTypes(clusterConfigEntity.getClusterId(),types);
-      LOG.error("Removing config that is not mapped to any service", clusterConfigEntity);
+      LOG.info("Removing cluster config mapping of clusterConfigEntity {} that is not mapped
to any service", clusterConfigEntity);
+      clusterDAO.removeClusterConfigMappingEntityByConfig(clusterConfigEntity);
+      LOG.info("Removing config that is not mapped to any service {}", clusterConfigEntity);
       clusterDAO.removeConfig(clusterConfigEntity);
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/23f8b85b/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 b727c72..b21aeff 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
@@ -364,6 +364,21 @@ public class ClusterDAO {
       daoUtils.executeUpdate(query, clusterId, types);
     }
 
+  /**
+   * Delete ClusterConfigMappingEntity corresponds to clusterConfigEntity
+   *
+   * @param clusterConfigEntity
+   *          clusterConfigEntity to match.
+   */
+  @Transactional
+  public void removeClusterConfigMappingEntityByConfig(ClusterConfigEntity clusterConfigEntity)
{
+
+    TypedQuery<Long> query = entityManagerProvider.get().createQuery
+        ("DELETE FROM ClusterConfigMappingEntity configs WHERE configs" +
+            ".clusterId=?1 AND configs.typeName= ?2 AND configs.tag=?3 ", Long.class);
+
+    daoUtils.executeUpdate(query, clusterConfigEntity.getClusterId(), clusterConfigEntity.getType(),
clusterConfigEntity.getTag());
+  }
 
   /**
    * Retrieve entity data from DB


Mime
View raw message