You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2014/08/19 05:40:03 UTC
[10/12] git commit: AMBARI-6908 - Alerts: AlertDefinition Should Have
a Label (jonathanhurley)
AMBARI-6908 - Alerts: AlertDefinition Should Have a Label (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7eb83709
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7eb83709
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7eb83709
Branch: refs/heads/branch-alerts-dev
Commit: 7eb837093e91b1531fad99c9d289c7b54cbac7f9
Parents: 4d1e7e1
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Mon Aug 18 21:01:32 2014 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 23:15:13 2014 -0400
----------------------------------------------------------------------
.../AlertDefinitionResourceProvider.java | 4 ++++
.../orm/entities/AlertDefinitionEntity.java | 22 ++++++++++++++++++++
.../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 +
.../src/main/resources/properties.json | 1 +
.../AlertDefinitionResourceProviderTest.java | 13 +++++++++++-
.../server/upgrade/UpgradeCatalog170Test.java | 4 ++--
10 files changed, 46 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
index df6aa2d..f20a9a9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
@@ -64,6 +64,7 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
protected static final String ALERT_DEF_CLUSTER_NAME = "AlertDefinition/cluster_name";
protected static final String ALERT_DEF_ID = "AlertDefinition/id";
protected static final String ALERT_DEF_NAME = "AlertDefinition/name";
+ protected static final String ALERT_DEF_LABEL = "AlertDefinition/label";
protected static final String ALERT_DEF_INTERVAL = "AlertDefinition/interval";
protected static final String ALERT_DEF_SOURCE_TYPE = "AlertDefinition/source/type";
protected static final String ALERT_DEF_SOURCE = "AlertDefinition/source";
@@ -196,6 +197,7 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
entity.setClusterId(Long.valueOf(cluster.getClusterId()));
entity.setComponentName((String) requestMap.get(ALERT_DEF_COMPONENT_NAME));
entity.setDefinitionName((String) requestMap.get(ALERT_DEF_NAME));
+ entity.setLabel((String) requestMap.get(ALERT_DEF_LABEL));
boolean enabled = requestMap.containsKey(ALERT_DEF_ENABLED) ?
Boolean.parseBoolean((String)requestMap.get(ALERT_DEF_ENABLED)) : true;
@@ -403,6 +405,8 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
setResourceProperty(resource, ALERT_DEF_ENABLED, Boolean.valueOf(entity.getEnabled()), requestedIds);
setResourceProperty(resource, ALERT_DEF_SCOPE, entity.getScope(), requestedIds);
setResourceProperty(resource, ALERT_DEF_SOURCE_TYPE, entity.getSourceType(), requestedIds);
+ setResourceProperty(resource, ALERT_DEF_LABEL, entity.getLabel(),
+ requestedIds);
if (!isCollection && null != resource.getPropertyValue(ALERT_DEF_SOURCE_TYPE)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
index 4e8b3b9..c93702a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
@@ -77,6 +77,9 @@ public class AlertDefinitionEntity {
@Column(name = "definition_name", nullable = false, length = 255)
private String definitionName;
+ @Column(name = "label", nullable = true, length = 255)
+ private String label;
+
@Column(name = "scope", length = 255)
@Enumerated(value = EnumType.STRING)
private Scope scope;
@@ -356,6 +359,25 @@ public class AlertDefinitionEntity {
}
/**
+ * Sets a human readable label for this alert definition.
+ *
+ * @param label
+ * the label or {@code null} if none.
+ */
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ /**
+ * Gets the label for this alert definition.
+ *
+ * @return the label or {@code null} if none.
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
* Called before {@link EntityManager#remove(Object)} for this entity, removes
* the non-owning relationship between definitions and groups.
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/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 bef01c1..144900e 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
@@ -574,6 +574,7 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
columns.add(new DBColumnInfo("service_name", String.class, 255, null, false));
columns.add(new DBColumnInfo("component_name", String.class, 255, null, true));
columns.add(new DBColumnInfo("scope", String.class, 255, null, true));
+ columns.add(new DBColumnInfo("label", String.class, 255, null, true));
columns.add(new DBColumnInfo("enabled", Short.class, 1, 1, false));
columns.add(new DBColumnInfo("schedule_interval", Integer.class, null, null, false));
columns.add(new DBColumnInfo("source_type", String.class, 255, null, false));
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/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 b39ca5d..fe39612 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -157,6 +157,7 @@ CREATE TABLE alert_definition (
service_name VARCHAR(255) NOT NULL,
component_name VARCHAR(255),
scope VARCHAR(255),
+ label VARCHAR(255),
enabled SMALLINT DEFAULT 1 NOT NULL,
schedule_interval INTEGER NOT NULL,
source_type VARCHAR(255) NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/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 500313b..e311646 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -148,6 +148,7 @@ CREATE TABLE alert_definition (
service_name VARCHAR2(255) NOT NULL,
component_name VARCHAR2(255),
scope VARCHAR2(255),
+ label VARCHAR2(255),
enabled NUMBER(1) DEFAULT 1 NOT NULL,
schedule_interval NUMBER(10) NOT NULL,
source_type VARCHAR2(255) NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/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 a13f415..25d973f 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -181,6 +181,7 @@ CREATE TABLE alert_definition (
service_name VARCHAR(255) NOT NULL,
component_name VARCHAR(255),
scope VARCHAR(255),
+ label VARCHAR(255),
enabled SMALLINT DEFAULT 1 NOT NULL,
schedule_interval INTEGER NOT NULL,
source_type VARCHAR(255) NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/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 ff38b24..2d5b267 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
@@ -246,6 +246,7 @@ CREATE TABLE ambari.alert_definition (
service_name VARCHAR(255) NOT NULL,
component_name VARCHAR(255),
scope VARCHAR(255),
+ label VARCHAR(255),
enabled SMALLINT DEFAULT 1 NOT NULL,
schedule_interval INTEGER NOT NULL,
source_type VARCHAR(255) NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 55b451e..aa2bf71 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -416,6 +416,7 @@
"AlertDefinition/component_name",
"AlertDefinition/id",
"AlertDefinition/name",
+ "AlertDefinition/label",
"AlertDefinition/interval",
"AlertDefinition/enabled",
"AlertDefinition/scope",
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
index 04d7f48..333f674 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
@@ -107,7 +107,8 @@ public class AlertDefinitionResourceProviderTest {
Request request = PropertyHelper.getReadRequest(
AlertDefinitionResourceProvider.ALERT_DEF_CLUSTER_NAME,
AlertDefinitionResourceProvider.ALERT_DEF_ID,
- AlertDefinitionResourceProvider.ALERT_DEF_NAME);
+ AlertDefinitionResourceProvider.ALERT_DEF_NAME,
+ AlertDefinitionResourceProvider.ALERT_DEF_LABEL);
AmbariManagementController amc = createMock(AmbariManagementController.class);
Clusters clusters = createMock(Clusters.class);
@@ -132,6 +133,9 @@ public class AlertDefinitionResourceProviderTest {
Assert.assertEquals("my_def", r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_NAME));
+ Assert.assertEquals("Mock Label",
+ r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_LABEL));
+
verify(amc, clusters, cluster, dao);
}
@@ -144,6 +148,7 @@ public class AlertDefinitionResourceProviderTest {
AlertDefinitionResourceProvider.ALERT_DEF_CLUSTER_NAME,
AlertDefinitionResourceProvider.ALERT_DEF_ID,
AlertDefinitionResourceProvider.ALERT_DEF_NAME,
+ AlertDefinitionResourceProvider.ALERT_DEF_LABEL,
AlertDefinitionResourceProvider.ALERT_DEF_SOURCE_TYPE);
AmbariManagementController amc = createMock(AmbariManagementController.class);
@@ -170,6 +175,8 @@ public class AlertDefinitionResourceProviderTest {
Assert.assertEquals("my_def", r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_NAME));
Assert.assertEquals("metric", r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_SOURCE_TYPE));
+ Assert.assertEquals("Mock Label",
+ r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_LABEL));
Assert.assertNotNull(r.getPropertyValue("AlertDefinition/source/type"));
}
@@ -204,6 +211,8 @@ public class AlertDefinitionResourceProviderTest {
requestProps.put(AlertDefinitionResourceProvider.ALERT_DEF_NAME, "my_def");
requestProps.put(AlertDefinitionResourceProvider.ALERT_DEF_SERVICE_NAME, "HDFS");
requestProps.put(AlertDefinitionResourceProvider.ALERT_DEF_SOURCE_TYPE, "METRIC");
+ requestProps.put(AlertDefinitionResourceProvider.ALERT_DEF_LABEL,
+ "Mock Label (Create)");
Request request = PropertyHelper.getCreateRequest(Collections.singleton(requestProps), null);
@@ -223,6 +232,7 @@ public class AlertDefinitionResourceProviderTest {
Assert.assertEquals("HDFS", entity.getServiceName());
Assert.assertNotNull(entity.getSource());
Assert.assertEquals("METRIC", entity.getSourceType());
+ Assert.assertEquals("Mock Label (Create)", entity.getLabel());
verify(amc, clusters, cluster, dao);
@@ -382,6 +392,7 @@ public class AlertDefinitionResourceProviderTest {
entity.setComponentName(null);
entity.setDefinitionId(Long.valueOf(1L));
entity.setDefinitionName("my_def");
+ entity.setLabel("Mock Label");
entity.setEnabled(true);
entity.setHash(DEFINITION_UUID);
entity.setScheduleInterval(Integer.valueOf(2));
http://git-wip-us.apache.org/repos/asf/ambari/blob/7eb83709/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 4033f03..6262a2b 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
@@ -197,7 +197,7 @@ public class UpgradeCatalog170Test {
assertViewColumns(maskColumnCapture);
assertViewParameterColumns(maskedColumnCapture);
- assertEquals(11, alertDefinitionColumnCapture.getValue().size());
+ assertEquals(12, alertDefinitionColumnCapture.getValue().size());
assertEquals(11, alertHistoryColumnCapture.getValue().size());
assertEquals(6, alertCurrentColumnCapture.getValue().size());
assertEquals(4, alertGroupColumnCapture.getValue().size());
@@ -282,7 +282,7 @@ public class UpgradeCatalog170Test {
upgradeCatalog.updateConfigurationProperties("hbase-env",
Collections.singletonMap("hbase_regionserver_xmn_ratio", "0.2"), false, false);
expectLastCall();
-
+
upgradeCatalog.updateConfigurationProperties("yarn-env",
Collections.singletonMap("min_user_id", "1000"), false, false);
expectLastCall();