ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [01/33] ambari git commit: AMBARI-15051. Improvements and fixes for database check.(vbrodetskyi)
Date Thu, 18 Feb 2016 13:33:20 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-dev-patch-upgrade e4d1475ea -> 418745d12


AMBARI-15051. Improvements and fixes for database check.(vbrodetskyi)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 4761fe7c40b10d4a5c1f7b2564df475c4a66222b
Parents: 0ea255c
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Mon Feb 15 14:51:36 2016 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Mon Feb 15 14:51:36 2016 +0200

----------------------------------------------------------------------
 ambari-server/conf/unix/log4j.properties        |   9 ++
 ambari-server/conf/windows/log4j.properties     |   9 ++
 ambari-server/src/main/conf/log4j.properties    |   9 ++
 .../server/checks/CheckDatabaseHelper.java      | 155 +++++++++++++------
 .../main/python/ambari_server/checkDatabase.py  |   7 +-
 .../server/checks/CheckDatabaseHelperTest.java  |  29 ++--
 .../src/test/python/TestAmbariServer.py         |   3 +-
 7 files changed, 152 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4761fe7c/ambari-server/conf/unix/log4j.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/log4j.properties b/ambari-server/conf/unix/log4j.properties
index c87b1f4..18ec33e 100644
--- a/ambari-server/conf/unix/log4j.properties
+++ b/ambari-server/conf/unix/log4j.properties
@@ -23,6 +23,7 @@ ambari.log.file=ambari-server.log
 ambari.config-changes.file=ambari-config-changes.log
 ambari.alerts.file=ambari-alerts.log
 ambari.eclipselink.file=ambari-eclipselink.log
+ambari.dbcheck.file=ambari-server-check-database.log
 
 log4j.rootLogger=INFO,file
 
@@ -50,6 +51,14 @@ log4j.appender.alerts.File=${ambari.log.dir}/${ambari.alerts.file}
 log4j.appender.alerts.layout=org.apache.log4j.PatternLayout
 log4j.appender.alerts.layout.ConversionPattern=%d{ISO8601} %m%n
 
+# Log database check process
+log4j.logger.org.apache.ambari.server.checks.CheckDatabaseHelper=INFO, dbcheck
+log4j.additivity.org.apache.ambari.server.checks.CheckDatabaseHelper=false
+log4j.appender.dbcheck=org.apache.log4j.FileAppender
+log4j.appender.dbcheck.File=${ambari.log.dir}/${ambari.dbcheck.file}
+log4j.appender.dbcheck.layout=org.apache.log4j.PatternLayout
+log4j.appender.dbcheck.layout.ConversionPattern=%d{ISO8601} %m%n
+
 # EclipsLink -> slf4j bridge
 log4j.logger.eclipselink=TRACE,eclipselink
 log4j.additivity.eclipselink=false

http://git-wip-us.apache.org/repos/asf/ambari/blob/4761fe7c/ambari-server/conf/windows/log4j.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/windows/log4j.properties b/ambari-server/conf/windows/log4j.properties
index 8a69508..09505cf 100644
--- a/ambari-server/conf/windows/log4j.properties
+++ b/ambari-server/conf/windows/log4j.properties
@@ -23,6 +23,7 @@ ambari.log.file=ambari-server.log
 ambari.config-changes.file=ambari-config-changes.log
 ambari.alerts.file=ambari-alerts.log
 ambari.eclipselink.file=ambari-eclipselink.log
+ambari.dbcheck.file=ambari-server-check-database.log
 
 # Define the root logger to the system property "ambari.root.logger".
 log4j.rootLogger=${ambari.root.logger}
@@ -76,6 +77,14 @@ log4j.appender.alerts.File=${ambari.log.dir}\${ambari.alerts.file}
 log4j.appender.alerts.layout=org.apache.log4j.PatternLayout
 log4j.appender.alerts.layout.ConversionPattern=%d{ISO8601} %m%n
 
