You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2015/08/12 15:40:17 UTC

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

Repository: ambari
Updated Branches:
  refs/heads/trunk 4b07879b3 -> a788a9f28


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/a788a9f2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a788a9f2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a788a9f2

Branch: refs/heads/trunk
Commit: a788a9f28bca56689d833eef6f1b4004a920d88c
Parents: 4b07879
Author: Dmytro Sen <ds...@apache.org>
Authored: Wed Aug 12 16:40:00 2015 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Wed Aug 12 16:40:00 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/a788a9f2/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/a788a9f2/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