瀏覽代碼

AMBARI-7263. Alerts: DDL for alert_current requires latest_text (ncole)

Nate Cole 10 年之前
父節點
當前提交
3035978fba

+ 19 - 0
ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java

@@ -66,6 +66,9 @@ public class AlertCurrentEntity {
 
   @Column(name = "original_timestamp", nullable = false)
   private Long originalTimestamp;
+  
+  @Column(name = "latest_text", length = 4000)
+  private String latestText = null;
 
   /**
    * Unidirectional one-to-one association to {@link AlertHistoryEntity}
@@ -168,6 +171,22 @@ public class AlertCurrentEntity {
   public void setOriginalTimestamp(Long originalTimestamp) {
     this.originalTimestamp = originalTimestamp;
   }
+  
+  /**
+   * Gets the latest text for this alert.  History will not get a new record on
+   * update when the state is the same, but the text may be changed.  For example,
+   * CPU utilization includes the usage in the text and should be available.
+   */
+  public String getLatestText() {
+    return latestText;
+  }
+  
+  /**
+   * Sets the latest text.  {@link #getLatestText()}
+   */
+  public void setLatestText(String text) {
+    latestText = text;
+  }
 
   /**
    * Gets the associated {@link AlertHistoryEntity} entry for this current alert

+ 1 - 0
ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java

@@ -737,6 +737,7 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
     columns.add(new DBColumnInfo("original_timestamp", Long.class, 0, null,
         false));
     columns.add(new DBColumnInfo("latest_timestamp", Long.class, 0, null, false));
+    columns.add(new DBColumnInfo("latest_text", String.class, 4000, null, true));
     dbAccessor.createTable(ALERT_TABLE_CURRENT, columns, "alert_id");
 
     dbAccessor.addFKConstraint(ALERT_TABLE_CURRENT, "fk_alert_current_def_id",

+ 1 - 0
ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql

@@ -190,6 +190,7 @@ CREATE TABLE alert_current (
   maintenance_state VARCHAR(255),
   original_timestamp BIGINT NOT NULL,
   latest_timestamp BIGINT NOT NULL,
+  latest_text TEXT,
   PRIMARY KEY (alert_id),
   FOREIGN KEY (definition_id) REFERENCES alert_definition(definition_id),
   FOREIGN KEY (history_id) REFERENCES alert_history(alert_id)

+ 1 - 0
ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql

@@ -181,6 +181,7 @@ CREATE TABLE alert_current (
   maintenance_state VARCHAR2(255),
   original_timestamp NUMBER(19) NOT NULL,
   latest_timestamp NUMBER(19) NOT NULL,
+  latest_text VARCHAR2(4000),
   PRIMARY KEY (alert_id),
   FOREIGN KEY (definition_id) REFERENCES alert_definition(definition_id),
   FOREIGN KEY (history_id) REFERENCES alert_history(alert_id)

+ 1 - 0
ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql

@@ -213,6 +213,7 @@ CREATE TABLE alert_current (
   maintenance_state VARCHAR(255),
   original_timestamp BIGINT NOT NULL,
   latest_timestamp BIGINT NOT NULL,
+  latest_text TEXT,
   PRIMARY KEY (alert_id),
   FOREIGN KEY (definition_id) REFERENCES alert_definition(definition_id),
   FOREIGN KEY (history_id) REFERENCES alert_history(alert_id)

+ 1 - 0
ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql

@@ -277,6 +277,7 @@ CREATE TABLE ambari.alert_current (
   maintenance_state VARCHAR(255),
   original_timestamp BIGINT NOT NULL,
   latest_timestamp BIGINT NOT NULL,
+  latest_text TEXT,
   PRIMARY KEY (alert_id),
   FOREIGN KEY (definition_id) REFERENCES ambari.alert_definition(definition_id),
   FOREIGN KEY (history_id) REFERENCES ambari.alert_history(alert_id)

+ 1 - 1
ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java

@@ -211,7 +211,7 @@ public class UpgradeCatalog170Test {
 
     assertEquals(12, alertDefinitionColumnCapture.getValue().size());
     assertEquals(11, alertHistoryColumnCapture.getValue().size());
-    assertEquals(6, alertCurrentColumnCapture.getValue().size());
+    assertEquals(7, alertCurrentColumnCapture.getValue().size());
     assertEquals(5, alertGroupColumnCapture.getValue().size());
     assertEquals(5, alertTargetCapture.getValue().size());
     assertEquals(2, alertGroupTargetCapture.getValue().size());