+# Log database check process
+log4j.logger.org.apache.ambari.server.checks.CheckDatabaseHelper=INFO, dbcheck
+log4j.additivity.org.apache.ambari.server.checks.CheckDatabaseHelper=false
+log4j.appender.dbcheck=org.apache.log4j.FileAppender
+log4j.appender.dbcheck.File=${ambari.log.dir}/${ambari.dbcheck.file}
+log4j.appender.dbcheck.layout=org.apache.log4j.PatternLayout
+log4j.appender.dbcheck.layout.ConversionPattern=%d{ISO8601} %m%n
+
 # EclipsLink -> slf4j bridge
 log4j.logger.eclipselink=TRACE,eclipselink
 log4j.additivity.eclipselink=false

http://git-wip-us.apache.org/repos/asf/ambari/blob/4761fe7c/ambari-server/src/main/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/conf/log4j.properties b/ambari-server/src/main/conf/log4j.properties
index 11e8d51..1211fe3 100644
--- a/ambari-server/src/main/conf/log4j.properties
+++ b/ambari-server/src/main/conf/log4j.properties
@@ -23,6 +23,7 @@ ambari.log.file=ambari-server.log
 ambari.config-changes.file=ambari-config-changes.log
 ambari.alerts.file=ambari-alerts.log
 ambari.eclipselink.file=ambari-eclipselink.log
+ambari.dbcheck.file=ambari-server-check-database.log
 
 # Define the root logger to the system property "ambari.root.logger".
 log4j.rootLogger=${ambari.root.logger}
@@ -76,6 +77,14 @@ log4j.appender.alerts.File=${ambari.log.dir}/${ambari.alerts.file}
 log4j.appender.alerts.layout=org.apache.log4j.PatternLayout
 log4j.appender.alerts.layout.ConversionPattern=%d{ISO8601} %m%n
 
+# Log database check process
+log4j.logger.org.apache.ambari.server.checks.CheckDatabaseHelper=INFO, dbcheck
+log4j.additivity.org.apache.ambari.server.checks.CheckDatabaseHelper=false
+log4j.appender.dbcheck=org.apache.log4j.FileAppender
+log4j.appender.dbcheck.File=${ambari.log.dir}/${ambari.dbcheck.file}
+log4j.appender.dbcheck.layout=org.apache.log4j.PatternLayout
+log4j.appender.dbcheck.layout.ConversionPattern=%d{ISO8601} %m%n
+
 # EclipsLink -> slf4j bridge
 log4j.logger.eclipselink=TRACE,eclipselink
 log4j.additivity.eclipselink=false

