ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [27/35] git commit: AMBARI-7024 - Alerts: DDL Update For Default Service Alert Groups (jonathanhurley)
Date Wed, 27 Aug 2014 14:05:08 GMT
AMBARI-7024 - Alerts: DDL Update For Default Service Alert Groups (jonathanhurley)


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

Branch: refs/heads/branch-alerts-dev
Commit: 0e9c744f21a7b8aaada917eafbf3fbbed1a87edc
Parents: 1ab3bb5
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Tue Aug 26 17:53:28 2014 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Tue Aug 26 19:51:38 2014 -0400

----------------------------------------------------------------------
 .../server/orm/entities/AlertGroupEntity.java   | 74 ++++++++++++++------
 .../server/upgrade/UpgradeCatalog170.java       |  1 +
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  1 +
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  1 +
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  1 +
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  1 +
 .../server/upgrade/UpgradeCatalog170Test.java   |  4 +-
 7 files changed, 60 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0e9c744f/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertGroupEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertGroupEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertGroupEntity.java
index 976855e..1ca592c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertGroupEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertGroupEntity.java
@@ -65,6 +65,9 @@ public class AlertGroupEntity {
   @Column(name = "is_default", nullable = false)
   private Integer isDefault = Integer.valueOf(0);
 
+  @Column(name = "service_name", nullable = true, length = 255)
+  private String serviceName;
+
   /**
    * Bi-directional many-to-many association to {@link AlertDefinitionEntity}
    */
@@ -81,7 +84,7 @@ public class AlertGroupEntity {
 
   /**
    * Gets the unique ID of this grouping of alerts.
-   * 
+   *
    * @return the ID (never {@code null}).
    */
   public Long getGroupId() {
@@ -90,7 +93,7 @@ public class AlertGroupEntity {
 
   /**
    * Sets the unique ID of this grouping of alerts.
-   * 
+   *
    * @param groupId
    *          the ID (not {@code null}).
    */
@@ -100,7 +103,7 @@ public class AlertGroupEntity {
 
   /**
    * Gets the ID of the cluster that this alert group is a part of.
-   * 
+   *
    * @return the ID (never {@code null}).
    */
   public Long getClusterId() {
@@ -109,7 +112,7 @@ public class AlertGroupEntity {
 
   /**
    * Sets the ID of the cluster that this alert group is a part of.
-   * 
+   *
    * @param clusterId
    *          the ID of the cluster (not {@code null}).
    */
@@ -120,7 +123,7 @@ public class AlertGroupEntity {
   /**
    * Gets the name of the grouping of alerts. Group names are unique in a given
    * cluster.
-   * 
+   *
    * @return the group name (never {@code null}).
    */
   public String getGroupName() {
@@ -130,7 +133,7 @@ public class AlertGroupEntity {
   /**
    * Sets the name of this grouping of alerts. Group names are unique in a given
    * cluster.
-   * 
+   *
    * @param groupName
    *          the name of the group (not {@code null}).
    */
@@ -143,7 +146,7 @@ public class AlertGroupEntity {
    * groups cannot have their alert definition groupings changed. New alert
    * definitions are automtaically added to the default group that belongs to
    * the service of that definition.
-   * 
+   *
    * @return {@code true} if this is a default group, {@code false} otherwise.
    */
   public boolean isDefault() {
@@ -152,7 +155,7 @@ public class AlertGroupEntity {
 
   /**
    * Sets whether this is a default group and is immutable.
-   * 
+   *
    * @param isDefault
    *          {@code true} to make this group immutable.
    */
@@ -161,8 +164,31 @@ public class AlertGroupEntity {
   }
 
   /**
-   * Gets all of the alert definitions that are a part of this grouping.
+   * Gets the name of the service. This is only applicable when
+   * {@link #isDefault()} is {@code true}.
+   *
+   * @return the service that this is the default group for, or {@code null} if
+   *         this is not a default group.
+   */
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  /**
+   * Set the service name. This is only applicable when {@link #isDefault()} is
+   * {@code true}.
    * 
+   * @param serviceName
+   *          the service that this is the default group for, or {@code null} if
+   *          this is not a default group.
+   */
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+
+  /**
+   * Gets all of the alert definitions that are a part of this grouping.
+   *
    * @return the alert definitions or {@code null} if none.
    */
   public Set<AlertDefinitionEntity> getAlertDefinitions() {
@@ -171,7 +197,7 @@ public class AlertGroupEntity {
 
   /**
    * Set all of the alert definitions that are part of this alert group.
-   * 
+   *
    * @param alertDefinitions
    *          the definitions, or {@code null} for none.
    */
@@ -182,25 +208,27 @@ public class AlertGroupEntity {
   /**
    * Gets an immutable set of the targets that will receive notifications for
    * alert definitions in this group.
-   * 
+   *
    * @return the targets, or {@code null} if there are none.
    */
   public Set<AlertTargetEntity> getAlertTargets() {
-    if( null == alertTargets )
+    if( null == alertTargets ) {
       return Collections.emptySet();
-      
+    }
+
     return Collections.unmodifiableSet(alertTargets);
   }
 
   /**
    * Adds the specified target to the targets that this group will dispatch to.
-   * 
+   *
    * @param alertTarget
    *          the target to add (not {@code null}).
    */
   public void addAlertTarget(AlertTargetEntity alertTarget) {
-    if (null == alertTargets)
+    if (null == alertTargets) {
       alertTargets = new HashSet<AlertTargetEntity>();
+    }
 
     alertTargets.add(alertTarget);
     alertTarget.addAlertGroup(this);
@@ -209,13 +237,14 @@ public class AlertGroupEntity {
   /**
    * Removes the specified target from the targets that this group will dispatch
    * to.
-   * 
+   *
    * @param alertTarget
    *          the target to remove (not {@code null}).
    */
   public void removeAlertTarget(AlertTargetEntity alertTarget) {
-    if (null != alertTargets)
+    if (null != alertTargets) {
       alertTargets.remove(alertTarget);
+    }
 
     alertTarget.removeAlertGroup(this);
   }
@@ -223,7 +252,7 @@ public class AlertGroupEntity {
   /**
    * Sets all of the targets that will receive notifications for alert
    * definitions in this group.
-   * 
+   *
    * @param alertTargets
    *          the targets, or {@code null} if there are none.
    */
@@ -248,16 +277,19 @@ public class AlertGroupEntity {
    */
   @Override
   public boolean equals(Object object) {
-    if (this == object)
+    if (this == object) {
       return true;
+    }
 
-    if (object == null || getClass() != object.getClass())
+    if (object == null || getClass() != object.getClass()) {
       return false;
+    }
 
     AlertGroupEntity that = (AlertGroupEntity) object;
 
-    if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null)
+    if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null) {
       return false;
+    }
 
     return true;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e9c744f/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
index dc3d5b8..864c084 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
@@ -671,6 +671,7 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
     columns.add(new DBColumnInfo("cluster_id", Long.class, null, null, false));
     columns.add(new DBColumnInfo("group_name", String.class, 255, null, false));
     columns.add(new DBColumnInfo("is_default", Short.class, 1, 1, false));
+    columns.add(new DBColumnInfo("service_name", String.class, 255, null, true));
     dbAccessor.createTable(ALERT_TABLE_GROUP, columns, "group_id");
 
     dbAccessor.executeQuery(

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e9c744f/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 2d83aeb..59d972e 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -200,6 +200,7 @@ CREATE TABLE alert_group (
   cluster_id BIGINT NOT NULL,
   group_name VARCHAR(255) NOT NULL,
   is_default SMALLINT NOT NULL DEFAULT 0,
+  service_name VARCHAR(255),
   PRIMARY KEY (group_id),
   CONSTRAINT uni_alert_group_name UNIQUE(cluster_id,group_name)
 );

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e9c744f/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 241bb2b..52ca857 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -191,6 +191,7 @@ CREATE TABLE alert_group (
   cluster_id NUMBER(19) NOT NULL,
   group_name VARCHAR2(255) NOT NULL,
   is_default NUMBER(1) DEFAULT 0 NOT NULL,
+  service_name VARCHAR2(255),
   PRIMARY KEY (group_id),
   CONSTRAINT uni_alert_group_name UNIQUE(cluster_id,group_name)
 );

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e9c744f/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index ddea71c..39d3ecf 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -223,6 +223,7 @@ CREATE TABLE alert_group (
   cluster_id BIGINT NOT NULL,
   group_name VARCHAR(255) NOT NULL,
   is_default SMALLINT NOT NULL DEFAULT 0,
+  service_name VARCHAR(255),
   PRIMARY KEY (group_id),
   CONSTRAINT uni_alert_group_name UNIQUE(cluster_id,group_name)
 );

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e9c744f/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index 17b95c2..196d298 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -287,6 +287,7 @@ CREATE TABLE ambari.alert_group (
   cluster_id BIGINT NOT NULL,
   group_name VARCHAR(255) NOT NULL,
   is_default SMALLINT NOT NULL DEFAULT 0,
+  service_name VARCHAR(255),
   PRIMARY KEY (group_id),
   CONSTRAINT uni_alert_group_name UNIQUE(cluster_id,group_name)
 );

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e9c744f/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
index 1cfba46..5210add 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
@@ -208,7 +208,7 @@ public class UpgradeCatalog170Test {
     assertEquals(12, alertDefinitionColumnCapture.getValue().size());
     assertEquals(11, alertHistoryColumnCapture.getValue().size());
     assertEquals(6, alertCurrentColumnCapture.getValue().size());
-    assertEquals(4, alertGroupColumnCapture.getValue().size());
+    assertEquals(5, alertGroupColumnCapture.getValue().size());
     assertEquals(5, alertTargetCapture.getValue().size());
     assertEquals(2, alertGroupTargetCapture.getValue().size());
     assertEquals(2, alertGroupingCapture.getValue().size());
@@ -428,7 +428,7 @@ public class UpgradeCatalog170Test {
     dbAccessor.addColumn(eq("clusterconfig"),
         capture(clusterConfigAttributesColumnCapture));
   }
- 
+
   private void setStageExpectations(DBAccessor dbAccessor,
                                     Capture<DBAccessor.DBColumnInfo> stageCommandParamsColumnCapture,
                                     Capture<DBAccessor.DBColumnInfo> stageHostParamsColumnCapture)


Mime
View raw message