ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-12731 Exceptions in ambari-server log: duplicate key value violates unique constraint "uni_alert_group_name" (dsen)
Date Wed, 12 Aug 2015 13:43:05 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 eb8fef862 -> 06dee693f


AMBARI-12731 Exceptions in ambari-server log: duplicate key value violates unique constraint
"uni_alert_group_name" (dsen)


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

Branch: refs/heads/branch-2.1
Commit: 06dee693f7d7c9f634ce176d4137d893c21d7554
Parents: eb8fef8
Author: Dmytro Sen <dsen@apache.org>
Authored: Wed Aug 12 16:40:00 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Wed Aug 12 16:42:57 2015 +0300

----------------------------------------------------------------------
 .../listeners/alerts/AlertServiceStateListener.java | 16 +++++++++-------
 .../ambari/server/orm/dao/AlertDispatchDAO.java     |  3 ++-
 2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/06dee693/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
index 41f9e81..496bb6b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
@@ -125,14 +125,16 @@ public class AlertServiceStateListener {
     String stackVersion = event.getStackVersion();
     String serviceName = event.getServiceName();
 
-    // create the default alert group for the new service; this MUST be done
-    // before adding definitions so that they are properly added to the
+    // create the default alert group for the new service if absent; this MUST
+    // be done before adding definitions so that they are properly added to the
     // default group
-    try {
-      m_alertDispatchDao.createDefaultGroup(clusterId, serviceName);
-    } catch (AmbariException ambariException) {
-      LOG.error("Unable to create a default alert group for {}", event.getServiceName(),
-          ambariException);
+    if (null == m_alertDispatchDao.findDefaultServiceGroup(clusterId, serviceName)) {
+      try {
+        m_alertDispatchDao.createDefaultGroup(clusterId, serviceName);
+      } catch (AmbariException ambariException) {
+        LOG.error("Unable to create a default alert group for {}",
+          event.getServiceName(), ambariException);
+      }
     }
 
     // populate alert definitions for the new service from the database, but

http://git-wip-us.apache.org/repos/asf/ambari/blob/06dee693/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
index a372748..1f1aa45 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
@@ -406,7 +406,7 @@ public class AlertDispatchDAO {
    *          the predicate to apply, or {@code null} for none.
    * @return the total count of rows that would be returned in a result set.
    */
-  @Transactional
+  @RequiresSession
   public int getNoticesCount(Predicate predicate) {
     return 0;
   }
@@ -457,6 +457,7 @@ public class AlertDispatchDAO {
    * @param serviceName
    *          the name of the group which is also the service name.
    */
+  @Transactional
   public AlertGroupEntity createDefaultGroup(long clusterId, String serviceName)
       throws AmbariException {
     // AMBARI is a special service that we let through, otherwise we need to


Mime
View raw message