http://git-wip-us.apache.org/repos/asf/ambari/blob/4761fe7c/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 9213738..0396767 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
@@ -37,11 +37,9 @@ import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -60,6 +58,7 @@ public class CheckDatabaseHelper {
   private Connection connection;
   private AmbariMetaInfo ambariMetaInfo;
   private Injector injector;
+  private boolean errorAvailable = false;
 
   @Inject
   public CheckDatabaseHelper(DBAccessor dbAccessor,
@@ -112,6 +111,14 @@ public class CheckDatabaseHelper {
     persistService.stop();
   }
 
+  protected boolean isErrorAvailable() {
+    return errorAvailable;
+  }
+
+  protected void setErrorAvailable(boolean errorAvailable) {
+    this.errorAvailable = errorAvailable;
+  }
+
   /*
   * This method checks if all configurations that we have in clusterconfig table
   * have at least one mapping in clusterconfigmapping table. If we found not mapped config
@@ -169,6 +176,7 @@ public class CheckDatabaseHelper {
       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),
",")));
+        errorAvailable = true;
       }
     } catch (SQLException e) {
       LOG.error("Exception occurred during check for config selected more than ones procedure:
", e);
@@ -203,6 +211,7 @@ public class CheckDatabaseHelper {
 
       if (!hostsWithoutStatus.isEmpty()) {
         LOG.error("You have host(s) without status: " + StringUtils.join(hostsWithoutStatus,
","));
+        errorAvailable = true;
       }
     } catch (SQLException e) {
       LOG.error("Exception occurred during check for host without state procedure: ", e);
@@ -257,7 +266,8 @@ public class CheckDatabaseHelper {
       }
 
       if (hostComponentStateCount != hostComponentDesiredStateCount || hostComponentStateCount
!= mergedCount) {
-        LOG.error("Your host component state count not equals host component desired state
count!");
+        LOG.error("Your host component states(hostcomponentstate table) count not equals
host component desired states(hostcomponentdesiredstate table) count!");
+        errorAvailable = true;
       }
 
     } catch (SQLException e) {
@@ -284,27 +294,32 @@ public class CheckDatabaseHelper {
   * If any issue was discovered, we are showing error message for user.
   * */
   protected void checkServiceConfigs()  {
-    String GET_SERVICES_WITHOUT_CONFIGS_QUERY = "select service_name from clusterservices
where service_name not in (select service_name from serviceconfig where group_id is null)";
+    String GET_SERVICES_WITHOUT_CONFIGS_QUERY = "select c.cluster_name, service_name from
clusterservices cs " +
+            "join clusters c on cs.cluster_id=c.cluster_id " +
+            "where service_name not in (select service_name from serviceconfig sc where sc.cluster_id=cs.cluster_id
and sc.service_name=cs.service_name and sc.group_id is null)";
     String GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY = "select service_name from serviceconfig
where service_config_id not in (select service_config_id from serviceconfigmapping) and group_id
is null";
-    String GET_STACK_NAME_VERSION_QUERY = "select s.stack_name, s.stack_version from clusters
c join stack s on c.desired_stack_id = s.stack_id";
-    String GET_SERVICES_WITH_CONFIGS_QUERY = "select cs.service_name, type_name, sc.version
from clusterservices cs " +
-            "join serviceconfig sc on cs.service_name=sc.service_name " +
+    String GET_STACK_NAME_VERSION_QUERY = "select c.cluster_name, s.stack_name, s.stack_version
from clusters c " +
+            "join stack s on c.desired_stack_id = s.stack_id";
+    String GET_SERVICES_WITH_CONFIGS_QUERY = "select c.cluster_name, cs.service_name, type_name,
sc.version from clusterservices cs " +
+            "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id
" +
             "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id
" +
-            "join clusterconfig cc on scm.config_id=cc.config_id " +
+            "join clusterconfig cc on scm.config_id=cc.config_id and sc.cluster_id=cc.cluster_id
" +
+            "join clusters c on cc.cluster_id=c.cluster_id " +
             "where sc.group_id is null " +
-            "group by cs.service_name, type_name, sc.version";
-    String GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY = "select cs.service_name,cc.type_name
from clusterservices cs " +
-            "join serviceconfig sc on cs.service_name=sc.service_name " +
+            "group by c.cluster_name, cs.service_name, type_name, sc.version";
+    String GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY = "select c.cluster_name, cs.service_name,cc.type_name
from clusterservices cs " +
+            "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id
" +
             "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id
" +
-            "join clusterconfig cc on scm.config_id=cc.config_id " +
-            "join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag
" +
-            "where sc.group_id is null and sc.service_config_id = (select max(service_config_id)
from serviceconfig sc2 where sc2.service_name=sc.service_name) " +
-            "group by cs.service_name,cc.type_name " +
+            "join clusterconfig cc on scm.config_id=cc.config_id and cc.cluster_id=sc.cluster_id
" +
+            "join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag
and cc.cluster_id=ccm.cluster_id " +
+            "join clusters c on ccm.cluster_id=c.cluster_id " +
+            "where sc.group_id is null and sc.service_config_id = (select max(service_config_id)
from serviceconfig sc2 where sc2.service_name=sc.service_name and sc2.cluster_id=sc.cluster_id)
" +
+            "group by c.cluster_name,cs.service_name,cc.type_name " +
             "having sum(ccm.selected) < 1";
