ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [19/50] [abbrv] ambari git commit: AMBARI-15034. Add checks and alerts when clusterconfigmapping has multiple selected entries for a config type.(vbrodetskyi)
Date Tue, 16 Feb 2016 18:30:24 GMT
AMBARI-15034. Add checks and alerts when clusterconfigmapping has multiple selected entries
for a config type.(vbrodetskyi)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 604040fbf71654c2218baef970c27d71b5f449c1
Parents: 350e9b3
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Fri Feb 12 08:06:01 2016 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Fri Feb 12 08:06:01 2016 +0200

----------------------------------------------------------------------
 .../ambari/server/checks/CheckDatabaseHelper.java | 18 +++++++++---------
 .../server/checks/CheckDatabaseHelperTest.java    |  5 ++++-
 2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/604040fb/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
index a078c8a..9213738 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
@@ -152,19 +152,23 @@ public class CheckDatabaseHelper {
   * than one selected version it's a bug and we are showing error message for user.
   * */
   protected void checkForConfigsSelectedMoreThanOnce() {
-    String GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY = "select type_name from clusterconfigmapping
group by type_name having sum(selected) > 1";
-    Set<String> configsSelectedMoreThanOnce = new HashSet<>();
+    String GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY = "select c.cluster_name,type_name from
clusterconfigmapping ccm " +
+            "join clusters c on ccm.cluster_id=c.cluster_id " +
+            "group by c.cluster_name,type_name " +
+            "having sum(selected) > 1";
+    Multimap<String, String> configsSelectedMoreThanOnce = HashMultimap.create();
     ResultSet rs = null;
     try {
       Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
       rs = statement.executeQuery(GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY);
       if (rs != null) {
         while (rs.next()) {
-          configsSelectedMoreThanOnce.add(rs.getString("type_name"));
+          configsSelectedMoreThanOnce.put(rs.getString("cluster_name"), rs.getString("type_name"));
         }
       }
-      if (!configsSelectedMoreThanOnce.isEmpty()) {
-        LOG.error("You have config(s) that is(are) selected more than once in clusterconfigmapping:
" + StringUtils.join(configsSelectedMoreThanOnce, ","));
+      for (String clusterName : configsSelectedMoreThanOnce.keySet()) {
+        LOG.error(String.format("You have config(s), in cluster %s, that is(are) selected
more than once in clusterconfigmapping: %s",
+                clusterName ,StringUtils.join(configsSelectedMoreThanOnce.get(clusterName),
",")));
       }
     } catch (SQLException e) {
       LOG.error("Exception occurred during check for config selected more than ones procedure:
", e);
@@ -193,10 +197,6 @@ public class CheckDatabaseHelper {
       rs = statement.executeQuery(GET_HOSTS_WITHOUT_STATUS_QUERY);
       if (rs != null) {
         while (rs.next()) {
-          LOG.error(rs.getString("host_name"));
-          LOG.error(rs.getString("HOST_NAME"));
-          System.out.println("ERROR" + rs.getString("HOST_NAME"));
-          System.out.println("ERROR" + rs.getString("host_name"));
           hostsWithoutStatus.add(rs.getString("host_name"));
         }
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/604040fb/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
index e329ab7..1c2765c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
@@ -111,7 +111,10 @@ public class CheckDatabaseHelperTest {
 
     expect(mockDBDbAccessor.getConnection()).andReturn(mockConnection);
     expect(mockConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)).andReturn(mockStatement);
-    expect(mockStatement.executeQuery("select type_name from clusterconfigmapping group by
type_name having sum(selected) > 1")).andReturn(mockResultSet);
+    expect(mockStatement.executeQuery("select c.cluster_name,type_name from clusterconfigmapping
ccm " +
+            "join clusters c on ccm.cluster_id=c.cluster_id " +
+            "group by c.cluster_name,type_name " +
+            "having sum(selected) > 1")).andReturn(mockResultSet);
 
     CheckDatabaseHelper checkDatabaseHelper = new CheckDatabaseHelper(mockDBDbAccessor, mockInjector,
null);
 


Mime
View raw message