Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C4F9518EE3 for ; Wed, 12 Aug 2015 13:43:05 +0000 (UTC) Received: (qmail 83191 invoked by uid 500); 12 Aug 2015 13:43:05 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 83165 invoked by uid 500); 12 Aug 2015 13:43:05 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 83156 invoked by uid 99); 12 Aug 2015 13:43:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Aug 2015 13:43:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7AFE3DFF41; Wed, 12 Aug 2015 13:43:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dsen@apache.org To: commits@ambari.apache.org Message-Id: <2cccda3ec1e3436ba23b92150c2b2c07@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) 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 Authored: Wed Aug 12 16:40:00 2015 +0300 Committer: Dmytro Sen 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