-    String stackName = null, stackVersion = null;
-    Set<String> servicesWithoutConfigs = new HashSet<>();
+    Multimap<String, String> servicesWithoutConfigs = HashMultimap.create();
+    Map<String, Map<String, String>>  clusterStackInfo = new HashMap<>();
     Set<String> servicesWithoutMappedConfigs = new HashSet<>();
-    Map<String, List<String>> notSelectedServiceConfigs = new HashMap<>();
+    Map<String, Multimap<String, String>> notSelectedServiceConfigs = new HashMap<>();
     ResultSet rs = null;
 
     try {
@@ -313,12 +328,13 @@ public class CheckDatabaseHelper {
       rs = statement.executeQuery(GET_SERVICES_WITHOUT_CONFIGS_QUERY);
       if (rs != null) {
         while (rs.next()) {
-          servicesWithoutConfigs.add(rs.getString("service_name"));
+          servicesWithoutConfigs.put(rs.getString("cluster_name"), rs.getString("service_name"));
         }
       }
 
-      if (!servicesWithoutConfigs.isEmpty()) {
-        LOG.error("You have services without configs at all: " + StringUtils.join(servicesWithoutConfigs,
","));
+      for (String clusterName : servicesWithoutConfigs.keySet()) {
+        LOG.error(String.format("Service(s): %s, from cluster %s has no config(s) in serviceconfig
table!", StringUtils.join(servicesWithoutConfigs.get(clusterName), ","), clusterName));
+        errorAvailable = true;
       }
 
       rs = statement.executeQuery(GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY);
@@ -329,44 +345,63 @@ public class CheckDatabaseHelper {
       }
 
       if (!servicesWithoutMappedConfigs.isEmpty()) {
-        LOG.error("You have services without mapped configs: " + StringUtils.join(servicesWithoutMappedConfigs,
","));
+        LOG.error("You have service(s) without mapped configs in serviceconfigmapping: "
+ StringUtils.join(servicesWithoutMappedConfigs, ","));
+        errorAvailable = true;
       }
 
       rs = statement.executeQuery(GET_STACK_NAME_VERSION_QUERY);
       if (rs != null) {
         while (rs.next()) {
-          stackName = rs.getString("stack_name");
-          stackVersion = rs.getString("stack_version");
+          Map<String, String> stackInfoMap = new HashMap<>();
+          stackInfoMap.put(rs.getString("stack_name"), rs.getString("stack_version"));
+          clusterStackInfo.put(rs.getString("cluster_name"), stackInfoMap);
         }
       }
 
-      if (stackName != null && stackVersion != null) {
-        Set<String> serviceNames = new HashSet<>();
-        Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = new
HashMap<>();
-        Multimap<String, String> stackServiceConfigs = HashMultimap.create();
 
-        rs = statement.executeQuery(GET_SERVICES_WITH_CONFIGS_QUERY);
-        if (rs != null) {
-          String serviceName = null, configType = null;
-          Integer serviceVersion = null;
-          while (rs.next()) {
-            serviceName = rs.getString("service_name");
-            configType = rs.getString("type_name");
-            serviceVersion = rs.getInt("version");
+      Set<String> serviceNames = new HashSet<>();
+      Map<String, Map<Integer, Multimap<String, String>>> dbClusterServiceVersionConfigs
= new HashMap<>();
+      Multimap<String, String> stackServiceConfigs = HashMultimap.create();
+
+      rs = statement.executeQuery(GET_SERVICES_WITH_CONFIGS_QUERY);
+      if (rs != null) {
+        String serviceName = null, configType = null, clusterName = null;
+        Integer serviceVersion = null;
+        while (rs.next()) {
+          clusterName = rs.getString("cluster_name");
+          serviceName = rs.getString("service_name");
+          configType = rs.getString("type_name");
+          serviceVersion = rs.getInt("version");
+
+          serviceNames.add(serviceName);
 
-            serviceNames.add(serviceName);
+          if (dbClusterServiceVersionConfigs.get(clusterName) != null) {
+            Map<Integer, Multimap<String, String>> dbServiceVersionConfigs =
dbClusterServiceVersionConfigs.get(clusterName);
 
-            if (dbServiceVersionConfigs.get(serviceVersion) == null) {
+            if (dbServiceVersionConfigs.get(serviceVersion) != null) {
+              dbServiceVersionConfigs.get(serviceVersion).put(serviceName, configType);
+            } else {
               Multimap<String, String> dbServiceConfigs = HashMultimap.create();
               dbServiceConfigs.put(serviceName, configType);
               dbServiceVersionConfigs.put(serviceVersion, dbServiceConfigs);
-            } else {
-              dbServiceVersionConfigs.get(serviceVersion).put(serviceName, configType);
             }
+          } else {
+
+            Map<Integer, Multimap<String, String>> dbServiceVersionConfigs =
new HashMap<>();
+            Multimap<String, String> dbServiceConfigs = HashMultimap.create();
+            dbServiceConfigs.put(serviceName, configType);
+            dbServiceVersionConfigs.put(serviceVersion, dbServiceConfigs);
+            dbClusterServiceVersionConfigs.put(clusterName, dbServiceVersionConfigs);
+
           }
         }
+      }
 
-
+      for (Map.Entry<String, Map<String, String>> clusterStackInfoEntry : clusterStackInfo.entrySet())
{
+        String clusterName = clusterStackInfoEntry.getKey();
+        Map<String, String> stackInfo = clusterStackInfoEntry.getValue();
+        String stackName = stackInfo.keySet().iterator().next();
+        String stackVersion = stackInfo.get(stackName);
         Map<String, ServiceInfo> serviceInfoMap = ambariMetaInfo.getServices(stackName,
stackVersion);
         for (String serviceName : serviceNames) {
           ServiceInfo serviceInfo = serviceInfoMap.get(serviceName);
@@ -376,6 +411,7 @@ public class CheckDatabaseHelper {
           }
         }
 
+        Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = dbClusterServiceVersionConfigs.get(clusterName);
         for (Integer serviceVersion : dbServiceVersionConfigs.keySet()) {
           Multimap<String, String> dbServiceConfigs = dbServiceVersionConfigs.get(serviceVersion);
           for (String serviceName : dbServiceConfigs.keySet()) {
@@ -384,33 +420,45 @@ public class CheckDatabaseHelper {
             if (serviceConfigsFromDB != null && serviceConfigsFromStack != null)
{
               serviceConfigsFromStack.removeAll(serviceConfigsFromDB);
               if (!serviceConfigsFromStack.isEmpty()) {
-                LOG.error(String.format("Required config(s): %s is(are) not available for
service %s with service config version %s",
-                        StringUtils.join(serviceConfigsFromStack, ","), serviceName, Integer.toString(serviceVersion)));
+                LOG.error(String.format("Required config(s): %s is(are) not available for
service %s with service config version %s for cluster %s",
+                        StringUtils.join(serviceConfigsFromStack, ","), serviceName, Integer.toString(serviceVersion),
clusterName));
+                errorAvailable = true;
               }
             }
           }
         }
       }
 
+
       rs = statement.executeQuery(GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY);
       if (rs != null) {
-        String serviceName = null, configType = null;
+        String serviceName = null, configType = null, clusterName = null;
         while (rs.next()) {
+          clusterName = rs.getString("cluster_name");
           serviceName = rs.getString("service_name");
           configType = rs.getString("type_name");
 
-          if (notSelectedServiceConfigs.get(serviceName) != null) {
-            notSelectedServiceConfigs.get(serviceName).add(configType);
+
+          if (notSelectedServiceConfigs.get(clusterName) != null) {
+            Multimap<String, String> serviceConfigs = notSelectedServiceConfigs.get(clusterName);
+            serviceConfigs.put(serviceName, configType);
           } else {
-            List<String> configTypes = new ArrayList<>();
-            configTypes.add(configType);
-            notSelectedServiceConfigs.put(serviceName, configTypes);
+
+            Multimap<String, String> serviceConfigs = HashMultimap.create();
+            serviceConfigs.put(serviceName, configType);
+            notSelectedServiceConfigs.put(clusterName, serviceConfigs);
+
           }
+
         }
       }
 
-      for (String serviceName : notSelectedServiceConfigs.keySet()) {
-        LOG.error(String.format("You have non selected configs: %s for service %s.", StringUtils.join(notSelectedServiceConfigs.get(serviceName),
","), serviceName));
+      for (String clusterName : notSelectedServiceConfigs.keySet()) {
+        Multimap<String, String> serviceConfig = notSelectedServiceConfigs.get(clusterName);
+        for (String serviceName : serviceConfig.keySet()) {
+          LOG.error(String.format("You have non selected configs: %s for service %s from
cluster %s!", StringUtils.join(serviceConfig.get(serviceName), ","), serviceName, clusterName));
+          errorAvailable = true;
+        }
       }
     } catch (SQLException e) {
       LOG.error("Exception occurred during complex service check procedure: ", e);
@@ -467,6 +515,11 @@ public class CheckDatabaseHelper {
     } finally {
       if (checkDatabaseHelper != null) {
         checkDatabaseHelper.closeConnection();
+        if (checkDatabaseHelper.isErrorAvailable()) {
+          System.out.print("Some error(s) was(were) found. Please check ambari-server-check-database.log
for problem(s).");
+        } else {
+          System.out.print("No erros were found.");
+        }
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4761fe7c/ambari-server/src/main/python/ambari_server/checkDatabase.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/checkDatabase.py b/ambari-server/src/main/python/ambari_server/checkDatabase.py
index af1d74f..80eecc2 100644
--- a/ambari-server/src/main/python/ambari_server/checkDatabase.py
+++ b/ambari-server/src/main/python/ambari_server/checkDatabase.py
@@ -39,8 +39,7 @@ from ambari_server.serverUtils import is_server_runing
 from ambari_server.userInput import get_YN_input
 
 CHECK_DATABASE_HELPER_CMD = "{0} -cp {1} " + \
-                         "org.apache.ambari.server.checks.CheckDatabaseHelper" + \
-                         " > " + configDefaults.SERVER_LOG_FILE + " 2>&1"
+                         "org.apache.ambari.server.checks.CheckDatabaseHelper"
 
 def check_database(options):
 
@@ -71,10 +70,10 @@ def check_database(options):
   print_info_msg("Return code from check database command, retcode = " + str(retcode))
 
   if retcode > 0:
-    print_error_msg("Database check failed to complete. Please check ambari-server.log for
problem.")
+    print_error_msg("Database check failed to complete. Please check ambari-server.log and
ambari-server-check-database.log for problem.")
     raise FatalException(1, 'Database check failed.')
   else:
-    print_info_msg('Check database completed successfully. Please check ambari-server.log
for results.')
+    print str(stdout)
 
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4761fe7c/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 1c2765c..67594b7 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
@@ -260,22 +260,27 @@ public class CheckDatabaseHelperTest {
     expect(stackResultSet.getString("stack_version")).andReturn("2.2");
     expect(mockDBDbAccessor.getConnection()).andReturn(mockConnection);
     expect(mockConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)).andReturn(mockStatement);
-    expect(mockStatement.executeQuery("select service_name from clusterservices where service_name
not in (select service_name from serviceconfig where group_id is null)")).andReturn(mockResultSet);
+    expect(mockStatement.executeQuery("select c.cluster_name, service_name from clusterservices
cs " +
+            "join clusters c on cs.cluster_id=c.cluster_id " +
+            "where service_name not in (select service_name from serviceconfig sc where sc.cluster_id=cs.cluster_id
and sc.service_name=cs.service_name and sc.group_id is null)")).andReturn(mockResultSet);
     expect(mockStatement.executeQuery("select service_name from serviceconfig where service_config_id
not in (select service_config_id from serviceconfigmapping) and group_id is null")).andReturn(mockResultSet);
-    expect(mockStatement.executeQuery("select s.stack_name, s.stack_version from clusters
c join stack s on c.desired_stack_id = s.stack_id")).andReturn(stackResultSet);
-    expect(mockStatement.executeQuery("select cs.service_name, type_name, sc.version from
clusterservices cs " +
-            "join serviceconfig sc on cs.service_name=sc.service_name " +
+    expect(mockStatement.executeQuery("select c.cluster_name, s.stack_name, s.stack_version
from clusters c " +
+            "join stack s on c.desired_stack_id = s.stack_id")).andReturn(stackResultSet);
+    expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name, type_name,
sc.version from clusterservices cs " +
+            "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id
" +
             "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id
" +
-            "join clusterconfig cc on scm.config_id=cc.config_id " +
+            "join clusterconfig cc on scm.config_id=cc.config_id and sc.cluster_id=cc.cluster_id
" +
+            "join clusters c on cc.cluster_id=c.cluster_id " +
             "where sc.group_id is null " +
-            "group by cs.service_name, type_name, sc.version")).andReturn(serviceConfigResultSet);
-    expect(mockStatement.executeQuery("select cs.service_name,cc.type_name from clusterservices
cs " +
-            "join serviceconfig sc on cs.service_name=sc.service_name " +
+            "group by c.cluster_name, cs.service_name, type_name, sc.version")).andReturn(serviceConfigResultSet);
+    expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name,cc.type_name
from clusterservices cs " +
+            "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id
" +
             "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id
" +
-            "join clusterconfig cc on scm.config_id=cc.config_id " +
-            "join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag
" +
-            "where sc.group_id is null and sc.service_config_id = (select max(service_config_id)
from serviceconfig sc2 where sc2.service_name=sc.service_name) " +
-            "group by cs.service_name,cc.type_name " +
+            "join clusterconfig cc on scm.config_id=cc.config_id and cc.cluster_id=sc.cluster_id
" +
+            "join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag
and cc.cluster_id=ccm.cluster_id " +
+            "join clusters c on ccm.cluster_id=c.cluster_id " +
+            "where sc.group_id is null and sc.service_config_id = (select max(service_config_id)
from serviceconfig sc2 where sc2.service_name=sc.service_name and sc2.cluster_id=sc.cluster_id)
" +
+            "group by c.cluster_name,cs.service_name,cc.type_name " +
             "having sum(ccm.selected) < 1")).andReturn(mockResultSet);
 
     CheckDatabaseHelper checkDatabaseHelper = new CheckDatabaseHelper(mockDBDbAccessor, mockInjector,
null);

http://git-wip-us.apache.org/repos/asf/ambari/blob/4761fe7c/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 2195ef0..f52edc3 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -6901,8 +6901,7 @@ class TestAmbariServer(TestCase):
     self.assertTrue(ensureCanStartUnderCurrentUserMock.called)
     self.assertTrue(generateEnvMock.called)
 
-    self.assertEquals(runOSCommandMock.call_args[0][0], '/path/to/java -cp test:path12 org.apache.ambari.server.checks.CheckDatabaseHelper'
-                                                        ' > /var/log/ambari-server/ambari-server.log
2>&1')
+    self.assertEquals(runOSCommandMock.call_args[0][0], '/path/to/java -cp test:path12 org.apache.ambari.server.checks.CheckDatabaseHelper')
 
     pass
 


Mime
View raw message