You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2015/09/14 14:56:40 UTC

ambari git commit: AMBARI-13086. 500 error for API calls to /api/v1/clusters/.(vbrodetskyi)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 ccc200e33 -> 67d96d6d8


AMBARI-13086. 500 error for API calls to /api/v1/clusters/<clusterName>.(vbrodetskyi)


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

Branch: refs/heads/branch-2.1
Commit: 67d96d6d80d4443f7725931ea6062c3653f9d3d0
Parents: ccc200e
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Mon Sep 14 15:56:19 2015 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Mon Sep 14 15:56:19 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ambari/server/orm/dao/AlertsDAO.java  | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/67d96d6d/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java
index 73ca637..4a5c5b0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java
@@ -499,8 +499,8 @@ public class AlertsDAO {
   public AlertHostSummaryDTO findCurrentHostCounts(long clusterId) {
     // use Number here since some databases like MySQL return Long and some
     // return Integer and we don't want a class cast exception
-    TypedQuery<Number> query = m_entityManagerProvider.get().createQuery(
-        HOST_COUNT_SQL_TEMPLATE, Number.class);
+    TypedQuery<Object> query = m_entityManagerProvider.get().createQuery(
+        HOST_COUNT_SQL_TEMPLATE, Object.class);
 
     query.setParameter("clusterId", Long.valueOf(clusterId));
     query.setParameter("criticalState", AlertState.CRITICAL);
@@ -513,13 +513,18 @@ public class AlertsDAO {
     int criticalCount = 0;
     int unknownCount = 0;
 
-    List<Number> hostStateValues = m_daoUtils.selectList(query);
-    for (Number hostStateValue : hostStateValues) {
+    List<Object> hostStateValues = m_daoUtils.selectList(query);
+    for (Object hostStateValue : hostStateValues) {
       if (null == hostStateValue) {
         continue;
       }
 
-      int integerValue = hostStateValue.intValue();
+      int integerValue;
+      if (hostStateValue instanceof Boolean) {
+        integerValue = (boolean)hostStateValue ? 1 : 0;
+      } else {
+        integerValue = ((Number)hostStateValue).intValue();
+      }
 
       switch (integerValue) {
         case 0: