AMBARI-7263. Alerts: DDL for alert_current requires latest_text (ncole)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3035978f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3035978f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3035978f Branch: refs/heads/branch-alerts-dev Commit: 3035978fba2921e81e83eedc8fd77090f6442b94 Parents: e293b67 Author: Nate Cole <nc...@hortonworks.com> Authored: Thu Sep 11 12:03:41 2014 -0400 Committer: Nate Cole <nc...@hortonworks.com> Committed: Thu Sep 11 14:31:19 2014 -0400 ---------------------------------------------------------------------- .../server/orm/entities/AlertCurrentEntity.java | 19 +++++++++++++++++++ .../ambari/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 | 2 +- 7 files changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/3035978f/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java index cde61f2..ba21c42 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/3035978f/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 17750f9..0e8aea5 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 @@ -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", http://git-wip-us.apache.org/repos/asf/ambari/blob/3035978f/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 356ef0c..4a6d3ba 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql +++ b/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) http://git-wip-us.apache.org/repos/asf/ambari/blob/3035978f/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 ecaf220..2e6b5c0 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql +++ b/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) http://git-wip-us.apache.org/repos/asf/ambari/blob/3035978f/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 f0ac53a..400373e 100644 --- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql +++ b/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) http://git-wip-us.apache.org/repos/asf/ambari/blob/3035978f/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 6e82ae1..74e6d1c 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 @@ -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) http://git-wip-us.apache.org/repos/asf/ambari/blob/3035978f/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 d3d7f7c..c7f5f1b 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 @@ -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());