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:04 UTC
[11/12] git commit: AMBARI-6853 - Alerts: Calculate Hash Based On
Alert Definitions (jonathanhurley)
AMBARI-6853 - Alerts: Calculate Hash Based On Alert Definitions (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9585c062
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9585c062
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9585c062
Branch: refs/heads/branch-alerts-dev
Commit: 9585c0624e9d393c53da43012538e0498884021e
Parents: 7eb8370
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Wed Aug 13 15:39:35 2014 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 23:19:49 2014 -0400
----------------------------------------------------------------------
.../apache/ambari/server/agent/HeartBeatHandler.java | 4 ++++
.../apache/ambari/server/agent/HeartBeatResponse.java | 13 +++++++++++++
.../internal/AlertDefinitionResourceProvider.java | 3 +++
ambari-server/src/main/resources/properties.json | 3 ++-
.../internal/AlertDefinitionResourceProviderTest.java | 7 +++++--
5 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9585c062/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index 65b7b6f..3c16257 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@ -224,6 +224,10 @@ public class HeartBeatHandler {
annotateResponse(hostname, response);
}
+ // send the alert definition hash for this host
+ Map<String, String> alertDefinitionHashes = alertDefinitionHash.getHashes(hostname);
+ response.setAlertDefinitionHash(alertDefinitionHashes);
+
return response;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/9585c062/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
index 1e9dc12..fe656c8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.agent;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import com.google.gson.annotations.SerializedName;
@@ -55,6 +56,7 @@ public class HeartBeatResponse {
@SerializedName("restartAgent")
private boolean restartAgent = false;
+ private boolean hasMappedComponents = false;
@SerializedName("hasMappedComponents")
private boolean hasMappedComponents = false;
@@ -137,6 +139,16 @@ public class HeartBeatResponse {
this.hasMappedComponents = hasMappedComponents;
}
+ @JsonProperty("alertDefinitionHashes")
+ public Map<String, String> getAlertDefinitionHash() {
+ return alertDefinitionHashes;
+ }
+
+ @JsonProperty("alertDefinitionHashes")
+ public void setAlertDefinitionHash(Map<String, String> alertDefinitionHashes) {
+ this.alertDefinitionHashes = alertDefinitionHashes;
+ }
+
public void addExecutionCommand(ExecutionCommand execCmd) {
executionCommands.add(execCmd);
}
@@ -169,6 +181,7 @@ public class HeartBeatResponse {
buffer.append(", alertDefinitionCommands=").append(alertDefinitionCommands);
buffer.append(", registrationCommand=").append(registrationCommand);
buffer.append(", restartAgent=").append(restartAgent);
+ buffer.append(", alertDefinitionHashes=").append(alertDefinitionHashes);
buffer.append('}');
return buffer.toString();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/9585c062/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 f20a9a9..1510f86 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
@@ -72,6 +72,7 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
protected static final String ALERT_DEF_COMPONENT_NAME = "AlertDefinition/component_name";
protected static final String ALERT_DEF_ENABLED = "AlertDefinition/enabled";
protected static final String ALERT_DEF_SCOPE = "AlertDefinition/scope";
+ protected static final String ALERT_DEF_UUID = "AlertDefinition/uuid";
private static Set<String> pkPropertyIds = new HashSet<String>(
Arrays.asList(ALERT_DEF_ID, ALERT_DEF_NAME));
@@ -407,6 +408,8 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
setResourceProperty(resource, ALERT_DEF_SOURCE_TYPE, entity.getSourceType(), requestedIds);
setResourceProperty(resource, ALERT_DEF_LABEL, entity.getLabel(),
requestedIds);
+ setResourceProperty(resource, ALERT_DEF_UUID, entity.getHash(),
+ requestedIds);
if (!isCollection && null != resource.getPropertyValue(ALERT_DEF_SOURCE_TYPE)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/9585c062/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 aa2bf71..6f79413 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -420,7 +420,8 @@
"AlertDefinition/interval",
"AlertDefinition/enabled",
"AlertDefinition/scope",
- "AlertDefinition/source"
+ "AlertDefinition/source",
+ "AlertDefinition/uuid"
],
"Controller":[
"Controllers/name",
http://git-wip-us.apache.org/repos/asf/ambari/blob/9585c062/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 333f674..1ccfab2 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
@@ -108,7 +108,8 @@ public class AlertDefinitionResourceProviderTest {
AlertDefinitionResourceProvider.ALERT_DEF_CLUSTER_NAME,
AlertDefinitionResourceProvider.ALERT_DEF_ID,
AlertDefinitionResourceProvider.ALERT_DEF_NAME,
- AlertDefinitionResourceProvider.ALERT_DEF_LABEL);
+ AlertDefinitionResourceProvider.ALERT_DEF_LABEL,
+ AlertDefinitionResourceProvider.ALERT_DEF_UUID);
AmbariManagementController amc = createMock(AmbariManagementController.class);
Clusters clusters = createMock(Clusters.class);
@@ -136,6 +137,9 @@ public class AlertDefinitionResourceProviderTest {
Assert.assertEquals("Mock Label",
r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_LABEL));
+ Assert.assertEquals(DEFINITION_UUID,
+ r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_UUID));
+
verify(amc, clusters, cluster, dao);
}
@@ -402,7 +406,6 @@ public class AlertDefinitionResourceProviderTest {
return Arrays.asList(entity);
}
-
/**
*
*/