You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2015/09/11 14:05:36 UTC

[1/2] ambari git commit: AMBARI-13059 Alerts: HDFS Finalized alert needs to be for HDFS service (dlysnichenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 219501f82 -> 13b9f0f45
  refs/heads/trunk 36c135c29 -> f41ed7f1e


AMBARI-13059 Alerts: HDFS Finalized alert needs to be for HDFS service (dlysnichenko)


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

Branch: refs/heads/branch-2.1
Commit: 13b9f0f45119ed73a55834f0f7d354e9612ee230
Parents: 219501f
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Fri Sep 11 15:05:01 2015 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Fri Sep 11 15:05:01 2015 +0300

----------------------------------------------------------------------
 .../HDFSUpgradeFinalizedStatusRunnable.java     | 215 --------------
 ambari-server/src/main/resources/alerts.json    |  12 -
 .../common-services/HDFS/2.1.0.2.0/alerts.json  |  13 +
 .../package/alerts/alert_upgrade_finalized.py   | 171 +++++++++++
 .../HDFSUpgradeFinalizedStatusRunnableTest.java | 294 -------------------
 .../server/api/services/AmbariMetaInfoTest.java |  14 +-
 .../metadata/AgentAlertDefinitionsTest.java     |   2 +-
 7 files changed, 192 insertions(+), 529 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/13b9f0f4/ambari-server/src/main/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnable.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnable.java b/ambari-server/src/main/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnable.java
deleted file mode 100644
index b5da9df..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnable.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.alerts;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.ServiceNotFoundException;
-import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
-import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
-import org.apache.ambari.server.controller.utilities.PredicateBuilder;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.events.AlertEvent;
-import org.apache.ambari.server.events.AlertReceivedEvent;
-import org.apache.ambari.server.events.publishers.AlertEventPublisher;
-import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
-import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
-import org.apache.ambari.server.state.Alert;
-import org.apache.ambari.server.state.AlertState;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.services.AmbariServerAlertService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * The {@link HDFSUpgradeFinalizedStatusRunnable} is used by the
- * {@link AmbariServerAlertService} to check hdfs finalized status
- */
-public class HDFSUpgradeFinalizedStatusRunnable implements Runnable
-{
-  /**
-   * Logger.
-   */
-  private final static Logger LOG = LoggerFactory.getLogger(AgentHeartbeatAlertRunnable.class);
-  /**
-   * String constants
-   */
-  private final static String s_serviceName = "HDFS";
-  private final static String s_serviceComponent = "NAMENODE";
-  private final static String s_upgradeFinalizedMetricProperty = "UpgradeFinalized";
-  private final static String s_alertText = "HDFS cluster is not in the upgrade state";
-  private final static String s_alertCriticalText = "HDFS cluster is not finalized";
-  private final static String s_alertUnknownText = "HDFS cluster is in the unknown state";
-  /**
-   * The unique name for the alert definition that governs this service.
-   */
-  private static final String ALERT_DEFINITION_NAME = "ambari_upgrade_finalized_state";
-  /**
-   * Used for looking up alert definitions.
-   */
-  @Inject
-  private AlertDefinitionDAO m_dao;
-  /**
-   * Used to get alert definitions to use when generating alert instances.
-   */
-  @Inject
-  private Provider<Clusters> m_clustersProvider;
-  /**
-   * Publishes {@link AlertEvent} instances.
-   */
-  @Inject
-  private AlertEventPublisher m_alertEventPublisher;
-
-  /**
-   * Represent possibly HDFS upgrade finalization states
-   */
-  private enum HDFSFinalizationState {
-    /**
-     * HDFS is not in the upgrade state
-     */
-    FINALIZED,
-    /**
-     * HDFS currently in the upgrade state
-     */
-    NOT_FINALIZED,
-    /**
-     * Undetermined stated, probably service is turned off and no metric available
-     */
-    UNKNOWN
-  }
-
-  public HDFSUpgradeFinalizedStatusRunnable(){
-  }
-
-  @Override
-  public void run(){
-    try {
-      Map<String, Cluster> clusterMap = m_clustersProvider.get().getClusters();
-
-      for (Cluster cluster : clusterMap.values()) {
-        AlertDefinitionEntity entity = m_dao.findByName(cluster.getClusterId(), ALERT_DEFINITION_NAME);
-
-        // skip this cluster if the runnable's alert definition is missing or disabled
-        if (null == entity || !entity.getEnabled()) {
-          continue;
-        }
-
-        // check if the service existed
-        try {
-          cluster.getService(s_serviceName);
-        } catch (ServiceNotFoundException e){
-          continue;
-        }
-
-        Date current = new Date(System.currentTimeMillis());
-        HDFSFinalizationState upgradeFinalized = getUpgradeFinalizedProperty(cluster);
-
-        AlertState alertState;
-        String alertDescription;
-
-        if (upgradeFinalized == HDFSFinalizationState.UNKNOWN) {
-          alertState = AlertState.UNKNOWN;
-          alertDescription = s_alertUnknownText;
-        } else if (upgradeFinalized == HDFSFinalizationState.FINALIZED){
-          alertState = AlertState.OK;
-          alertDescription = s_alertText;
-        } else {
-          alertState = AlertState.CRITICAL;
-          alertDescription = s_alertCriticalText;
-        }
-
-        Alert alert = new Alert(entity.getDefinitionName(), null,
-          entity.getServiceName(), entity.getComponentName(), null, alertState);
-
-        alert.setLabel(entity.getLabel());
-        alert.setText(alertDescription);
-        alert.setTimestamp(current.getTime());
-        alert.setCluster(cluster.getClusterName());
-        AlertReceivedEvent event = new AlertReceivedEvent(cluster.getClusterId(), alert);
-        m_alertEventPublisher.publish(event);
-      }
-    } catch (Exception e){
-      LOG.error("Unable to run the {} alert", ALERT_DEFINITION_NAME, e);
-    }
-  }
-
-  /**
-   * Query {@link ComponentResourceProvider} for the HDFS finalization status
-   * @param cluster the cluster for the query
-   * @return HDFS finalization status flag
-   * @throws AmbariException
-   */
-  private HDFSFinalizationState getUpgradeFinalizedProperty(Cluster cluster) throws AmbariException{
-  try
-    {
-      ComponentResourceProvider crp = (ComponentResourceProvider) ClusterControllerHelper
-        .getClusterController().ensureResourceProvider(Resource.Type.Component);
-
-      Set<String> properties = new HashSet<String>();
-      properties.add("ServiceComponentInfo/" + s_upgradeFinalizedMetricProperty);
-      Request request = PropertyHelper.getReadRequest(properties);
-      PredicateBuilder pb = new PredicateBuilder();
-
-      Predicate predicate =  pb.begin()
-        .property("ServiceComponentInfo/service_name").equals(s_serviceName)
-        .and()
-        .property("ServiceComponentInfo/component_name").equals(s_serviceComponent)
-        .and()
-        .property("ServiceComponentInfo/cluster_name").equals(cluster.getClusterName())
-        .end().toPredicate();
-
-      Set<Resource> res =  ClusterControllerHelper.getClusterController().populateResources(
-                   Resource.Type.Component,
-                   crp.getResources(request, predicate),
-                   request,
-                   predicate);
-
-      for (Resource rr: res){
-        for (Map<String, Object> t: rr.getPropertiesMap().values()){
-          if (t.containsKey(s_upgradeFinalizedMetricProperty) &&
-              t.get(s_upgradeFinalizedMetricProperty) instanceof Boolean) {
-
-            if ((Boolean)t.get(s_upgradeFinalizedMetricProperty)){
-              return HDFSFinalizationState.FINALIZED;
-            } else {
-              return HDFSFinalizationState.NOT_FINALIZED;
-            }
-          }
-        }
-      }
-    } catch (SystemException|UnsupportedPropertyException|NoSuchParentResourceException|NoSuchResourceException e) {
-      LOG.error("Unable to run the {} alert", ALERT_DEFINITION_NAME, e);
-    }
-    // no metric available
-    return HDFSFinalizationState.UNKNOWN;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/13b9f0f4/ambari-server/src/main/resources/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/alerts.json b/ambari-server/src/main/resources/alerts.json
index 1285b24..6a50223 100644
--- a/ambari-server/src/main/resources/alerts.json
+++ b/ambari-server/src/main/resources/alerts.json
@@ -26,18 +26,6 @@
           "type": "SERVER",
           "class": "org.apache.ambari.server.alerts.StaleAlertRunnable"
         }
-      },
-      {
-        "name": "ambari_upgrade_finalized_state",
-        "label": "HDFS Upgrade Finalized State",
-        "description": "This service-level alert is triggered if HDFS is not in the finalized state",
-        "interval": 10,
-        "scope": "SERVICE",
-        "enabled": true,
-        "source": {
-          "type": "SERVER",
-          "class": "org.apache.ambari.server.alerts.HDFSUpgradeFinalizedStatusRunnable"
-        }
       }
     ],
     "AMBARI_AGENT" : [

http://git-wip-us.apache.org/repos/asf/ambari/blob/13b9f0f4/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json
index 1310ce8..2fcacc8 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json
@@ -116,6 +116,19 @@
         }
       },
       {
+        "name": "upgrade_finalized_state",
+        "label": "HDFS Upgrade Finalized State",
+        "description": "This service-level alert is triggered if HDFS is not in the finalized state",
+        "interval": 1,
+        "scope": "SERVICE",
+        "enabled": true,
+        "source": {
+          "type": "SCRIPT",
+          "path": "HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py",
+          "parameters": []
+        }
+      },
+      {
         "name": "namenode_cpu",
         "label": "NameNode Host CPU Utilization",
         "description": "This host-level alert is triggered if CPU utilization of the NameNode exceeds certain warning and critical thresholds. It checks the NameNode JMX Servlet for the SystemCPULoad property. The threshold values are in percent.",

http://git-wip-us.apache.org/repos/asf/ambari/blob/13b9f0f4/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py
new file mode 100644
index 0000000..be72327
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py
@@ -0,0 +1,171 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import urllib2
+import ambari_simplejson as json # simplejson is much faster comparing to Python 2.6 json module and has the same functions set.
+import logging
+
+from resource_management.libraries.functions.curl_krb_request import curl_krb_request, CONNECTION_TIMEOUT_DEFAULT
+from resource_management.core.environment import Environment
+
+NN_HTTP_ADDRESS_KEY = '{{hdfs-site/dfs.namenode.http-address}}'
+NN_HTTPS_ADDRESS_KEY = '{{hdfs-site/dfs.namenode.https-address}}'
+NN_HTTP_POLICY_KEY = '{{hdfs-site/dfs.http.policy}}'
+
+KERBEROS_KEYTAB = '{{hdfs-site/dfs.web.authentication.kerberos.keytab}}'
+KERBEROS_PRINCIPAL = '{{hdfs-site/dfs.web.authentication.kerberos.principal}}'
+SECURITY_ENABLED_KEY = '{{cluster-env/security_enabled}}'
+SMOKEUSER_KEY = "{{cluster-env/smokeuser}}"
+EXECUTABLE_SEARCH_PATHS = '{{kerberos-env/executable_search_paths}}'
+
+logger = logging.getLogger()
+
+def get_tokens():
+  """
+  Returns a tuple of tokens in the format {{site/property}} that will be used
+  to build the dictionary passed into execute
+
+  :rtype tuple
+  """
+  return (NN_HTTP_ADDRESS_KEY, NN_HTTPS_ADDRESS_KEY, NN_HTTP_POLICY_KEY, EXECUTABLE_SEARCH_PATHS,
+          KERBEROS_KEYTAB, KERBEROS_PRINCIPAL, SECURITY_ENABLED_KEY, SMOKEUSER_KEY)
+
+
+def execute(configurations={}, parameters={}, host_name=None):
+  """
+  Returns a tuple containing the result code and a pre-formatted result label
+
+  Keyword arguments:
+  configurations : a mapping of configuration key to value
+  parameters : a mapping of script parameter key to value
+  host_name : the name of this host where the alert is running
+
+  :type configurations dict
+  :type parameters dict
+  :type host_name str
+  """
+
+  if configurations is None:
+    return (('UNKNOWN', ['There were no configurations supplied to the script.']))
+
+  uri = None
+  scheme = 'http'
+  http_uri = None
+  https_uri = None
+  http_policy = 'HTTP_ONLY'
+
+  if NN_HTTP_ADDRESS_KEY in configurations:
+    http_uri = configurations[NN_HTTP_ADDRESS_KEY]
+
+  if NN_HTTPS_ADDRESS_KEY in configurations:
+    https_uri = configurations[NN_HTTPS_ADDRESS_KEY]
+
+  if NN_HTTP_POLICY_KEY in configurations:
+    http_policy = configurations[NN_HTTP_POLICY_KEY]
+
+  if SMOKEUSER_KEY in configurations:
+    smokeuser = configurations[SMOKEUSER_KEY]
+
+  executable_paths = None
+  if EXECUTABLE_SEARCH_PATHS in configurations:
+    executable_paths = configurations[EXECUTABLE_SEARCH_PATHS]
+
+  security_enabled = False
+  if SECURITY_ENABLED_KEY in configurations:
+    security_enabled = str(configurations[SECURITY_ENABLED_KEY]).upper() == 'TRUE'
+
+  kerberos_keytab = None
+  if KERBEROS_KEYTAB in configurations:
+    kerberos_keytab = configurations[KERBEROS_KEYTAB]
+
+  kerberos_principal = None
+  if KERBEROS_PRINCIPAL in configurations:
+    kerberos_principal = configurations[KERBEROS_PRINCIPAL]
+    kerberos_principal = kerberos_principal.replace('_HOST', host_name)
+
+  # determine the right URI and whether to use SSL
+  uri = http_uri
+  if http_policy == 'HTTPS_ONLY':
+    scheme = 'https'
+
+    if https_uri is not None:
+      uri = https_uri
+
+  upgrade_finalized_qry = "{0}://{1}/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo".format(scheme, uri)
+
+  # start out assuming an OK status
+  label = None
+  result_code = "OK"
+
+  try:
+    if kerberos_principal is not None and kerberos_keytab is not None and security_enabled:
+      env = Environment.get_instance()
+
+      last_checkpoint_time_response, error_msg, time_millis = curl_krb_request(
+        env.tmp_dir, kerberos_keytab,
+        kerberos_principal, upgrade_finalized_qry, "upgrade_finalized_state", executable_paths, False,
+        "HDFS Upgrade Finalized State", smokeuser
+       )
+
+      upgrade_finalized_response_json = json.loads(last_checkpoint_time_response)
+      upgrade_finalized = bool(upgrade_finalized_response_json["beans"][0]["UpgradeFinalized"])
+
+    else:
+      upgrade_finalized = bool(get_value_from_jmx(upgrade_finalized_qry,
+                                                    "UpgradeFinalized"))
+
+    if upgrade_finalized:
+      label = "HDFS cluster is not in the upgrade state"
+      result_code = 'OK'
+    else:
+      label = "HDFS cluster is not finalized"
+      result_code = 'CRITICAL'
+
+  except Exception, e:
+    label = str(e)
+    result_code = 'UNKNOWN'
+
+  return ((result_code, [label]))
+
+def get_value_from_jmx(query, jmx_property):
+  """
+   Read property from the jxm endpoint
+
+  :param query: jmx uri path
+  :param jmx_property: property name to read
+  :return: jmx property value
+  
+  :type query str
+  :type jmx_property str
+  """
+  response = None
+
+  try:
+    response = urllib2.urlopen(query, timeout=int(CONNECTION_TIMEOUT_DEFAULT))
+    data = response.read()
+
+    data_dict = json.loads(data)
+    return data_dict["beans"][0][jmx_property]
+  finally:
+    if response is not None:
+      try:
+        response.close()
+      except:
+        pass

http://git-wip-us.apache.org/repos/asf/ambari/blob/13b9f0f4/ambari-server/src/test/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnableTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnableTest.java b/ambari-server/src/test/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnableTest.java
deleted file mode 100644
index df9834f..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnableTest.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.server.alerts;
-
-import static junit.framework.Assert.assertEquals;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.persistence.EntityManager;
-
-import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
-import org.apache.ambari.server.controller.internal.ResourceImpl;
-import org.apache.ambari.server.controller.spi.ClusterController;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
-import org.apache.ambari.server.events.AlertEvent;
-import org.apache.ambari.server.events.AlertReceivedEvent;
-import org.apache.ambari.server.events.MockEventListener;
-import org.apache.ambari.server.events.publishers.AlertEventPublisher;
-import org.apache.ambari.server.orm.DBAccessor;
-import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
-import org.apache.ambari.server.orm.dao.AlertsDAO;
-import org.apache.ambari.server.orm.entities.AlertCurrentEntity;
-import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
-import org.apache.ambari.server.state.Alert;
-import org.apache.ambari.server.state.AlertState;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.stack.OsFamily;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.eventbus.EventBus;
-import com.google.inject.Binder;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-/**
- * Tests {@link StaleAlertRunnableTest}.
- */
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(ClusterControllerHelper.class)
-public class HDFSUpgradeFinalizedStatusRunnableTest {
-
-  private final static long CLUSTER_ID = 1;
-  private final static String CLUSTER_NAME = "c1";
-
-  private final static String DEFINITION_NAME = "ambari_upgrade_finalized_state";
-  private final static String DEFINITION_SERVICE = "AMBARI";
-  private final static String DEFINITION_COMPONENT = "AMBARI_SERVER";
-  private final static String DEFINITION_LABEL = "Mock Definition";
-  private final static String s_upgradeFinalizedMetricProperty = "UpgradeFinalized";
-  private final static int DEFINITION_INTERVAL = 1;
-
-  private Clusters m_clusters;
-  private Cluster m_cluster;
-  private Injector m_injector;
-  private AlertsDAO m_alertsDao;
-  private AlertDefinitionDAO m_definitionDao;
-  private AlertDefinitionEntity m_definition;
-  private List<AlertCurrentEntity> m_currentAlerts = new ArrayList<AlertCurrentEntity>();
-  private MockEventListener m_listener;
-
-  private AlertEventPublisher m_eventPublisher;
-  private EventBus m_synchronizedBus;
-
-  /**
-   *
-   */
-  @Before
-  public void setup() throws Exception {
-    m_injector = Guice.createInjector(new MockModule());
-    m_alertsDao = m_injector.getInstance(AlertsDAO.class);
-    m_definitionDao = m_injector.getInstance(AlertDefinitionDAO.class);
-    m_clusters = m_injector.getInstance(Clusters.class);
-    m_cluster = m_injector.getInstance(Cluster.class);
-    m_eventPublisher = m_injector.getInstance(AlertEventPublisher.class);
-    m_listener = m_injector.getInstance(MockEventListener.class);
-    m_definition = EasyMock.createNiceMock(AlertDefinitionEntity.class);
-
-    // !!! need a synchronous op for testing
-    m_synchronizedBus = new EventBus();
-    Field field = AlertEventPublisher.class.getDeclaredField("m_eventBus");
-    field.setAccessible(true);
-    field.set(m_eventPublisher, m_synchronizedBus);
-
-    // register mock listener
-    m_synchronizedBus.register(m_listener);
-
-    // create the cluster map
-    Map<String,Cluster> clusterMap = new HashMap<String, Cluster>();
-    clusterMap.put(CLUSTER_NAME, m_cluster);
-
-    // mock the definition for the alert
-    expect(m_definition.getDefinitionName()).andReturn(DEFINITION_NAME).atLeastOnce();
-    expect(m_definition.getServiceName()).andReturn(DEFINITION_SERVICE).atLeastOnce();
-    expect(m_definition.getComponentName()).andReturn(DEFINITION_COMPONENT).atLeastOnce();
-    expect(m_definition.getLabel()).andReturn(DEFINITION_LABEL).atLeastOnce();
-    expect(m_definition.getEnabled()).andReturn(true).atLeastOnce();
-    expect(m_definition.getScheduleInterval()).andReturn(DEFINITION_INTERVAL).atLeastOnce();
-
-    // mock the cluster
-    expect(m_cluster.getClusterId()).andReturn(CLUSTER_ID).atLeastOnce();
-
-    // mock clusters
-    expect(m_clusters.getClusters()).andReturn(clusterMap).atLeastOnce();
-
-    // mock the definition DAO
-    expect(m_definitionDao.findByName(CLUSTER_ID, DEFINITION_NAME)).andReturn(
-      m_definition).atLeastOnce();
-
-    // mock the current dao
-    expect(m_alertsDao.findCurrentByCluster(CLUSTER_ID)).andReturn(
-      m_currentAlerts).atLeastOnce();
-
-    replay(m_definition, m_cluster, m_clusters,
-      m_definitionDao, m_alertsDao);
-  }
-
-  /**
-   * @throws Exception
-   */
-  @After
-  public void teardown() throws Exception {
-  }
-
-  /**
-   * Tests that the event is triggered with a status of OK.
-   */
-  @Test
-  @SuppressWarnings("unchecked")
-  public void testFinalizedState() throws SystemException {
-
-    // create current alerts that are not stale
-    Resource resource = new ResourceImpl(Resource.Type.Component);
-    resource.setProperty(s_upgradeFinalizedMetricProperty, Boolean.TRUE);
-
-    ClusterController clusterController = createNiceMock(ClusterController.class);
-    ComponentResourceProvider crp = createNiceMock(ComponentResourceProvider.class);
-
-
-    Set<Resource> resourceMap = new HashSet<Resource>();
-    resourceMap.add(resource);
-
-    PowerMock.mockStatic(ClusterControllerHelper.class);
-    expect(ClusterControllerHelper.getClusterController()).andReturn(clusterController).atLeastOnce();
-    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(crp).atLeastOnce();
-    expect(clusterController.populateResources(anyObject(Resource.Type.class),
-      anyObject(resourceMap.getClass()), anyObject(Request.class), anyObject(Predicate.class))).andReturn(resourceMap).atLeastOnce();
-
-    PowerMock.replay(ClusterControllerHelper.class);
-    replay(crp, clusterController);
-
-
-    // precondition that no events were fired
-    assertEquals(0,
-      m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));
-
-    // instantiate and inject mocks
-    HDFSUpgradeFinalizedStatusRunnable runnable = new HDFSUpgradeFinalizedStatusRunnable();
-    m_injector.injectMembers(runnable);
-
-    // run the alert
-    runnable.run();
-
-    assertEquals(1,
-      m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));
-
-    List<AlertEvent> events = m_listener.getAlertEventInstances(AlertReceivedEvent.class);
-    assertEquals(1, events.size());
-
-    AlertReceivedEvent event = (AlertReceivedEvent) events.get(0);
-    Alert alert = event.getAlert();
-    assertEquals("AMBARI", alert.getService());
-    assertEquals("AMBARI_SERVER", alert.getComponent());
-    assertEquals(AlertState.OK, alert.getState());
-    assertEquals(DEFINITION_NAME, alert.getName());
-
-    verify(m_cluster, m_clusters, m_definitionDao);
-  }
-
-  /**
-   * Tests that a alert triggers the event with a status of CRITICAL.
-   */
-  @Test
-  @SuppressWarnings("unchecked")
-  public void testNonFinalizedState() throws SystemException {
-
-    // create current alerts that are not stale
-    Resource resource = new ResourceImpl(Resource.Type.Component);
-    resource.setProperty(s_upgradeFinalizedMetricProperty, Boolean.FALSE);
-
-    ClusterController clusterController = createNiceMock(ClusterController.class);
-    ComponentResourceProvider crp = createNiceMock(ComponentResourceProvider.class);
-
-
-    Set<Resource> resourceMap = new HashSet<Resource>();
-    resourceMap.add(resource);
-
-    PowerMock.mockStatic(ClusterControllerHelper.class);
-    expect(ClusterControllerHelper.getClusterController()).andReturn(clusterController).atLeastOnce();
-    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(crp).atLeastOnce();
-    expect(clusterController.populateResources(anyObject(Resource.Type.class),
-      anyObject(resourceMap.getClass()), anyObject(Request.class), anyObject(Predicate.class))).andReturn(resourceMap).atLeastOnce();
-
-    PowerMock.replay(ClusterControllerHelper.class);
-    replay(crp, clusterController);
-
-
-    // precondition that no events were fired
-    assertEquals(0,
-      m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));
-
-    // instantiate and inject mocks
-    HDFSUpgradeFinalizedStatusRunnable runnable = new HDFSUpgradeFinalizedStatusRunnable();
-    m_injector.injectMembers(runnable);
-
-    // run the alert
-    runnable.run();
-
-    assertEquals(1,
-      m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));
-
-    List<AlertEvent> events = m_listener.getAlertEventInstances(AlertReceivedEvent.class);
-    assertEquals(1, events.size());
-
-    AlertReceivedEvent event = (AlertReceivedEvent) events.get(0);
-    Alert alert = event.getAlert();
-    assertEquals("AMBARI", alert.getService());
-    assertEquals("AMBARI_SERVER", alert.getComponent());
-    assertEquals(AlertState.CRITICAL, alert.getState());
-    assertEquals(DEFINITION_NAME, alert.getName());
-
-    verify(m_cluster, m_clusters, m_definitionDao);
-  }
-
-  /**
-   *
-   */
-  private class MockModule implements Module {
-    /**
-     *
-     */
-    @Override
-    public void configure(Binder binder) {
-      Cluster cluster = EasyMock.createNiceMock(Cluster.class);
-
-      binder.bind(Clusters.class).toInstance(createNiceMock(Clusters.class));
-      binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
-      binder.bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
-      binder.bind(Cluster.class).toInstance(cluster);
-      binder.bind(AlertDefinitionDAO.class).toInstance(createNiceMock(AlertDefinitionDAO.class));
-      binder.bind(AlertsDAO.class).toInstance(createNiceMock(AlertsDAO.class));
-      binder.bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/13b9f0f4/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 86ff0c9..14c66a2 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
@@ -1736,7 +1736,7 @@ public class AmbariMetaInfoTest {
 
     AlertDefinitionDAO dao = injector.getInstance(AlertDefinitionDAO.class);
     List<AlertDefinitionEntity> definitions = dao.findAll(clusterId);
-    assertEquals(10, definitions.size());
+    assertEquals(9, definitions.size());
 
     // figure out how many of these alerts were merged into from the
     // non-stack alerts.json
@@ -1749,7 +1749,7 @@ public class AmbariMetaInfoTest {
     }
 
     assertEquals(1, hostAlertCount);
-    assertEquals(9, definitions.size() - hostAlertCount);
+    assertEquals(8, definitions.size() - hostAlertCount);
 
     for (AlertDefinitionEntity definition : definitions) {
       definition.setScheduleInterval(28);
@@ -1759,7 +1759,7 @@ public class AmbariMetaInfoTest {
     metaInfo.reconcileAlertDefinitions(clusters);
 
     definitions = dao.findAll();
-    assertEquals(10, definitions.size());
+    assertEquals(9, definitions.size());
 
     for (AlertDefinitionEntity definition : definitions) {
       assertEquals(28, definition.getScheduleInterval().intValue());
@@ -1768,7 +1768,7 @@ public class AmbariMetaInfoTest {
     // find all enabled for the cluster should find 6 (the ones from HDFS;
     // it will not find the agent alert since it's not bound to the cluster)
     definitions = dao.findAllEnabled(cluster.getClusterId());
-    assertEquals(9, definitions.size());
+    assertEquals(8, definitions.size());
 
     // create new definition
     AlertDefinitionEntity entity = new AlertDefinitionEntity();
@@ -1787,19 +1787,19 @@ public class AmbariMetaInfoTest {
 
     // verify the new definition is found (6 HDFS + 1 new one)
     definitions = dao.findAllEnabled(cluster.getClusterId());
-    assertEquals(10, definitions.size());
+    assertEquals(9, definitions.size());
 
     // reconcile, which should disable our bad definition
     metaInfo.reconcileAlertDefinitions(clusters);
 
     // find all enabled for the cluster should find 6
     definitions = dao.findAllEnabled(cluster.getClusterId());
-    assertEquals(9, definitions.size());
+    assertEquals(8, definitions.size());
 
     // find all should find 6 HDFS + 1 disabled + 1 agent alert + 2 server
     // alerts
     definitions = dao.findAll();
-    assertEquals(11, definitions.size());
+    assertEquals(10, definitions.size());
 
     entity = dao.findById(entity.getDefinitionId());
     assertFalse(entity.getEnabled());

http://git-wip-us.apache.org/repos/asf/ambari/blob/13b9f0f4/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
index 80ab0fe..9d58b94 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
@@ -66,7 +66,7 @@ public class AgentAlertDefinitionsTest {
   public void testLoadingServertAlerts() {
     AmbariServiceAlertDefinitions ambariServiceAlertDefinitions = m_injector.getInstance(AmbariServiceAlertDefinitions.class);
     List<AlertDefinition> definitions = ambariServiceAlertDefinitions.getServerDefinitions();
-    Assert.assertEquals(3, definitions.size());
+    Assert.assertEquals(2, definitions.size());
 
     for (AlertDefinition definition : definitions) {
       Assert.assertEquals(Components.AMBARI_SERVER.name(),


[2/2] ambari git commit: AMBARI-13059 Alerts: HDFS Finalized alert needs to be for HDFS service (dlysnichenko)

Posted by dm...@apache.org.
AMBARI-13059 Alerts: HDFS Finalized alert needs to be for HDFS service (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: f41ed7f1e67b21b4463d4330da8ed8090f222e29
Parents: 36c135c
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Fri Sep 11 15:05:01 2015 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Fri Sep 11 15:06:02 2015 +0300

----------------------------------------------------------------------
 .../HDFSUpgradeFinalizedStatusRunnable.java     | 215 --------------
 ambari-server/src/main/resources/alerts.json    |  12 -
 .../common-services/HDFS/2.1.0.2.0/alerts.json  |  13 +
 .../package/alerts/alert_upgrade_finalized.py   | 171 +++++++++++
 .../HDFSUpgradeFinalizedStatusRunnableTest.java | 294 -------------------
 .../server/api/services/AmbariMetaInfoTest.java |  14 +-
 .../metadata/AgentAlertDefinitionsTest.java     |   2 +-
 7 files changed, 192 insertions(+), 529 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f41ed7f1/ambari-server/src/main/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnable.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnable.java b/ambari-server/src/main/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnable.java
deleted file mode 100644
index b5da9df..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnable.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.alerts;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.ServiceNotFoundException;
-import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
-import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
-import org.apache.ambari.server.controller.utilities.PredicateBuilder;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.events.AlertEvent;
-import org.apache.ambari.server.events.AlertReceivedEvent;
-import org.apache.ambari.server.events.publishers.AlertEventPublisher;
-import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
-import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
-import org.apache.ambari.server.state.Alert;
-import org.apache.ambari.server.state.AlertState;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.services.AmbariServerAlertService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * The {@link HDFSUpgradeFinalizedStatusRunnable} is used by the
- * {@link AmbariServerAlertService} to check hdfs finalized status
- */
-public class HDFSUpgradeFinalizedStatusRunnable implements Runnable
-{
-  /**
-   * Logger.
-   */
-  private final static Logger LOG = LoggerFactory.getLogger(AgentHeartbeatAlertRunnable.class);
-  /**
-   * String constants
-   */
-  private final static String s_serviceName = "HDFS";
-  private final static String s_serviceComponent = "NAMENODE";
-  private final static String s_upgradeFinalizedMetricProperty = "UpgradeFinalized";
-  private final static String s_alertText = "HDFS cluster is not in the upgrade state";
-  private final static String s_alertCriticalText = "HDFS cluster is not finalized";
-  private final static String s_alertUnknownText = "HDFS cluster is in the unknown state";
-  /**
-   * The unique name for the alert definition that governs this service.
-   */
-  private static final String ALERT_DEFINITION_NAME = "ambari_upgrade_finalized_state";
-  /**
-   * Used for looking up alert definitions.
-   */
-  @Inject
-  private AlertDefinitionDAO m_dao;
-  /**
-   * Used to get alert definitions to use when generating alert instances.
-   */
-  @Inject
-  private Provider<Clusters> m_clustersProvider;
-  /**
-   * Publishes {@link AlertEvent} instances.
-   */
-  @Inject
-  private AlertEventPublisher m_alertEventPublisher;
-
-  /**
-   * Represent possibly HDFS upgrade finalization states
-   */
-  private enum HDFSFinalizationState {
-    /**
-     * HDFS is not in the upgrade state
-     */
-    FINALIZED,
-    /**
-     * HDFS currently in the upgrade state
-     */
-    NOT_FINALIZED,
-    /**
-     * Undetermined stated, probably service is turned off and no metric available
-     */
-    UNKNOWN
-  }
-
-  public HDFSUpgradeFinalizedStatusRunnable(){
-  }
-
-  @Override
-  public void run(){
-    try {
-      Map<String, Cluster> clusterMap = m_clustersProvider.get().getClusters();
-
-      for (Cluster cluster : clusterMap.values()) {
-        AlertDefinitionEntity entity = m_dao.findByName(cluster.getClusterId(), ALERT_DEFINITION_NAME);
-
-        // skip this cluster if the runnable's alert definition is missing or disabled
-        if (null == entity || !entity.getEnabled()) {
-          continue;
-        }
-
-        // check if the service existed
-        try {
-          cluster.getService(s_serviceName);
-        } catch (ServiceNotFoundException e){
-          continue;
-        }
-
-        Date current = new Date(System.currentTimeMillis());
-        HDFSFinalizationState upgradeFinalized = getUpgradeFinalizedProperty(cluster);
-
-        AlertState alertState;
-        String alertDescription;
-
-        if (upgradeFinalized == HDFSFinalizationState.UNKNOWN) {
-          alertState = AlertState.UNKNOWN;
-          alertDescription = s_alertUnknownText;
-        } else if (upgradeFinalized == HDFSFinalizationState.FINALIZED){
-          alertState = AlertState.OK;
-          alertDescription = s_alertText;
-        } else {
-          alertState = AlertState.CRITICAL;
-          alertDescription = s_alertCriticalText;
-        }
-
-        Alert alert = new Alert(entity.getDefinitionName(), null,
-          entity.getServiceName(), entity.getComponentName(), null, alertState);
-
-        alert.setLabel(entity.getLabel());
-        alert.setText(alertDescription);
-        alert.setTimestamp(current.getTime());
-        alert.setCluster(cluster.getClusterName());
-        AlertReceivedEvent event = new AlertReceivedEvent(cluster.getClusterId(), alert);
-        m_alertEventPublisher.publish(event);
-      }
-    } catch (Exception e){
-      LOG.error("Unable to run the {} alert", ALERT_DEFINITION_NAME, e);
-    }
-  }
-
-  /**
-   * Query {@link ComponentResourceProvider} for the HDFS finalization status
-   * @param cluster the cluster for the query
-   * @return HDFS finalization status flag
-   * @throws AmbariException
-   */
-  private HDFSFinalizationState getUpgradeFinalizedProperty(Cluster cluster) throws AmbariException{
-  try
-    {
-      ComponentResourceProvider crp = (ComponentResourceProvider) ClusterControllerHelper
-        .getClusterController().ensureResourceProvider(Resource.Type.Component);
-
-      Set<String> properties = new HashSet<String>();
-      properties.add("ServiceComponentInfo/" + s_upgradeFinalizedMetricProperty);
-      Request request = PropertyHelper.getReadRequest(properties);
-      PredicateBuilder pb = new PredicateBuilder();
-
-      Predicate predicate =  pb.begin()
-        .property("ServiceComponentInfo/service_name").equals(s_serviceName)
-        .and()
-        .property("ServiceComponentInfo/component_name").equals(s_serviceComponent)
-        .and()
-        .property("ServiceComponentInfo/cluster_name").equals(cluster.getClusterName())
-        .end().toPredicate();
-
-      Set<Resource> res =  ClusterControllerHelper.getClusterController().populateResources(
-                   Resource.Type.Component,
-                   crp.getResources(request, predicate),
-                   request,
-                   predicate);
-
-      for (Resource rr: res){
-        for (Map<String, Object> t: rr.getPropertiesMap().values()){
-          if (t.containsKey(s_upgradeFinalizedMetricProperty) &&
-              t.get(s_upgradeFinalizedMetricProperty) instanceof Boolean) {
-
-            if ((Boolean)t.get(s_upgradeFinalizedMetricProperty)){
-              return HDFSFinalizationState.FINALIZED;
-            } else {
-              return HDFSFinalizationState.NOT_FINALIZED;
-            }
-          }
-        }
-      }
-    } catch (SystemException|UnsupportedPropertyException|NoSuchParentResourceException|NoSuchResourceException e) {
-      LOG.error("Unable to run the {} alert", ALERT_DEFINITION_NAME, e);
-    }
-    // no metric available
-    return HDFSFinalizationState.UNKNOWN;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f41ed7f1/ambari-server/src/main/resources/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/alerts.json b/ambari-server/src/main/resources/alerts.json
index 1285b24..6a50223 100644
--- a/ambari-server/src/main/resources/alerts.json
+++ b/ambari-server/src/main/resources/alerts.json
@@ -26,18 +26,6 @@
           "type": "SERVER",
           "class": "org.apache.ambari.server.alerts.StaleAlertRunnable"
         }
-      },
-      {
-        "name": "ambari_upgrade_finalized_state",
-        "label": "HDFS Upgrade Finalized State",
-        "description": "This service-level alert is triggered if HDFS is not in the finalized state",
-        "interval": 10,
-        "scope": "SERVICE",
-        "enabled": true,
-        "source": {
-          "type": "SERVER",
-          "class": "org.apache.ambari.server.alerts.HDFSUpgradeFinalizedStatusRunnable"
-        }
       }
     ],
     "AMBARI_AGENT" : [

http://git-wip-us.apache.org/repos/asf/ambari/blob/f41ed7f1/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json
index 1310ce8..2fcacc8 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/alerts.json
@@ -116,6 +116,19 @@
         }
       },
       {
+        "name": "upgrade_finalized_state",
+        "label": "HDFS Upgrade Finalized State",
+        "description": "This service-level alert is triggered if HDFS is not in the finalized state",
+        "interval": 1,
+        "scope": "SERVICE",
+        "enabled": true,
+        "source": {
+          "type": "SCRIPT",
+          "path": "HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py",
+          "parameters": []
+        }
+      },
+      {
         "name": "namenode_cpu",
         "label": "NameNode Host CPU Utilization",
         "description": "This host-level alert is triggered if CPU utilization of the NameNode exceeds certain warning and critical thresholds. It checks the NameNode JMX Servlet for the SystemCPULoad property. The threshold values are in percent.",

http://git-wip-us.apache.org/repos/asf/ambari/blob/f41ed7f1/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py
new file mode 100644
index 0000000..be72327
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_upgrade_finalized.py
@@ -0,0 +1,171 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import urllib2
+import ambari_simplejson as json # simplejson is much faster comparing to Python 2.6 json module and has the same functions set.
+import logging
+
+from resource_management.libraries.functions.curl_krb_request import curl_krb_request, CONNECTION_TIMEOUT_DEFAULT
+from resource_management.core.environment import Environment
+
+NN_HTTP_ADDRESS_KEY = '{{hdfs-site/dfs.namenode.http-address}}'
+NN_HTTPS_ADDRESS_KEY = '{{hdfs-site/dfs.namenode.https-address}}'
+NN_HTTP_POLICY_KEY = '{{hdfs-site/dfs.http.policy}}'
+
+KERBEROS_KEYTAB = '{{hdfs-site/dfs.web.authentication.kerberos.keytab}}'
+KERBEROS_PRINCIPAL = '{{hdfs-site/dfs.web.authentication.kerberos.principal}}'
+SECURITY_ENABLED_KEY = '{{cluster-env/security_enabled}}'
+SMOKEUSER_KEY = "{{cluster-env/smokeuser}}"
+EXECUTABLE_SEARCH_PATHS = '{{kerberos-env/executable_search_paths}}'
+
+logger = logging.getLogger()
+
+def get_tokens():
+  """
+  Returns a tuple of tokens in the format {{site/property}} that will be used
+  to build the dictionary passed into execute
+
+  :rtype tuple
+  """
+  return (NN_HTTP_ADDRESS_KEY, NN_HTTPS_ADDRESS_KEY, NN_HTTP_POLICY_KEY, EXECUTABLE_SEARCH_PATHS,
+          KERBEROS_KEYTAB, KERBEROS_PRINCIPAL, SECURITY_ENABLED_KEY, SMOKEUSER_KEY)
+
+
+def execute(configurations={}, parameters={}, host_name=None):
+  """
+  Returns a tuple containing the result code and a pre-formatted result label
+
+  Keyword arguments:
+  configurations : a mapping of configuration key to value
+  parameters : a mapping of script parameter key to value
+  host_name : the name of this host where the alert is running
+
+  :type configurations dict
+  :type parameters dict
+  :type host_name str
+  """
+
+  if configurations is None:
+    return (('UNKNOWN', ['There were no configurations supplied to the script.']))
+
+  uri = None
+  scheme = 'http'
+  http_uri = None
+  https_uri = None
+  http_policy = 'HTTP_ONLY'
+
+  if NN_HTTP_ADDRESS_KEY in configurations:
+    http_uri = configurations[NN_HTTP_ADDRESS_KEY]
+
+  if NN_HTTPS_ADDRESS_KEY in configurations:
+    https_uri = configurations[NN_HTTPS_ADDRESS_KEY]
+
+  if NN_HTTP_POLICY_KEY in configurations:
+    http_policy = configurations[NN_HTTP_POLICY_KEY]
+
+  if SMOKEUSER_KEY in configurations:
+    smokeuser = configurations[SMOKEUSER_KEY]
+
+  executable_paths = None
+  if EXECUTABLE_SEARCH_PATHS in configurations:
+    executable_paths = configurations[EXECUTABLE_SEARCH_PATHS]
+
+  security_enabled = False
+  if SECURITY_ENABLED_KEY in configurations:
+    security_enabled = str(configurations[SECURITY_ENABLED_KEY]).upper() == 'TRUE'
+
+  kerberos_keytab = None
+  if KERBEROS_KEYTAB in configurations:
+    kerberos_keytab = configurations[KERBEROS_KEYTAB]
+
+  kerberos_principal = None
+  if KERBEROS_PRINCIPAL in configurations:
+    kerberos_principal = configurations[KERBEROS_PRINCIPAL]
+    kerberos_principal = kerberos_principal.replace('_HOST', host_name)
+
+  # determine the right URI and whether to use SSL
+  uri = http_uri
+  if http_policy == 'HTTPS_ONLY':
+    scheme = 'https'
+
+    if https_uri is not None:
+      uri = https_uri
+
+  upgrade_finalized_qry = "{0}://{1}/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo".format(scheme, uri)
+
+  # start out assuming an OK status
+  label = None
+  result_code = "OK"
+
+  try:
+    if kerberos_principal is not None and kerberos_keytab is not None and security_enabled:
+      env = Environment.get_instance()
+
+      last_checkpoint_time_response, error_msg, time_millis = curl_krb_request(
+        env.tmp_dir, kerberos_keytab,
+        kerberos_principal, upgrade_finalized_qry, "upgrade_finalized_state", executable_paths, False,
+        "HDFS Upgrade Finalized State", smokeuser
+       )
+
+      upgrade_finalized_response_json = json.loads(last_checkpoint_time_response)
+      upgrade_finalized = bool(upgrade_finalized_response_json["beans"][0]["UpgradeFinalized"])
+
+    else:
+      upgrade_finalized = bool(get_value_from_jmx(upgrade_finalized_qry,
+                                                    "UpgradeFinalized"))
+
+    if upgrade_finalized:
+      label = "HDFS cluster is not in the upgrade state"
+      result_code = 'OK'
+    else:
+      label = "HDFS cluster is not finalized"
+      result_code = 'CRITICAL'
+
+  except Exception, e:
+    label = str(e)
+    result_code = 'UNKNOWN'
+
+  return ((result_code, [label]))
+
+def get_value_from_jmx(query, jmx_property):
+  """
+   Read property from the jxm endpoint
+
+  :param query: jmx uri path
+  :param jmx_property: property name to read
+  :return: jmx property value
+  
+  :type query str
+  :type jmx_property str
+  """
+  response = None
+
+  try:
+    response = urllib2.urlopen(query, timeout=int(CONNECTION_TIMEOUT_DEFAULT))
+    data = response.read()
+
+    data_dict = json.loads(data)
+    return data_dict["beans"][0][jmx_property]
+  finally:
+    if response is not None:
+      try:
+        response.close()
+      except:
+        pass

http://git-wip-us.apache.org/repos/asf/ambari/blob/f41ed7f1/ambari-server/src/test/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnableTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnableTest.java b/ambari-server/src/test/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnableTest.java
deleted file mode 100644
index df9834f..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/alerts/HDFSUpgradeFinalizedStatusRunnableTest.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.server.alerts;
-
-import static junit.framework.Assert.assertEquals;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.persistence.EntityManager;
-
-import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
-import org.apache.ambari.server.controller.internal.ResourceImpl;
-import org.apache.ambari.server.controller.spi.ClusterController;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
-import org.apache.ambari.server.events.AlertEvent;
-import org.apache.ambari.server.events.AlertReceivedEvent;
-import org.apache.ambari.server.events.MockEventListener;
-import org.apache.ambari.server.events.publishers.AlertEventPublisher;
-import org.apache.ambari.server.orm.DBAccessor;
-import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
-import org.apache.ambari.server.orm.dao.AlertsDAO;
-import org.apache.ambari.server.orm.entities.AlertCurrentEntity;
-import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
-import org.apache.ambari.server.state.Alert;
-import org.apache.ambari.server.state.AlertState;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.stack.OsFamily;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.eventbus.EventBus;
-import com.google.inject.Binder;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-/**
- * Tests {@link StaleAlertRunnableTest}.
- */
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(ClusterControllerHelper.class)
-public class HDFSUpgradeFinalizedStatusRunnableTest {
-
-  private final static long CLUSTER_ID = 1;
-  private final static String CLUSTER_NAME = "c1";
-
-  private final static String DEFINITION_NAME = "ambari_upgrade_finalized_state";
-  private final static String DEFINITION_SERVICE = "AMBARI";
-  private final static String DEFINITION_COMPONENT = "AMBARI_SERVER";
-  private final static String DEFINITION_LABEL = "Mock Definition";
-  private final static String s_upgradeFinalizedMetricProperty = "UpgradeFinalized";
-  private final static int DEFINITION_INTERVAL = 1;
-
-  private Clusters m_clusters;
-  private Cluster m_cluster;
-  private Injector m_injector;
-  private AlertsDAO m_alertsDao;
-  private AlertDefinitionDAO m_definitionDao;
-  private AlertDefinitionEntity m_definition;
-  private List<AlertCurrentEntity> m_currentAlerts = new ArrayList<AlertCurrentEntity>();
-  private MockEventListener m_listener;
-
-  private AlertEventPublisher m_eventPublisher;
-  private EventBus m_synchronizedBus;
-
-  /**
-   *
-   */
-  @Before
-  public void setup() throws Exception {
-    m_injector = Guice.createInjector(new MockModule());
-    m_alertsDao = m_injector.getInstance(AlertsDAO.class);
-    m_definitionDao = m_injector.getInstance(AlertDefinitionDAO.class);
-    m_clusters = m_injector.getInstance(Clusters.class);
-    m_cluster = m_injector.getInstance(Cluster.class);
-    m_eventPublisher = m_injector.getInstance(AlertEventPublisher.class);
-    m_listener = m_injector.getInstance(MockEventListener.class);
-    m_definition = EasyMock.createNiceMock(AlertDefinitionEntity.class);
-
-    // !!! need a synchronous op for testing
-    m_synchronizedBus = new EventBus();
-    Field field = AlertEventPublisher.class.getDeclaredField("m_eventBus");
-    field.setAccessible(true);
-    field.set(m_eventPublisher, m_synchronizedBus);
-
-    // register mock listener
-    m_synchronizedBus.register(m_listener);
-
-    // create the cluster map
-    Map<String,Cluster> clusterMap = new HashMap<String, Cluster>();
-    clusterMap.put(CLUSTER_NAME, m_cluster);
-
-    // mock the definition for the alert
-    expect(m_definition.getDefinitionName()).andReturn(DEFINITION_NAME).atLeastOnce();
-    expect(m_definition.getServiceName()).andReturn(DEFINITION_SERVICE).atLeastOnce();
-    expect(m_definition.getComponentName()).andReturn(DEFINITION_COMPONENT).atLeastOnce();
-    expect(m_definition.getLabel()).andReturn(DEFINITION_LABEL).atLeastOnce();
-    expect(m_definition.getEnabled()).andReturn(true).atLeastOnce();
-    expect(m_definition.getScheduleInterval()).andReturn(DEFINITION_INTERVAL).atLeastOnce();
-
-    // mock the cluster
-    expect(m_cluster.getClusterId()).andReturn(CLUSTER_ID).atLeastOnce();
-
-    // mock clusters
-    expect(m_clusters.getClusters()).andReturn(clusterMap).atLeastOnce();
-
-    // mock the definition DAO
-    expect(m_definitionDao.findByName(CLUSTER_ID, DEFINITION_NAME)).andReturn(
-      m_definition).atLeastOnce();
-
-    // mock the current dao
-    expect(m_alertsDao.findCurrentByCluster(CLUSTER_ID)).andReturn(
-      m_currentAlerts).atLeastOnce();
-
-    replay(m_definition, m_cluster, m_clusters,
-      m_definitionDao, m_alertsDao);
-  }
-
-  /**
-   * @throws Exception
-   */
-  @After
-  public void teardown() throws Exception {
-  }
-
-  /**
-   * Tests that the event is triggered with a status of OK.
-   */
-  @Test
-  @SuppressWarnings("unchecked")
-  public void testFinalizedState() throws SystemException {
-
-    // create current alerts that are not stale
-    Resource resource = new ResourceImpl(Resource.Type.Component);
-    resource.setProperty(s_upgradeFinalizedMetricProperty, Boolean.TRUE);
-
-    ClusterController clusterController = createNiceMock(ClusterController.class);
-    ComponentResourceProvider crp = createNiceMock(ComponentResourceProvider.class);
-
-
-    Set<Resource> resourceMap = new HashSet<Resource>();
-    resourceMap.add(resource);
-
-    PowerMock.mockStatic(ClusterControllerHelper.class);
-    expect(ClusterControllerHelper.getClusterController()).andReturn(clusterController).atLeastOnce();
-    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(crp).atLeastOnce();
-    expect(clusterController.populateResources(anyObject(Resource.Type.class),
-      anyObject(resourceMap.getClass()), anyObject(Request.class), anyObject(Predicate.class))).andReturn(resourceMap).atLeastOnce();
-
-    PowerMock.replay(ClusterControllerHelper.class);
-    replay(crp, clusterController);
-
-
-    // precondition that no events were fired
-    assertEquals(0,
-      m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));
-
-    // instantiate and inject mocks
-    HDFSUpgradeFinalizedStatusRunnable runnable = new HDFSUpgradeFinalizedStatusRunnable();
-    m_injector.injectMembers(runnable);
-
-    // run the alert
-    runnable.run();
-
-    assertEquals(1,
-      m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));
-
-    List<AlertEvent> events = m_listener.getAlertEventInstances(AlertReceivedEvent.class);
-    assertEquals(1, events.size());
-
-    AlertReceivedEvent event = (AlertReceivedEvent) events.get(0);
-    Alert alert = event.getAlert();
-    assertEquals("AMBARI", alert.getService());
-    assertEquals("AMBARI_SERVER", alert.getComponent());
-    assertEquals(AlertState.OK, alert.getState());
-    assertEquals(DEFINITION_NAME, alert.getName());
-
-    verify(m_cluster, m_clusters, m_definitionDao);
-  }
-
-  /**
-   * Tests that a alert triggers the event with a status of CRITICAL.
-   */
-  @Test
-  @SuppressWarnings("unchecked")
-  public void testNonFinalizedState() throws SystemException {
-
-    // create current alerts that are not stale
-    Resource resource = new ResourceImpl(Resource.Type.Component);
-    resource.setProperty(s_upgradeFinalizedMetricProperty, Boolean.FALSE);
-
-    ClusterController clusterController = createNiceMock(ClusterController.class);
-    ComponentResourceProvider crp = createNiceMock(ComponentResourceProvider.class);
-
-
-    Set<Resource> resourceMap = new HashSet<Resource>();
-    resourceMap.add(resource);
-
-    PowerMock.mockStatic(ClusterControllerHelper.class);
-    expect(ClusterControllerHelper.getClusterController()).andReturn(clusterController).atLeastOnce();
-    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(crp).atLeastOnce();
-    expect(clusterController.populateResources(anyObject(Resource.Type.class),
-      anyObject(resourceMap.getClass()), anyObject(Request.class), anyObject(Predicate.class))).andReturn(resourceMap).atLeastOnce();
-
-    PowerMock.replay(ClusterControllerHelper.class);
-    replay(crp, clusterController);
-
-
-    // precondition that no events were fired
-    assertEquals(0,
-      m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));
-
-    // instantiate and inject mocks
-    HDFSUpgradeFinalizedStatusRunnable runnable = new HDFSUpgradeFinalizedStatusRunnable();
-    m_injector.injectMembers(runnable);
-
-    // run the alert
-    runnable.run();
-
-    assertEquals(1,
-      m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));
-
-    List<AlertEvent> events = m_listener.getAlertEventInstances(AlertReceivedEvent.class);
-    assertEquals(1, events.size());
-
-    AlertReceivedEvent event = (AlertReceivedEvent) events.get(0);
-    Alert alert = event.getAlert();
-    assertEquals("AMBARI", alert.getService());
-    assertEquals("AMBARI_SERVER", alert.getComponent());
-    assertEquals(AlertState.CRITICAL, alert.getState());
-    assertEquals(DEFINITION_NAME, alert.getName());
-
-    verify(m_cluster, m_clusters, m_definitionDao);
-  }
-
-  /**
-   *
-   */
-  private class MockModule implements Module {
-    /**
-     *
-     */
-    @Override
-    public void configure(Binder binder) {
-      Cluster cluster = EasyMock.createNiceMock(Cluster.class);
-
-      binder.bind(Clusters.class).toInstance(createNiceMock(Clusters.class));
-      binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
-      binder.bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
-      binder.bind(Cluster.class).toInstance(cluster);
-      binder.bind(AlertDefinitionDAO.class).toInstance(createNiceMock(AlertDefinitionDAO.class));
-      binder.bind(AlertsDAO.class).toInstance(createNiceMock(AlertsDAO.class));
-      binder.bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f41ed7f1/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 86ff0c9..14c66a2 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
@@ -1736,7 +1736,7 @@ public class AmbariMetaInfoTest {
 
     AlertDefinitionDAO dao = injector.getInstance(AlertDefinitionDAO.class);
     List<AlertDefinitionEntity> definitions = dao.findAll(clusterId);
-    assertEquals(10, definitions.size());
+    assertEquals(9, definitions.size());
 
     // figure out how many of these alerts were merged into from the
     // non-stack alerts.json
@@ -1749,7 +1749,7 @@ public class AmbariMetaInfoTest {
     }
 
     assertEquals(1, hostAlertCount);
-    assertEquals(9, definitions.size() - hostAlertCount);
+    assertEquals(8, definitions.size() - hostAlertCount);
 
     for (AlertDefinitionEntity definition : definitions) {
       definition.setScheduleInterval(28);
@@ -1759,7 +1759,7 @@ public class AmbariMetaInfoTest {
     metaInfo.reconcileAlertDefinitions(clusters);
 
     definitions = dao.findAll();
-    assertEquals(10, definitions.size());
+    assertEquals(9, definitions.size());
 
     for (AlertDefinitionEntity definition : definitions) {
       assertEquals(28, definition.getScheduleInterval().intValue());
@@ -1768,7 +1768,7 @@ public class AmbariMetaInfoTest {
     // find all enabled for the cluster should find 6 (the ones from HDFS;
     // it will not find the agent alert since it's not bound to the cluster)
     definitions = dao.findAllEnabled(cluster.getClusterId());
-    assertEquals(9, definitions.size());
+    assertEquals(8, definitions.size());
 
     // create new definition
     AlertDefinitionEntity entity = new AlertDefinitionEntity();
@@ -1787,19 +1787,19 @@ public class AmbariMetaInfoTest {
 
     // verify the new definition is found (6 HDFS + 1 new one)
     definitions = dao.findAllEnabled(cluster.getClusterId());
-    assertEquals(10, definitions.size());
+    assertEquals(9, definitions.size());
 
     // reconcile, which should disable our bad definition
     metaInfo.reconcileAlertDefinitions(clusters);
 
     // find all enabled for the cluster should find 6
     definitions = dao.findAllEnabled(cluster.getClusterId());
-    assertEquals(9, definitions.size());
+    assertEquals(8, definitions.size());
 
     // find all should find 6 HDFS + 1 disabled + 1 agent alert + 2 server
     // alerts
     definitions = dao.findAll();
-    assertEquals(11, definitions.size());
+    assertEquals(10, definitions.size());
 
     entity = dao.findById(entity.getDefinitionId());
     assertFalse(entity.getEnabled());

http://git-wip-us.apache.org/repos/asf/ambari/blob/f41ed7f1/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
index 80ab0fe..9d58b94 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/metadata/AgentAlertDefinitionsTest.java
@@ -66,7 +66,7 @@ public class AgentAlertDefinitionsTest {
   public void testLoadingServertAlerts() {
     AmbariServiceAlertDefinitions ambariServiceAlertDefinitions = m_injector.getInstance(AmbariServiceAlertDefinitions.class);
     List<AlertDefinition> definitions = ambariServiceAlertDefinitions.getServerDefinitions();
-    Assert.assertEquals(3, definitions.size());
+    Assert.assertEquals(2, definitions.size());
 
     for (AlertDefinition definition : definitions) {
       Assert.assertEquals(Components.AMBARI_SERVER.name(),