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/18 18:39:38 UTC

git commit: AMBARI-6890 - Alerts: Send Empty Alert Definition With Hash To Agents (jonathanhurley)

Repository: ambari
Updated Branches:
  refs/heads/branch-alerts-dev d17baa9ff -> 09edccfcc


AMBARI-6890 - Alerts: Send Empty Alert Definition With Hash To Agents (jonathanhurley)


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

Branch: refs/heads/branch-alerts-dev
Commit: 09edccfccece74839cf8dce8543e2294ea09fcf7
Parents: d17baa9
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Mon Aug 18 10:03:00 2014 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 12:39:30 2014 -0400

----------------------------------------------------------------------
 .../ambari/server/agent/AgentCommand.java       |  24 +++-
 .../ambari/server/agent/CancelCommand.java      |   5 +-
 .../ambari/server/agent/ExecutionCommand.java   | 109 ++++++++--------
 .../ambari/server/agent/HeartBeatResponse.java  |  42 +++---
 .../ambari/server/agent/NagiosAlertCommand.java |  11 +-
 .../ambari/server/agent/StatusCommand.java      |  43 +++----
 .../AlertDefinitionResourceProvider.java        |   8 +-
 .../server/orm/entities/AlertHistoryEntity.java |  55 ++++----
 .../apache/ambari/server/utils/StageUtils.java  |  54 ++++----
 .../stacks/HDP/2.0.6/services/HDFS/alerts.json  |  58 +++++++++
 .../server/api/services/AmbariMetaInfoTest.java |   2 -
 .../AmbariManagementControllerTest.java         |  21 +--
 .../AlertDefinitionResourceProviderTest.java    |   2 +
 .../ambari/server/utils/TestStageUtils.java     | 127 ++++++++++---------
 .../stacks/HDP/2.0.5/services/HDFS/alerts.json  |  51 ++++++++
 15 files changed, 374 insertions(+), 238 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
index 29805a1..6e8aab1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentCommand.java
@@ -17,16 +17,34 @@
  */
 package org.apache.ambari.server.agent;
 
+import com.google.gson.Gson;
+
+/**
+ * The base class for all agent commands. Concrete implementations are
+ * serialized by Gson ({@link Gson}) and should be annotated with Gson
+ * annotations (not Jackson).
+ */
 public abstract class AgentCommand {
 
   private AgentCommandType commandType;
 
+  /**
+   * Constructor. Although not required for Gson, it's a good idea to have it so
+   * that we don't need to worry about unsafe object construction that bypasses
+   * the constructors.
+   * <p/>
+   * Subclasses should always use {@link #AgentCommand(AgentCommandType)}
+   */
   public AgentCommand() {
-    this.commandType = AgentCommandType.STATUS_COMMAND;
+    commandType = AgentCommandType.STATUS_COMMAND;
   }
 
+  /**
+   * Constructor. Must be invoked by all concrete subsclasses to properly set
+   * the type.
+   */
   public AgentCommand(AgentCommandType type) {
-    this.commandType = type;
+    commandType = type;
   }
 
   public enum AgentCommandType {
@@ -41,7 +59,7 @@ public abstract class AgentCommand {
   public AgentCommandType getCommandType() {
     return commandType;
   }
-  
+
   public void setCommandType(AgentCommandType commandType) {
     this.commandType = commandType;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/main/java/org/apache/ambari/server/agent/CancelCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/CancelCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/CancelCommand.java
index 55de9ea..7aa24c8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/CancelCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/CancelCommand.java
@@ -18,10 +18,6 @@
 package org.apache.ambari.server.agent;
 
 import com.google.gson.annotations.SerializedName;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-import java.util.HashMap;
-import java.util.Map;
 
 /**
  * Command to report the status of a list of services in roles.
@@ -35,6 +31,7 @@ public class CancelCommand extends AgentCommand {
   @SerializedName("target_task_id")
   private long targetTaskId;
 
+  @SerializedName("reason")
   private String reason;
 
   public long getTargetTaskId() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
index fdf96df..0600f27 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
@@ -22,12 +22,12 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import com.google.gson.annotations.SerializedName;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.utils.StageUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.codehaus.jackson.annotate.JsonProperty;
+
+import com.google.gson.annotations.SerializedName;
 
 
 /**
@@ -35,66 +35,95 @@ import org.codehaus.jackson.annotate.JsonProperty;
  * persisted in the database for recovery.
  */
 public class ExecutionCommand extends AgentCommand {
-  
+
   private static Log LOG = LogFactory.getLog(ExecutionCommand.class);
-  
+
   public ExecutionCommand() {
     super(AgentCommandType.EXECUTION_COMMAND);
   }
 
+  @SerializedName("clusterName")
   private String clusterName;
+
+  @SerializedName("taskId")
   private long taskId;
+
+  @SerializedName("commandId")
   private String commandId;
+
+  @SerializedName("hostname")
   private String hostname;
+
+  @SerializedName("role")
   private String role;
+
+  @SerializedName("hostLevelParams")
   private Map<String, String> hostLevelParams = new HashMap<String, String>();
+
+  @SerializedName("roleParams")
   private Map<String, String> roleParams = null;
+
+  @SerializedName("roleCommand")
   private RoleCommand roleCommand;
-  private Map<String, Set<String>> clusterHostInfo = 
+
+  @SerializedName("clusterHostInfo")
+  private Map<String, Set<String>> clusterHostInfo =
       new HashMap<String, Set<String>>();
+
+  @SerializedName("configurations")
   private Map<String, Map<String, String>> configurations;
+
   @SerializedName("configuration_attributes")
   private Map<String, Map<String, Map<String, String>>> configurationAttributes;
+
+  @SerializedName("configurationTags")
   private Map<String, Map<String, String>> configurationTags;
+
+  @SerializedName("forceRefreshConfigTags")
   private Set<String> forceRefreshConfigTags = new HashSet<String>();
+
+  @SerializedName("commandParams")
   private Map<String, String> commandParams;
+
+  @SerializedName("serviceName")
   private String serviceName;
+
+  @SerializedName("componentName")
   private String componentName;
 
   /**
    * Used for ignoring nagios alerts at agent
    */
+  @SerializedName("passiveInfo")
   private Set<Map<String,String>> passiveInfo;
 
-  @JsonProperty("commandId")
   public String getCommandId() {
-    return this.commandId;
+    return commandId;
   }
-  
-  @JsonProperty("commandId")
+
   public void setCommandId(String commandId) {
     this.commandId = commandId;
   }
-  
+
   @Override
   public boolean equals(Object other) {
     if (!(other instanceof ExecutionCommand)) {
       return false;
     }
     ExecutionCommand o = (ExecutionCommand) other;
-    return (this.commandId.equals(o.commandId) &&
-            this.hostname.equals(o.hostname) &&
-            this.role.equals(o.role) &&
-            this.roleCommand.equals(o.roleCommand));
+    return (commandId.equals(o.commandId) &&
+            hostname.equals(o.hostname) &&
+            role.equals(o.role) &&
+            roleCommand.equals(o.roleCommand));
   }
-  
+
   @Override
   public String toString() {
     try {
       return StageUtils.jaxbToString(this);
     } catch (Exception ex) {
       LOG.warn("Exception in json conversion", ex);
-      return "Exception in json conversion"; 
+      return "Exception in json conversion";
     }
   }
 
@@ -103,97 +132,79 @@ public class ExecutionCommand extends AgentCommand {
     return (hostname + commandId + role).hashCode();
   }
 
-  @JsonProperty("taskId")
   public long getTaskId() {
     return taskId;
   }
 
-  @JsonProperty("taskId")
   public void setTaskId(long taskId) {
     this.taskId = taskId;
   }
 
-  @JsonProperty("role")
   public String getRole() {
     return role;
   }
 
-  @JsonProperty("role")
   public void setRole(String role) {
     this.role = role;
   }
 
-  @JsonProperty("roleParams")
   public Map<String, String> getRoleParams() {
     return roleParams;
   }
 
-  @JsonProperty("roleParams")
   public void setRoleParams(Map<String, String> roleParams) {
     this.roleParams = roleParams;
   }
 
-  @JsonProperty("roleCommand")
   public RoleCommand getRoleCommand() {
     return roleCommand;
   }
 
-  @JsonProperty("roleCommand")
   public void setRoleCommand(RoleCommand cmd) {
-    this.roleCommand = cmd;
+    roleCommand = cmd;
   }
-  
-  @JsonProperty("clusterName")
+
   public String getClusterName() {
     return clusterName;
   }
-  
-  @JsonProperty("clusterName")
+
   public void setClusterName(String clusterName) {
     this.clusterName = clusterName;
   }
 
-  @JsonProperty("hostname")
   public String getHostname() {
     return hostname;
   }
 
-  @JsonProperty("hostname")
   public void setHostname(String hostname) {
     this.hostname = hostname;
   }
 
-  @JsonProperty("hostLevelParams")
   public Map<String, String> getHostLevelParams() {
     return hostLevelParams;
   }
 
-  @JsonProperty("hostLevelParams")
   public void setHostLevelParams(Map<String, String> params) {
-    this.hostLevelParams = params;
+    hostLevelParams = params;
   }
 
-  @JsonProperty("clusterHostInfo")
   public Map<String, Set<String>> getClusterHostInfo() {
     return clusterHostInfo;
   }
 
-  @JsonProperty("clusterHostInfo")
   public void setClusterHostInfo(Map<String, Set<String>> clusterHostInfo) {
     this.clusterHostInfo = clusterHostInfo;
   }
-  
-  @JsonProperty("configurations")
+
   public Map<String, Map<String, String>> getConfigurations() {
     return configurations;
   }
 
-  @JsonProperty("configurations")
   public void setConfigurations(Map<String, Map<String, String>> configurations) {
     this.configurations = configurations;
   }
   /**
-   * @return Returns the set of config-types that have to be propagated to actual-config of component of given custom command, if command is successfully finished. 
+   * @return Returns the set of config-types that have to be propagated to actual-config of component of given custom command, if command is successfully finished.
    */
   public Set<String> getForceRefreshConfigTags() {
     return forceRefreshConfigTags;
@@ -203,42 +214,34 @@ public class ExecutionCommand extends AgentCommand {
     this.forceRefreshConfigTags = forceRefreshConfigTags;
   }
 
-  @JsonProperty("configuration_attributes")
   public Map<String, Map<String, Map<String, String>>> getConfigurationAttributes() {
     return configurationAttributes;
   }
 
-  @JsonProperty("configuration_attributes")
   public void setConfigurationAttributes(Map<String, Map<String, Map<String, String>>> configurationAttributes) {
     this.configurationAttributes = configurationAttributes;
   }
 
-  @JsonProperty("commandParams")
   public Map<String, String> getCommandParams() {
     return commandParams;
   }
 
-  @JsonProperty("commandParams")
   public void setCommandParams(Map<String, String> commandParams) {
     this.commandParams = commandParams;
   }
 
-  @JsonProperty("serviceName")
   public String getServiceName() {
     return serviceName;
   }
 
-  @JsonProperty("serviceName")
   public void setServiceName(String serviceName) {
     this.serviceName = serviceName;
   }
 
-  @JsonProperty("componentName")
   public String getComponentName() {
     return componentName;
   }
 
-  @JsonProperty("componentName")
   public void setComponentName(String componentName) {
     this.componentName = componentName;
   }
@@ -248,22 +251,22 @@ public class ExecutionCommand extends AgentCommand {
    */
   public void setConfigurationTags(Map<String, Map<String, String>> configTags) {
     configurationTags = configTags;
-  }  
+  }
 
   /**
-   * @return the configuration tags 
+   * @return the configuration tags
    */
   public Map<String, Map<String, String>> getConfigurationTags() {
     return configurationTags;
   }
-  
+
   /**
    * @return the passive info for the cluster
    */
   public Set<Map<String, String>> getPassiveInfo() {
     return passiveInfo;
   }
-  
+
   /**
    * @param info the passive info for the cluster
    */
@@ -277,7 +280,6 @@ public class ExecutionCommand extends AgentCommand {
    * incapsulated inside command.
    */
   public static interface KeyNames {
-
     String COMMAND_TIMEOUT = "command_timeout";
     String SCRIPT = "script";
     String SCRIPT_TYPE = "script_type";
@@ -306,7 +308,6 @@ public class ExecutionCommand extends AgentCommand {
 
     String SERVICE_CHECK = "SERVICE_CHECK"; // TODO: is it standart command? maybe add it to RoleCommand enum?
     String CUSTOM_COMMAND = "custom_command";
-
   }
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/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 0dff507..1e9dc12 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
@@ -21,78 +21,80 @@ package org.apache.ambari.server.agent;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.google.gson.annotations.SerializedName;
 
 /**
  * Controller to Agent response data model.
  */
 public class HeartBeatResponse {
 
+  @SerializedName("responseId")
   private long responseId;
 
+  @SerializedName("executionCommands")
   private List<ExecutionCommand> executionCommands = new ArrayList<ExecutionCommand>();
+
+  @SerializedName("statusCommands")
   private List<StatusCommand> statusCommands = new ArrayList<StatusCommand>();
+
+  @SerializedName("cancelCommands")
   private List<CancelCommand> cancelCommands = new ArrayList<CancelCommand>();
 
   /**
    * {@link AlertDefinitionCommand}s are used to isntruct the agent as to which
-   * alert definitions it needs to schedule.
+   * alert definitions it needs to schedule. A {@code null} value here indicates
+   * that no data is to be sent and no change is required on the agent. This is
+   * different from sending an empty list where the empty list would instruct
+   * the agent to abandon all alert definitions that are scheduled.
    */
-  @JsonProperty("alertDefinitionCommands")
-  private List<AlertDefinitionCommand> alertDefinitionCommands = new ArrayList<AlertDefinitionCommand>();
-
+  @SerializedName("alertDefinitionCommands")
+  private List<AlertDefinitionCommand> alertDefinitionCommands = null;
 
+  @SerializedName("registrationCommand")
   private RegistrationCommand registrationCommand;
 
+  @SerializedName("restartAgent")
   private boolean restartAgent = false;
+
+  @SerializedName("hasMappedComponents")
   private boolean hasMappedComponents = false;
 
-  @JsonProperty("responseId")
   public long getResponseId() {
     return responseId;
   }
 
-  @JsonProperty("responseId")
   public void setResponseId(long responseId) {
     this.responseId=responseId;
   }
 
-  @JsonProperty("executionCommands")
   public List<ExecutionCommand> getExecutionCommands() {
     return executionCommands;
   }
 
-  @JsonProperty("executionCommands")
   public void setExecutionCommands(List<ExecutionCommand> executionCommands) {
     this.executionCommands = executionCommands;
   }
 
-  @JsonProperty("statusCommands")
   public List<StatusCommand> getStatusCommands() {
     return statusCommands;
   }
 
-  @JsonProperty("statusCommands")
   public void setStatusCommands(List<StatusCommand> statusCommands) {
     this.statusCommands = statusCommands;
   }
 
-  @JsonProperty("cancelCommands")
   public List<CancelCommand> getCancelCommands() {
     return cancelCommands;
   }
 
-  @JsonProperty("cancelCommands")
   public void setCancelCommands(List<CancelCommand> cancelCommands) {
     this.cancelCommands = cancelCommands;
   }
 
-  @JsonProperty("registrationCommand")
   public RegistrationCommand getRegistrationCommand() {
     return registrationCommand;
   }
 
-  @JsonProperty("registrationCommand")
   public void setRegistrationCommand(RegistrationCommand registrationCommand) {
     this.registrationCommand = registrationCommand;
   }
@@ -119,22 +121,18 @@ public class HeartBeatResponse {
     alertDefinitionCommands = commands;
   }
 
-  @JsonProperty("restartAgent")
   public boolean isRestartAgent() {
     return restartAgent;
   }
 
-  @JsonProperty("restartAgent")
   public void setRestartAgent(boolean restartAgent) {
     this.restartAgent = restartAgent;
   }
 
-  @JsonProperty("hasMappedComponents")
   public boolean hasMappedComponents() {
     return hasMappedComponents;
   }
 
-  @JsonProperty("hasMappedComponents")
   public void setHasMappedComponents(boolean hasMappedComponents) {
     this.hasMappedComponents = hasMappedComponents;
   }
@@ -152,6 +150,12 @@ public class HeartBeatResponse {
   }
 
   public void addAlertDefinitionCommand(AlertDefinitionCommand command) {
+    // commands are added here when they are taken off the queue; there should
+    // be no thread contention and thus no worry about locks for the null check
+    if (null == alertDefinitionCommands) {
+      alertDefinitionCommands = new ArrayList<AlertDefinitionCommand>();
+    }
+
     alertDefinitionCommands.add(command);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/main/java/org/apache/ambari/server/agent/NagiosAlertCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/NagiosAlertCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/NagiosAlertCommand.java
index f8e2f26..bdf9039 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/NagiosAlertCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/NagiosAlertCommand.java
@@ -21,24 +21,27 @@ import java.util.Collection;
 
 import org.apache.ambari.server.state.Alert;
 
+import com.google.gson.annotations.SerializedName;
+
 /**
- * Specialized command that updates Nagios with alert data 
+ * Specialized command that updates Nagios with alert data
  */
 public class NagiosAlertCommand extends StatusCommand {
+  @SerializedName("alerts")
   private Collection<Alert> alerts = null;
-  
+
   /**
    * @param alerts
    */
   public void setAlerts(Collection<Alert> alertData) {
     alerts = alertData;
   }
-  
+
   /**
    * @return the alerts
    */
   public Collection<Alert> getAlerts() {
     return alerts;
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
index 9ac8bed..6e08ef0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
@@ -20,8 +20,6 @@ package org.apache.ambari.server.agent;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.codehaus.jackson.annotate.JsonProperty;
-
 import com.google.gson.annotations.SerializedName;
 
 /**
@@ -33,96 +31,91 @@ public class StatusCommand extends AgentCommand {
     super(AgentCommandType.STATUS_COMMAND);
   }
 
+  @SerializedName("clusterName")
   private String clusterName;
+
+  @SerializedName("serviceName")
   private String serviceName;
+
+  @SerializedName("componentName")
   private String componentName;
+
+  @SerializedName("configurations")
   private Map<String, Map<String, String>> configurations;
+
   @SerializedName("configuration_attributes")
   private Map<String, Map<String, Map<String, String>>> configurationAttributes;
+
+  @SerializedName("commandParams")
   private Map<String, String> commandParams = new HashMap<String, String>();
+
+  @SerializedName("hostLevelParams")
   private Map<String, String> hostLevelParams = new HashMap<String, String>();
+
+  @SerializedName("hostname")
   private String hostname = null;
-  
 
-  @JsonProperty("clusterName")
   public String getClusterName() {
     return clusterName;
   }
-  
-  @JsonProperty("clusterName")
+
   public void setClusterName(String clusterName) {
     this.clusterName = clusterName;
   }
 
-  @JsonProperty("serviceName")
   public String getServiceName() {
     return serviceName;
   }
 
-  @JsonProperty("serviceName")
   public void setServiceName(String serviceName) {
     this.serviceName = serviceName;
   }
 
-  @JsonProperty("componentName")
   public String getComponentName() {
     return componentName;
   }
 
-  @JsonProperty("componentName")
   public void setComponentName(String componentName) {
     this.componentName = componentName;
   }
-  
-  @JsonProperty("configurations")
+
   public Map<String, Map<String, String>> getConfigurations() {
     return configurations;
   }
 
-  @JsonProperty("configurations")
   public void setConfigurations(Map<String, Map<String, String>> configurations) {
     this.configurations = configurations;
   }
 
-  @JsonProperty("configuration_attributes")
   public Map<String, Map<String, Map<String, String>>> getConfigurationAttributes() {
     return configurationAttributes;
   }
 
-  @JsonProperty("configuration_attributes")
   public void setConfigurationAttributes(Map<String, Map<String, Map<String, String>>> configurationAttributes) {
     this.configurationAttributes = configurationAttributes;
   }
 
-  @JsonProperty("hostLevelParams")
   public Map<String, String> getHostLevelParams() {
     return hostLevelParams;
   }
 
-  @JsonProperty("hostLevelParams")
   public void setHostLevelParams(Map<String, String> params) {
-    this.hostLevelParams = params;
+    hostLevelParams = params;
   }
 
-  @JsonProperty("commandParams")
   public Map<String, String> getCommandParams() {
     return commandParams;
   }
 
-  @JsonProperty("commandParams")
   public void setCommandParams(Map<String, String> commandParams) {
     this.commandParams = commandParams;
   }
-  
-  @JsonProperty("hostname")
+
   public void setHostname(String hostname) {
     this.hostname = hostname;
   }
 
-  @JsonProperty("hostname")
   public String getHostname() {
     return hostname;
   }
-  
-  
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/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 a639197..df6aa2d 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
@@ -271,9 +271,10 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
 
     for (Map<String, Object> requestPropMap : request.getProperties()) {
       for (Map<String, Object> propertyMap : getPropertyMaps(requestPropMap, predicate)) {
-        Long id = (Long) propertyMap.get(ALERT_DEF_ID);
+        String stringId = (String) propertyMap.get(ALERT_DEF_ID);
+        long id = Long.parseLong(stringId);
 
-        AlertDefinitionEntity entity = alertDefinitionDAO.findById(id.longValue());
+        AlertDefinitionEntity entity = alertDefinitionDAO.findById(id);
         if (null == entity) {
           continue;
         }
@@ -357,7 +358,8 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
 
     String clusterName = null;
     for (final Resource resource : resources) {
-      definitionIds.add((Long) resource.getPropertyValue(ALERT_DEF_ID));
+      Long id = (Long) resource.getPropertyValue(ALERT_DEF_ID);
+      definitionIds.add(id);
 
       if (null == clusterName) {
         clusterName = (String) resource.getPropertyValue(ALERT_DEF_CLUSTER_NAME);

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
index 3e8b15b..7855de4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertHistoryEntity.java
@@ -90,7 +90,7 @@ public class AlertHistoryEntity {
    * Unidirectional many-to-one association to {@link AlertDefinitionEntity}
    */
   @ManyToOne
-  @JoinColumn(name = "definition_id", nullable = false)
+  @JoinColumn(name = "alert_definition_id", nullable = false)
   private AlertDefinitionEntity alertDefinition;
 
   /**
@@ -101,7 +101,7 @@ public class AlertHistoryEntity {
 
   /**
    * Gets the unique ID for this alert instance.
-   * 
+   *
    * @return the unique ID (never {@code null}).
    */
   public Long getAlertId() {
@@ -110,7 +110,7 @@ public class AlertHistoryEntity {
 
   /**
    * Sets the unique ID for this alert instance.
-   * 
+   *
    * @param alertId
    *          the unique ID (not {@code null}).
    */
@@ -120,7 +120,7 @@ public class AlertHistoryEntity {
 
   /**
    * Gets the instance identifier, if any, for this alert instance.
-   * 
+   *
    * @return the instance ID or {@code null} if none.
    */
   public String getAlertInstance() {
@@ -129,7 +129,7 @@ public class AlertHistoryEntity {
 
   /**
    * Sets the instance identifier, if any, for this alert instance.
-   * 
+   *
    * @param alertInstance
    *          the instance ID or {@code null} if none.
    */
@@ -140,7 +140,7 @@ public class AlertHistoryEntity {
   /**
    * Gets the label for this alert instance. The label is typically an
    * abbreviated form of the alert text.
-   * 
+   *
    * @return the alert instance label or {@code null} if none.
    * @see #getAlertText()
    */
@@ -150,7 +150,7 @@ public class AlertHistoryEntity {
 
   /**
    * Sets the label for this alert instance.
-   * 
+   *
    * @param alertLabel
    *          the label or {@code null} if none.
    */
@@ -160,7 +160,7 @@ public class AlertHistoryEntity {
 
   /**
    * Gets the state of this alert instance.
-   * 
+   *
    * @return the alert state (never {@code null}).
    */
   public AlertState getAlertState() {
@@ -169,7 +169,7 @@ public class AlertHistoryEntity {
 
   /**
    * Sets the state of this alert instance.
-   * 
+   *
    * @param alertState
    *          the alert state (not {@code null}).
    */
@@ -179,7 +179,7 @@ public class AlertHistoryEntity {
 
   /**
    * Gets the text of the alert instance.
-   * 
+   *
    * @return the text of the alert instance or {@code null} if none.
    */
   public String getAlertText() {
@@ -188,7 +188,7 @@ public class AlertHistoryEntity {
 
   /**
    * Sets the text of the alert instance.
-   * 
+   *
    * @param alertText
    *          the text, or {@code null} if none.
    */
@@ -199,7 +199,7 @@ public class AlertHistoryEntity {
   /**
    * Gets the time that the alert instace was received. This will be the value,
    * in milliseconds, since the UNIX/Java epoch, represented in UTC time.
-   * 
+   *
    * @return the time of the alert instance (never {@code null}).
    */
   public Long getAlertTimestamp() {
@@ -209,7 +209,7 @@ public class AlertHistoryEntity {
   /**
    * Sets the time that the alert instace was received. This should be the
    * value, in milliseconds, since the UNIX/Java epoch, represented in UTC time.
-   * 
+   *
    * @param alertTimestamp
    *          the time of the alert instance (not {@code null}).
    */
@@ -219,7 +219,7 @@ public class AlertHistoryEntity {
 
   /**
    * Gets the ID of the cluster that this alert is associated with.
-   * 
+   *
    * @return the ID of the cluster for the server that this alert is for (never
    *         {@code null}).
    */
@@ -229,7 +229,7 @@ public class AlertHistoryEntity {
 
   /**
    * Sets the ID of the cluster that this alert is associated with.
-   * 
+   *
    * @param clusterId
    *          the ID of the cluster for the server that this alert is for (never
    *          {@code null}).
@@ -242,7 +242,7 @@ public class AlertHistoryEntity {
    * Gets the name of the component, if any, that this alert instance is for.
    * Some alerts, such as those that are scoped for the entire service, do not
    * have component names.
-   * 
+   *
    * @return the name of the component, or {@code null} for none.
    */
   public String getComponentName() {
@@ -254,7 +254,7 @@ public class AlertHistoryEntity {
    * Component names are not required if the alert definition is scoped for a
    * service. If specified, there is always a 1:1 mapping between alert
    * definitions and components.
-   * 
+   *
    * @param componentName
    *          the name of the component, or {@code null} if none.
    */
@@ -266,7 +266,7 @@ public class AlertHistoryEntity {
    * Gets the name of the host that the alert is for. Some alerts do not run
    * against hosts, such as aggregate alert definitions, so this may be
    * {@code null}.
-   * 
+   *
    * @return the name of the host or {@code null} if none.
    */
   public String getHostName() {
@@ -275,7 +275,7 @@ public class AlertHistoryEntity {
 
   /**
    * Sets the name of the host that the alert is for.
-   * 
+   *
    * @param hostName
    *          the name of the host or {@code null} if none.
    */
@@ -285,7 +285,7 @@ public class AlertHistoryEntity {
 
   /**
    * Gets the name of the service that the alert is defined for.
-   * 
+   *
    * @return the name of the service (never {@code null}).
    */
   public String getServiceName() {
@@ -295,7 +295,7 @@ public class AlertHistoryEntity {
   /**
    * Sets the name of the service that the alert is defined for. Every alert
    * definition is related to exactly 1 service.
-   * 
+   *
    * @param serviceName
    *          the name of the service (not {@code null}).
    */
@@ -307,7 +307,7 @@ public class AlertHistoryEntity {
    * Gets the associated alert definition for this alert instance. The alert
    * definition can be used to retrieve global information about an alert such
    * as the interval and the name.
-   * 
+   *
    * @return the alert definition (never {@code null}).
    */
   public AlertDefinitionEntity getAlertDefinition() {
@@ -316,7 +316,7 @@ public class AlertHistoryEntity {
 
   /**
    * Sets the associated alert definition for this alert instance.
-   * 
+   *
    * @param alertDefinition
    *          the alert definition (not {@code null}).
    */
@@ -329,16 +329,19 @@ public class AlertHistoryEntity {
    */
   @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;
+    }
 
     AlertHistoryEntity that = (AlertHistoryEntity) object;
 
-    if (alertId != null ? !alertId.equals(that.alertId) : that.alertId != null)
+    if (alertId != null ? !alertId.equals(that.alertId) : that.alertId != null) {
       return false;
+    }
 
     return true;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
index 7160bcf..f0f5643 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
@@ -17,14 +17,31 @@
  */
 package org.apache.ambari.server.utils;
 
-import com.google.common.base.Joiner;
-import com.google.gson.Gson;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import javax.xml.bind.JAXBException;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.ExecutionCommand;
-import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostComponentAdminState;
@@ -35,30 +52,12 @@ import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEve
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.map.JsonMappingException;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
 
-import javax.xml.bind.JAXBException;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
+import com.google.common.base.Joiner;
+import com.google.gson.Gson;
 
 public class StageUtils {
 
@@ -205,15 +204,6 @@ public class StageUtils {
     return getGson().toJson(jaxbObj);
   }
 
-  public static ExecutionCommand stringToExecutionCommand(String json)
-      throws JsonParseException, JsonMappingException, IOException {
-    ObjectMapper mapper = new ObjectMapper();
-    mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
-    mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true);
-    InputStream is = new ByteArrayInputStream(json.getBytes(Charset.forName("UTF8")));
-    return mapper.readValue(is, ExecutionCommand.class);
-  }
-
   public static <T> T fromJson(String json, Class<T> clazz) throws IOException {
     ObjectMapper mapper = new ObjectMapper();
     mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/alerts.json b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/alerts.json
new file mode 100644
index 0000000..6a06d4d
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/alerts.json
@@ -0,0 +1,58 @@
+{
+  "service": [
+    // datanode space aggregate
+    // datanode process aggregate
+  ],
+  "SECONDARY_NAMENODE": [
+    {
+      "name": "secondary_namenode_process",
+      "label": "Secondary NameNode process",
+      "interval": 1,
+      "scope": "service",
+      "source": {
+        "type": "PORT",
+        "config": "{{hdfs-site/dfs.namenode.secondary.http-address}}:50071",
+        "default": 50071
+      }
+    }
+  ],
+  "NAMENODE": [
+    // name node cpu utilization (metric)
+    {
+      "name": "namenode_cpu",
+      "label": "NameNode host CPU Utilization",
+      "scope": "host",
+      "source": {
+        "type": "METRIC",
+        "jmx": "java.lang:type=OperatingSystem/SystemCpuLoad",
+        "host": "{{hdfs-site/dfs.namenode.secondary.http-address}}"
+      }
+    },
+    // namenode process (port check)
+    {
+      "name": "namenode_process",
+      "label": "NameNode process",
+      "interval": 1,
+      "scope": "host",
+      "source": {
+        "type": "PORT",
+        "uri": "{{hdfs-site/dfs.namenode.http-address}}:50070"
+       }
+    },
+    {
+      "name": "hdfs_last_checkpoint",
+      "label": "Last Checkpoint Time",
+      "interval": 1,
+      "scope": "service",
+      "enabled": false
+      "source": {
+        "type": "SCRIPT",
+        "path": "scripts/alerts/last_checkpoint.py"
+      }
+    }
+  ],
+  "DATANODE": [
+    // datanode process (port check)
+    // datanode space
+  ]
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index b1b83fa..68cbc92 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -57,7 +57,6 @@ import org.apache.ambari.server.state.alert.AlertDefinition;
 import org.apache.ambari.server.state.stack.MetricDefinition;
 import org.apache.commons.io.FileUtils;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -1403,7 +1402,6 @@ public class AmbariMetaInfoTest {
   }
 
   @Test
-  @Ignore
   public void testAlertsJson() throws Exception {
     ServiceInfo svc = metaInfo.getService(STACK_NAME_HDP, "2.0.5", "HDFS");
     Assert.assertNotNull(svc);

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 9ca5348..d36fd70 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -35,6 +35,7 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.StringReader;
 import java.lang.reflect.Type;
 import java.net.ConnectException;
 import java.net.MalformedURLException;
@@ -4514,8 +4515,10 @@ public class AmbariManagementControllerTest {
     //Check configs not stored with execution command
     ExecutionCommandDAO executionCommandDAO = injector.getInstance(ExecutionCommandDAO.class);
     ExecutionCommandEntity commandEntity = executionCommandDAO.findByPK(task.getTaskId());
-    ExecutionCommand executionCommand =
-        StageUtils.fromJson(new String(commandEntity.getCommand()), ExecutionCommand.class);
+
+    Gson gson = new Gson();
+    ExecutionCommand executionCommand = gson.fromJson(new StringReader(
+        new String(commandEntity.getCommand())), ExecutionCommand.class);
 
     assertFalse(executionCommand.getConfigurationTags().isEmpty());
     assertTrue(executionCommand.getConfigurations() == null || executionCommand.getConfigurations().isEmpty());
@@ -10329,7 +10332,7 @@ public class AmbariManagementControllerTest {
 
     // Start
     startService(clusterName, serviceName, false, false);
-    
+
     ServiceComponentHostRequest req = new ServiceComponentHostRequest(clusterName, serviceName,
         componentName1, host1, "INSTALLED");
 
@@ -10339,24 +10342,24 @@ public class AmbariManagementControllerTest {
 
     // succeed in creating a task
     assertNotNull(resp);
-    
+
     // manually change live state to stopped as no running action manager
     for (ServiceComponentHost sch :
       clusters.getCluster(clusterName).getServiceComponentHosts(host1)) {
         sch.setState(State.INSTALLED);
     }
-    
+
     // no new commands since no targeted info
     resp = controller.updateHostComponents(Collections.singleton(req), new HashMap<String, String>(), false);
     assertNull(resp);
-    
+
     // role commands added for targeted command
     resp = controller.updateHostComponents(Collections.singleton(req), requestProperties, false);
     assertNotNull(resp);
-    
+
   }
-  
-  
+
+
 }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/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 a9826df..04d7f48 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
@@ -273,6 +273,7 @@ public class AlertDefinitionResourceProviderTest {
     Predicate p = new PredicateBuilder().property(
         AlertDefinitionResourceProvider.ALERT_DEF_ID).equals("1").and().property(
             AlertDefinitionResourceProvider.ALERT_DEF_CLUSTER_NAME).equals("c1").toPredicate();
+
     // everything is mocked, there is no DB
     entity.setDefinitionId(Long.valueOf(1));
 
@@ -285,6 +286,7 @@ public class AlertDefinitionResourceProviderTest {
     replay(dao);
 
     requestProps = new HashMap<String, Object>();
+    requestProps.put(AlertDefinitionResourceProvider.ALERT_DEF_ID, "1");
     requestProps.put(AlertDefinitionResourceProvider.ALERT_DEF_CLUSTER_NAME, "c1");
     requestProps.put(AlertDefinitionResourceProvider.ALERT_DEF_INTERVAL, "1");
     requestProps.put(AlertDefinitionResourceProvider.ALERT_DEF_NAME, "my_def1");

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java b/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
index 6e587f1..d3f0e37 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
@@ -20,9 +20,15 @@ package org.apache.ambari.server.utils;
 import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.powermock.api.easymock.PowerMock.mockStaticPartial;
+import static org.powermock.api.easymock.PowerMock.replayAll;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.UnknownHostException;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -42,8 +48,6 @@ import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
-import org.apache.ambari.server.configuration.Configuration;
-import org.apache.ambari.server.controller.HostsMap;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.state.Cluster;
@@ -57,19 +61,17 @@ import org.apache.commons.logging.LogFactory;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
 import org.junit.Before;
-import org.junit.Test;
 import org.junit.Ignore;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.powermock.core.classloader.annotations.PowerMockIgnore;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
-import static org.powermock.api.easymock.PowerMock.replayAll;
-import java.net.InetAddress;
-import static org.powermock.api.easymock.PowerMock.*;
 
 import com.google.common.collect.ContiguousSet;
 import com.google.common.collect.DiscreteDomain;
 import com.google.common.collect.Range;
+import com.google.gson.Gson;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
@@ -105,12 +107,12 @@ public class TestStageUtils {
        Injector injector) throws AmbariException {
     cl.setDesiredStackVersion(new StackId(STACK_ID));
     cl.addService(serviceName);
-    
+
     for (Entry<String, List<Integer>> component : topology.entrySet()) {
-      
+
       String componentName = component.getKey();
       cl.getService(serviceName).addServiceComponent(componentName);
-      
+
       for (Integer hostIndex : component.getValue()) {
         cl.getService(serviceName)
         .getServiceComponent(componentName)
@@ -151,14 +153,20 @@ public class TestStageUtils {
   public void testJasonToExecutionCommand() throws JsonGenerationException,
       JsonMappingException, JAXBException, IOException {
     Stage s = StageUtils.getATestStage(1, 2, "host1", "clusterHostInfo");
-    ExecutionCommand cmd = s.getExecutionCommands("host1").get(0).getExecutionCommand();    
+    ExecutionCommand cmd = s.getExecutionCommands("host1").get(0).getExecutionCommand();
     HashMap<String, Map<String,String>> configTags = new HashMap<String, Map<String,String>>();
     Map<String, String> globalTag = new HashMap<String, String>();
     globalTag.put("tag", "version1");
     configTags.put("global", globalTag );
     cmd.setConfigurationTags(configTags);
     String json = StageUtils.jaxbToString(cmd);
-    ExecutionCommand cmdDes = StageUtils.stringToExecutionCommand(json);
+
+    InputStream is = new ByteArrayInputStream(
+        json.getBytes(Charset.forName("UTF8")));
+
+    ExecutionCommand cmdDes = new Gson().fromJson(new InputStreamReader(is),
+        ExecutionCommand.class);
+
     assertEquals(cmd.toString(), cmdDes.toString());
     assertEquals(cmd, cmdDes);
   }
@@ -195,20 +203,20 @@ public class TestStageUtils {
         8672,
         null,
         8673);
-    
+
     fsm.addCluster("c1");
     fsm.getCluster("c1").setDesiredStackVersion(new StackId(STACK_ID));
-    
+
     int index = 0;
-    
+
     for (String host: hostList) {
       fsm.addHost(host);
-      
+
       Map<String, String> hostAttributes = new HashMap<String, String>();
       hostAttributes.put("os_family", "redhat");
       hostAttributes.put("os_release_version", "5.9");
       fsm.getHost(host).setHostAttributes(hostAttributes);
-      
+
       fsm.getHost(host).setCurrentPingPort(pingPorts.get(index));
       fsm.getHost(host).persist();
       fsm.mapHostToCluster(host, "c1");
@@ -222,24 +230,24 @@ public class TestStageUtils {
     List<Integer> datanodeIndexes = Arrays.asList(0,1,2,3,5,7,8,9);
     hdfsTopology.put("DATANODE", new ArrayList<Integer>(datanodeIndexes));
     addService(fsm.getCluster("c1"), hostList, hdfsTopology , "HDFS", injector);
-    
+
     //Add HBASE service
-    Map<String, List<Integer>> hbaseTopology = new HashMap<String, List<Integer>>(); 
+    Map<String, List<Integer>> hbaseTopology = new HashMap<String, List<Integer>>();
     hbaseTopology.put("HBASE_MASTER", Collections.singletonList(5));
     List<Integer> regionServiceIndexes = Arrays.asList(1,3,5,8,9);
     hbaseTopology.put("HBASE_REGIONSERVER", regionServiceIndexes);
     addService(fsm.getCluster("c1"), hostList, hbaseTopology , "HBASE", injector);
-    
+
     //Add MAPREDUCE service
-    Map<String, List<Integer>> mrTopology = new HashMap<String, List<Integer>>(); 
+    Map<String, List<Integer>> mrTopology = new HashMap<String, List<Integer>>();
     mrTopology.put("JOBTRACKER", Collections.singletonList(5));
     List<Integer> taskTrackerIndexes = Arrays.asList(1,2,3,4,5,7,9);
     mrTopology.put("TASKTRACKER", taskTrackerIndexes);
     addService(fsm.getCluster("c1"), hostList, mrTopology , "MAPREDUCE", injector);
-    
-    
+
+
     //Add NONAME service
-    Map<String, List<Integer>> nonameTopology = new HashMap<String, List<Integer>>(); 
+    Map<String, List<Integer>> nonameTopology = new HashMap<String, List<Integer>>();
     nonameTopology.put("NONAME_SERVER", Collections.singletonList(7));
     addService(fsm.getCluster("c1"), hostList, nonameTopology , "NONAME", injector);
 
@@ -259,39 +267,40 @@ public class TestStageUtils {
     for (Host host: fsm.getHosts()) {
       assertTrue(allHosts.contains(host.getHostName()));
     }
-    
-    
+
+
     //Check HDFS topology compression
     Map<String, String> hdfsMapping = new HashMap<String, String>();
     hdfsMapping.put("DATANODE", "slave_hosts");
     hdfsMapping.put("NAMENODE", "namenode_host");
     hdfsMapping.put("SECONDARY_NAMENODE", "snamenode_host");
     checkServiceCompression(info, hdfsMapping, hdfsTopology, hostList);
-    
-    
+
+
     //Check HBASE topology compression
     Map<String, String> hbaseMapping = new HashMap<String, String>();
     hbaseMapping.put("HBASE_MASTER", "hbase_master_hosts");
     hbaseMapping.put("HBASE_REGIONSERVER", "hbase_rs_hosts");
     checkServiceCompression(info, hbaseMapping, hbaseTopology, hostList);
-    
+
     //Check MAPREDUCE topology compression
     Map<String, String> mrMapping = new HashMap<String, String>();
     mrMapping.put("JOBTRACKER", "jtnode_host");
     mrMapping.put("TASKTRACKER", "mapred_tt_hosts");
     checkServiceCompression(info, mrMapping, mrTopology, hostList);
-    
+
     Set<String> actualPingPorts = info.get("all_ping_ports");
-    
-    if (pingPorts.contains(null))
+
+    if (pingPorts.contains(null)) {
       assertEquals(new HashSet<Integer>(pingPorts).size(), actualPingPorts.size() + 1);
-    else
+    } else {
       assertEquals(new HashSet<Integer>(pingPorts).size(), actualPingPorts.size());
-    
+    }
+
     List<Integer> pingPortsActual = getRangeMappedDecompressedSet(actualPingPorts);
 
     List<Integer> reindexedPorts = getReindexedList(pingPortsActual, new ArrayList<String>(allHosts), hostList);
-    
+
     //Treat null values
     while (pingPorts.contains(null)) {
       int indexOfNull = pingPorts.indexOf(null);
@@ -299,7 +308,7 @@ public class TestStageUtils {
     }
 
     assertEquals(pingPorts, reindexedPorts);
-    
+
     // check for no-name in the list
     assertTrue(info.containsKey("noname_server_hosts"));
     assertTrue(info.containsKey("decom_tt_hosts"));
@@ -316,36 +325,38 @@ public class TestStageUtils {
   private void checkServiceCompression(Map<String, Set<String>> info,
       Map<String, String> serviceMapping, Map<String, List<Integer>> serviceTopology,
       List<String> hostList) {
-    
-    
+
+
     for (Entry<String, List<Integer>> component: serviceTopology.entrySet()) {
-      
+
       String componentName = component.getKey();
-      
+
       List<Integer> componentIndexesExpected = component.getValue();
-      
+
       String roleName = serviceMapping.get(componentName);
-      
+
       assertTrue("No mapping for " + componentName , roleName != null);
-      
+
       Set<Integer> componentIndexesActual = getDecompressedSet(info.get(roleName));
-      
+
       Set<String> expectedComponentHosts = new HashSet<String>();
-      
-      for (Integer i: componentIndexesExpected)
+
+      for (Integer i: componentIndexesExpected) {
         expectedComponentHosts.add(hostList.get(i));
-      
+      }
+
       Set<String> actualSlavesHosts = new HashSet<String>();
-      
-      for (Integer i: componentIndexesActual)
+
+      for (Integer i: componentIndexesActual) {
         actualSlavesHosts.add(new ArrayList<String>(info.get(HOSTS_LIST)).get(i));
-        
-      
-      
+      }
+
+
+
       assertEquals(expectedComponentHosts, actualSlavesHosts);
-    
+
     }
-    
+
   }
 
   private Set<Integer> getDecompressedSet(Set<String> set) {
@@ -379,7 +390,7 @@ public class TestStageUtils {
     }
     return resultSet;
   }
-  
+
   private List<Integer> getRangeMappedDecompressedSet(Set<String> compressedSet) {
 
     SortedMap<Integer, Integer> resultMap = new TreeMap<Integer, Integer>();
@@ -388,9 +399,10 @@ public class TestStageUtils {
 
       String[] split = token.split(":");
 
-      if (split.length != 2)
+      if (split.length != 2) {
         throw new RuntimeException("Broken data, expected format - m:r, got - "
             + token);
+      }
 
       Integer index = Integer.valueOf(split[0]);
 
@@ -401,8 +413,9 @@ public class TestStageUtils {
 
       Set<Integer> decompressedSet = getDecompressedSet(rangeTokensSet);
 
-      for (Integer i : decompressedSet)
+      for (Integer i : decompressedSet) {
         resultMap.put(i, index);
+      }
 
     }
 
@@ -411,7 +424,7 @@ public class TestStageUtils {
     return resultList;
 
   }
-  
+
   private List<Integer> getReindexedList(List<Integer> list,
       List<String> currentIndexes, List<String> desiredIndexes) {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/09edccfc/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/alerts.json b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/alerts.json
new file mode 100644
index 0000000..85aa3ab
--- /dev/null
+++ b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/HDFS/alerts.json
@@ -0,0 +1,51 @@
+{
+  "service": [
+  ],
+  "SECONDARY_NAMENODE": [
+    {
+      "name": "secondary_namenode_process",
+      "label": "Secondary NameNode process",
+      "interval": 1,
+      "scope": "service",
+      "source": {
+        "type": "PORT",
+        "config": "{{hdfs-site/dfs.namenode.secondary.http-address}}:50071"
+      }
+    }
+  ],
+  "NAMENODE": [
+    {
+      "name": "namenode_cpu",
+      "label": "NameNode host CPU Utilization",
+      "scope": "host",
+      "source": {
+        "type": "METRIC",
+        "jmx": "java.lang:type=OperatingSystem/SystemCpuLoad",
+        "host": "{{hdfs-site/dfs.namenode.secondary.http-address}}"
+      }
+    },
+    {
+      "name": "namenode_process",
+      "label": "NameNode process",
+      "interval": 1,
+      "scope": "host",
+      "source": {
+        "type": "PORT",
+        "uri": "{{hdfs-site/dfs.namenode.http-address}}:50070"
+       }
+    },
+    {
+      "name": "hdfs_last_checkpoint",
+      "label": "Last Checkpoint Time",
+      "interval": 1,
+      "scope": "service",
+      "enabled": false,
+      "source": {
+        "type": "SCRIPT",
+        "path": "scripts/alerts/last_checkpoint.py"
+      }
+    }
+  ],
+  "DATANODE": [
+  ]
+}