You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2014/09/07 12:40:43 UTC

git commit: AMBARI-7160. Add endpoints for alert data (ncole)

Repository: ambari
Updated Branches:
  refs/heads/branch-alerts-dev e508fe5a3 -> 84c16c5c5


AMBARI-7160. Add endpoints for alert data (ncole)


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

Branch: refs/heads/branch-alerts-dev
Commit: 84c16c5c5981559454659d069463a5bbd26e7de6
Parents: e508fe5
Author: Nate Cole <nc...@hortonworks.com>
Authored: Thu Sep 4 18:07:59 2014 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Sun Sep 7 05:45:13 2014 -0400

----------------------------------------------------------------------
 .../api/resources/AlertResourceDefinition.java  |  41 ++++
 .../resources/ClusterResourceDefinition.java    |   1 +
 .../api/resources/HostResourceDefinition.java   |   7 +-
 .../resources/ResourceInstanceFactoryImpl.java  |   4 +
 .../resources/ServiceResourceDefinition.java    |   5 +-
 .../server/api/services/AlertService.java       |  93 +++++++
 .../server/api/services/ClusterService.java     |  16 ++
 .../ambari/server/api/services/HostService.java |  11 +
 .../server/api/services/ServiceService.java     |   9 +
 .../ambari/server/controller/AmbariServer.java  |   2 +
 .../AbstractControllerResourceProvider.java     |   2 +
 .../internal/AlertResourceProvider.java         | 191 +++++++++++++++
 .../ambari/server/controller/spi/Resource.java  |   2 +
 .../apache/ambari/server/orm/dao/AlertsDAO.java |  21 ++
 .../server/orm/entities/AlertCurrentEntity.java |   5 +-
 .../src/main/resources/key_properties.json      |   6 +
 .../src/main/resources/properties.json          |  16 ++
 .../api/query/render/DefaultRendererTest.java   |   3 +-
 .../api/query/render/MinimalRendererTest.java   |   3 +-
 .../ClusterResourceDefinitionTest.java          |   3 +-
 .../internal/AlertResourceProviderTest.java     | 241 +++++++++++++++++++
 .../ambari/server/orm/dao/AlertsDAOTest.java    |  52 +++-
 22 files changed, 724 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/resources/AlertResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/AlertResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/AlertResourceDefinition.java
new file mode 100644
index 0000000..afdbcfc
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/AlertResourceDefinition.java
@@ -0,0 +1,41 @@
+/**
+ * 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.api.resources;
+
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Definition for alert resources.
+ */
+public class AlertResourceDefinition extends BaseResourceDefinition {
+  
+  public AlertResourceDefinition() {
+    super(Resource.Type.Alert);
+  }
+  
+  @Override
+  public String getPluralName() {
+    return "alerts_data";
+  }
+  
+  @Override
+  public String getSingularName() {
+    return "alert_data";
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
index 702bcf8..ef907c0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
@@ -68,6 +68,7 @@ public class ClusterResourceDefinition extends BaseResourceDefinition {
     setChildren.add(new SubResourceDefinition(Resource.Type.ConfigGroup));
     setChildren.add(new SubResourceDefinition(Resource.Type.ClusterPrivilege));
     setChildren.add(new SubResourceDefinition(Resource.Type.AlertDefinition));
+    setChildren.add(new SubResourceDefinition(Resource.Type.Alert));
 
     return setChildren;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java
index 8aba287..14ed799 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java
@@ -19,7 +19,7 @@
 package org.apache.ambari.server.api.resources;
 
 
-import java.util.Collections;
+import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.ambari.server.controller.spi.Resource;
@@ -48,6 +48,9 @@ public class HostResourceDefinition extends BaseResourceDefinition {
 
   @Override
   public Set<SubResourceDefinition> getSubResourceDefinitions() {
-    return Collections.singleton(new SubResourceDefinition(Resource.Type.HostComponent));
+    Set<SubResourceDefinition> subs = new HashSet<SubResourceDefinition>();
+    subs.add(new SubResourceDefinition(Resource.Type.HostComponent));
+    subs.add(new SubResourceDefinition(Resource.Type.Alert));
+    return subs;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
index ffbfb29..3b90b30 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
@@ -250,6 +250,10 @@ public class ResourceInstanceFactoryImpl implements ResourceInstanceFactory {
       case Permission:
         resourceDefinition = new PermissionResourceDefinition();
         break;
+        
+      case Alert:
+        resourceDefinition = new AlertResourceDefinition();
+        break;
 
       case AlertDefinition:
         resourceDefinition = new AlertDefResourceDefinition();

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceResourceDefinition.java
index e1355ad..be8e0b4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceResourceDefinition.java
@@ -47,6 +47,9 @@ public class ServiceResourceDefinition extends BaseResourceDefinition {
 
   @Override
   public Set<SubResourceDefinition> getSubResourceDefinitions() {
-    return Collections.singleton(new SubResourceDefinition(Resource.Type.Component));
+    Set<SubResourceDefinition> subs = new HashSet<SubResourceDefinition>();
+    subs.add(new SubResourceDefinition(Resource.Type.Component));
+    subs.add(new SubResourceDefinition(Resource.Type.Alert));
+    return subs;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/services/AlertService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AlertService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AlertService.java
new file mode 100644
index 0000000..8e163c2
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AlertService.java
@@ -0,0 +1,93 @@
+/**
+ * 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.api.services;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Endpoint for alert data.
+ */
+public class AlertService extends BaseService {
+
+  private String clusterName = null;
+  private String serviceName = null;
+  private String hostName = null;
+  
+  AlertService(String clusterName, String serviceName, String hostName) {
+    this.clusterName = clusterName;
+    this.serviceName = serviceName;
+    this.hostName = hostName;
+  }
+
+  /**
+   * Gets all the definitions for the target
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getDefinitions(String body,
+      @Context HttpHeaders headers,
+      @Context UriInfo ui) {
+    return handleRequest(headers, body, ui, Request.Type.GET,
+      createResourceInstance(null));
+  }
+  
+
+  /**
+   * Gets a specific alert's instance
+   */
+  @GET
+  @Path("{alertId}")
+  @Produces("text/plain")
+  public Response getDefinition(String body,
+      @Context HttpHeaders headers,
+      @Context UriInfo ui,
+      @PathParam("alertId") Long id) {
+    return handleRequest(headers, body, ui, Request.Type.GET,
+      createResourceInstance(id));
+  }
+  
+  
+  /**
+   * Create an alert resource instance
+   * @param alertId the alert id, if requesting a specific one
+   * @return the resource instance
+   */
+  private ResourceInstance createResourceInstance(Long alertId) {
+    Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.Cluster, clusterName);
+    mapIds.put(Resource.Type.Service, serviceName);
+    mapIds.put(Resource.Type.Host, hostName);
+    mapIds.put(Resource.Type.Alert, null == alertId ? null : alertId.toString());
+
+    return createResource(Resource.Type.Alert, mapIds);
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
index 3f1ce36..c76acf7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
@@ -357,6 +357,22 @@ public class ClusterService extends BaseService {
     hasPermission(Request.Type.valueOf(request.getMethod()), clusterName);
     return new ClusterPrivilegeService(clusterName);
   }
+  
+  /**
+   * Gets the alert definition service
+   *
+   * @param request      the request
+   * @param clusterName  the cluster name
+   *
+   * @return  the alert definition service
+   */
+  @Path("{clusterName}/alerts_data")
+  public AlertService getAlertService(
+      @Context javax.ws.rs.core.Request request, @PathParam("clusterName") String clusterName) {
+
+    hasPermission(Request.Type.valueOf(request.getMethod()), clusterName);
+    return new AlertService(clusterName, null, null);
+  }  
 
 
   // ----- helper methods ----------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
index db9d3c0..8cec7e1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
@@ -207,6 +207,17 @@ public class HostService extends BaseService {
   }
 
   /**
+   * Get the alerts sub-resource.
+   *
+   * @param hostName host id
+   * @return the alerts service
+   */
+  @Path("{hostName}/alerts_data")
+  public AlertService getAlertHandler(@PathParam("hostName") String hostName) {
+    return new AlertService(m_clusterName, null, hostName);
+  }  
+  
+  /**
    * Create a service resource instance.
    *
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
index 643ae36..30f4f2f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
@@ -183,6 +183,15 @@ public class ServiceService extends BaseService {
 
     return new ComponentService(m_clusterName, serviceName);
   }
+  
+  /**
+   * Gets the alerts sub-resource.
+   */
+  @Path("{serviceName}/alerts_data")
+  public AlertService getAlertHandler(
+      @PathParam("serviceName") String serviceName) {
+    return new AlertService(m_clusterName, serviceName, null);
+  }
 
   /**
    * Create a service resource instance.

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 31d6518..73e4013 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -47,6 +47,7 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.AbstractControllerResourceProvider;
 import org.apache.ambari.server.controller.internal.AlertDefinitionResourceProvider;
 import org.apache.ambari.server.controller.internal.AlertGroupResourceProvider;
+import org.apache.ambari.server.controller.internal.AlertResourceProvider;
 import org.apache.ambari.server.controller.internal.AlertTargetResourceProvider;
 import org.apache.ambari.server.controller.internal.AmbariPrivilegeResourceProvider;
 import org.apache.ambari.server.controller.internal.BlueprintResourceProvider;
@@ -531,6 +532,7 @@ public class AmbariServer {
         injector.getInstance(Gson.class), ambariMetaInfo);
     StackDependencyResourceProvider.init(ambariMetaInfo);
     ClusterResourceProvider.init(injector.getInstance(BlueprintDAO.class), ambariMetaInfo, injector.getInstance(ConfigHelper.class));
+    AlertResourceProvider.init(injector);
     AlertDefinitionResourceProvider.init(injector);
     AlertGroupResourceProvider.init(injector);
     AlertTargetResourceProvider.init(injector);

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index 31c350b..f3f92a1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -149,6 +149,8 @@ public abstract class AbstractControllerResourceProvider extends AbstractResourc
         return new RecommendationResourceProvider(propertyIds, keyPropertyIds, managementController);
       case Validation:
         return new ValidationResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Alert:
+        return new AlertResourceProvider(propertyIds, keyPropertyIds, managementController);
       case AlertDefinition:
         return new AlertDefinitionResourceProvider(propertyIds, keyPropertyIds, managementController);
       case AlertGroup:

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertResourceProvider.java
new file mode 100644
index 0000000..639a02f
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertResourceProvider.java
@@ -0,0 +1,191 @@
+/**
+ * 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.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+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.orm.dao.AlertsDAO;
+import org.apache.ambari.server.orm.entities.AlertCurrentEntity;
+import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
+import org.apache.ambari.server.orm.entities.AlertHistoryEntity;
+import org.apache.ambari.server.state.Cluster;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+/**
+ * ResourceProvider for Alert instances
+ */
+public class AlertResourceProvider extends ReadOnlyResourceProvider {
+
+  protected static final String ALERT_CLUSTER_NAME = "Alert/cluster_name";
+  protected static final String ALERT_ID = "Alert/id";
+  protected static final String ALERT_NAME = "Alert/name";
+  protected static final String ALERT_LATEST_TIMESTAMP = "Alert/latest_timestamp";
+  protected static final String ALERT_MAINTENANCE_STATE = "Alert/maintenance_state";
+  protected static final String ALERT_ORIGINAL_TIMESTAMP = "Alert/original_timestamp";
+  protected static final String ALERT_INSTANCE = "Alert/instance";
+  protected static final String ALERT_LABEL = "Alert/label";
+  protected static final String ALERT_STATE = "Alert/state";
+  protected static final String ALERT_TEXT = "Alert/text";
+  protected static final String ALERT_COMPONENT = "Alert/component_name";
+  protected static final String ALERT_HOST = "Alert/host_name";
+  protected static final String ALERT_SERVICE = "Alert/service_name";
+  protected static final String ALERT_SCOPE = "Alert/scope";
+  
+  private static Set<String> pkPropertyIds = new HashSet<String>(
+      Arrays.asList(ALERT_ID, ALERT_NAME));
+
+  private static AlertsDAO alertsDAO = null;
+
+  /**
+   * @param injector the injector
+   */
+  @Inject
+  public static void init(Injector injector) {
+    alertsDAO = injector.getInstance(AlertsDAO.class);
+  }
+
+  AlertResourceProvider(Set<String> propertyIds,
+      Map<Resource.Type, String> keyPropertyIds,
+      AmbariManagementController managementController) {
+    
+    super(propertyIds, keyPropertyIds, managementController);
+  }
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return pkPropertyIds;
+  }
+
+
+  @Override
+  public Set<Resource> getResources(Request request, Predicate predicate)
+      throws SystemException, UnsupportedPropertyException,
+      NoSuchResourceException, NoSuchParentResourceException {
+
+    Set<String> requestPropertyIds = getRequestPropertyIds(request, predicate);
+    
+    Set<Resource> results = new HashSet<Resource>();
+
+    for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
+      
+      String clusterName = (String) propertyMap.get(ALERT_CLUSTER_NAME);
+
+      if (null == clusterName || clusterName.isEmpty()) {
+        throw new IllegalArgumentException("Invalid argument, cluster name is required");
+      }
+
+      String id = (String) propertyMap.get(ALERT_ID);
+      if (null != id) {
+        AlertCurrentEntity entity = alertsDAO.findCurrentById(Long.parseLong(id));
+        
+        if (null != entity) {
+          results.add(toResource(false, clusterName, entity, requestPropertyIds));
+        }
+        
+      } else {
+        Cluster cluster = null;
+        
+        try {
+          cluster = getManagementController().getClusters().getCluster(clusterName);
+        } catch (AmbariException e) {
+          throw new NoSuchResourceException("Parent Cluster resource doesn't exist", e);
+        }
+        
+        String serviceName = (String) propertyMap.get(ALERT_SERVICE);
+        String hostName = (String) propertyMap.get(ALERT_HOST);
+        
+        List<AlertCurrentEntity> entities = null;
+        
+        if (null != hostName) {
+          entities = alertsDAO.findCurrentByHost(cluster.getClusterId(),
+              hostName);
+        } else if (null != serviceName) {
+          entities = alertsDAO.findCurrentByService(cluster.getClusterId(),
+              serviceName);
+        } else {
+          entities = alertsDAO.findCurrentByCluster(cluster.getClusterId());          
+        }
+        
+        if (null == entities)
+          entities = Collections.emptyList();
+        
+        for (AlertCurrentEntity entity : entities) {
+          results.add(toResource(true, clusterName, entity, requestPropertyIds));
+        }
+      }
+    }
+
+    return results;
+  }
+
+  /**
+   * Converts an entity to a resource.
+   * 
+   * @param isCollection {@code true} if the response is for a collection
+   * @param clusterName the cluster name
+   * @param entity the entity
+   * @param requestedIds the requested ids
+   * @return the resource
+   */
+  private Resource toResource(boolean isCollection, String clusterName,
+      AlertCurrentEntity entity, Set<String> requestedIds) {
+    Resource resource = new ResourceImpl(Resource.Type.Alert);
+
+    setResourceProperty(resource, ALERT_CLUSTER_NAME, clusterName, requestedIds);
+    setResourceProperty(resource, ALERT_ID, entity.getAlertId(), requestedIds);
+    setResourceProperty(resource, ALERT_LATEST_TIMESTAMP, entity.getLatestTimestamp(), requestedIds);
+    setResourceProperty(resource, ALERT_MAINTENANCE_STATE, entity.getMaintenanceState(), requestedIds);
+    setResourceProperty(resource, ALERT_ORIGINAL_TIMESTAMP, entity.getOriginalTimestamp(), requestedIds);
+    
+    AlertHistoryEntity history = entity.getAlertHistory();
+    setResourceProperty(resource, ALERT_INSTANCE, history.getAlertInstance(), requestedIds);
+    setResourceProperty(resource, ALERT_LABEL, history.getAlertLabel(), requestedIds);
+    setResourceProperty(resource, ALERT_STATE, history.getAlertState(), requestedIds);
+    setResourceProperty(resource, ALERT_TEXT, history.getAlertText(), requestedIds);
+    setResourceProperty(resource, ALERT_COMPONENT, history.getComponentName(), requestedIds);
+    setResourceProperty(resource, ALERT_HOST, history.getHostName(), requestedIds);
+    setResourceProperty(resource, ALERT_SERVICE, history.getServiceName(), requestedIds);
+    
+    AlertDefinitionEntity definition = history.getAlertDefinition();
+    setResourceProperty(resource, ALERT_NAME, definition.getDefinitionName(), requestedIds);
+    setResourceProperty(resource, ALERT_SCOPE, definition.getScope(), requestedIds);
+    
+    if (isCollection) {
+      // !!! want name to be populated as if it were a PK when requesting the collection
+      resource.setProperty(ALERT_NAME, definition.getDefinitionName());
+    }
+
+    return resource;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
index 2cf6d99..59f9a89 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
@@ -114,6 +114,7 @@ public interface Resource {
     Validation,
     HostComponentProcess,
     Permission,
+    Alert,
     AlertDefinition,
     AlertGroup,
     AlertTarget,
@@ -198,6 +199,7 @@ public interface Resource {
     public static final Type Validation = InternalType.Validation.getType();
     public static final Type HostComponentProcess = InternalType.HostComponentProcess.getType();
     public static final Type Permission = InternalType.Permission.getType();
+    public static final Type Alert = InternalType.Alert.getType();
     public static final Type AlertDefinition = InternalType.AlertDefinition.getType();
     public static final Type AlertGroup = InternalType.AlertGroup.getType();
     public static final Type AlertTarget = InternalType.AlertTarget.getType();

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java
index b43b5b1..5fcc1ec 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java
@@ -19,6 +19,7 @@ package org.apache.ambari.server.orm.dao;
 
 import java.util.Collections;
 import java.util.Date;
+import java.util.EnumSet;
 import java.util.List;
 
 import javax.persistence.EntityManager;
@@ -28,6 +29,7 @@ import org.apache.ambari.server.orm.RequiresSession;
 import org.apache.ambari.server.orm.entities.AlertCurrentEntity;
 import org.apache.ambari.server.orm.entities.AlertHistoryEntity;
 import org.apache.ambari.server.state.AlertState;
+import org.apache.ambari.server.state.alert.Scope;
 
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -205,6 +207,23 @@ public class AlertsDAO {
   }
 
   /**
+   * Gets the current alerts for a given cluster.
+   * 
+   * @return the current alerts for the given clusteror an empty list if none
+   *         exist (never {@code null}).
+   */
+  @RequiresSession
+  public List<AlertCurrentEntity> findCurrentByCluster(long clusterId) {
+    TypedQuery<AlertCurrentEntity> query = entityManagerProvider.get().createNamedQuery(
+        "AlertCurrentEntity.findByCluster", AlertCurrentEntity.class);
+
+    query.setParameter("clusterId", Long.valueOf(clusterId));
+
+    return daoUtils.selectList(query);
+  }
+  
+  
+  /**
    * Gets the current alerts for a given service.
    * 
    * @return the current alerts for the given service or an empty list if none
@@ -218,6 +237,7 @@ public class AlertsDAO {
 
     query.setParameter("clusterId", clusterId);
     query.setParameter("serviceName", serviceName);
+    query.setParameter("inlist", EnumSet.of(Scope.ANY, Scope.SERVICE));
 
     return daoUtils.selectList(query);
   }
@@ -236,6 +256,7 @@ public class AlertsDAO {
 
     query.setParameter("clusterId", clusterId);
     query.setParameter("hostName", hostName);
+    query.setParameter("inlist", EnumSet.of(Scope.ANY, Scope.HOST));
 
     return daoUtils.selectList(query);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java
index 31b1673..6d6073f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertCurrentEntity.java
@@ -47,8 +47,9 @@ import org.apache.ambari.server.state.MaintenanceState;
 @TableGenerator(name = "alert_current_id_generator", table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_value", pkColumnValue = "alert_current_id_seq", initialValue = 0, allocationSize = 1)
 @NamedQueries({
     @NamedQuery(name = "AlertCurrentEntity.findAll", query = "SELECT alert FROM AlertCurrentEntity alert"),
-    @NamedQuery(name = "AlertCurrentEntity.findByService", query = "SELECT alert FROM AlertCurrentEntity alert JOIN alert.alertHistory history WHERE history.clusterId = :clusterId AND history.serviceName = :serviceName"),
-    @NamedQuery(name = "AlertCurrentEntity.findByHost", query = "SELECT alert FROM AlertCurrentEntity alert JOIN alert.alertHistory history WHERE history.clusterId = :clusterId AND history.hostName = :hostName"),
+    @NamedQuery(name = "AlertCurrentEntity.findByCluster", query = "SELECT alert FROM AlertCurrentEntity alert JOIN alert.alertHistory history WHERE history.clusterId = :clusterId"),
+    @NamedQuery(name = "AlertCurrentEntity.findByService", query = "SELECT alert FROM AlertCurrentEntity alert JOIN alert.alertHistory history WHERE history.clusterId = :clusterId AND history.serviceName = :serviceName AND history.alertDefinition.scope IN :inlist"),
+    @NamedQuery(name = "AlertCurrentEntity.findByHost", query = "SELECT alert FROM AlertCurrentEntity alert JOIN alert.alertHistory history WHERE history.clusterId = :clusterId AND history.hostName = :hostName AND history.alertDefinition.scope IN :inlist"),
     @NamedQuery(name = "AlertCurrentEntity.findByHostAndName", query = "SELECT alert FROM AlertCurrentEntity alert JOIN alert.alertHistory history WHERE history.clusterId = :clusterId AND history.alertDefinition.definitionName = :definitionName AND history.hostName = :hostName"),
     @NamedQuery(name = "AlertCurrentEntity.removeByHistoryId", query = "DELETE FROM AlertCurrentEntity alert WHERE alert.alertHistory.alertId = :historyId"),
     @NamedQuery(name = "AlertCurrentEntity.removeByDefinitionId", query = "DELETE FROM AlertCurrentEntity alert WHERE alert.alertDefinition.definitionId = :definitionId") })

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/resources/key_properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/key_properties.json b/ambari-server/src/main/resources/key_properties.json
index db34920..d127bc5 100644
--- a/ambari-server/src/main/resources/key_properties.json
+++ b/ambari-server/src/main/resources/key_properties.json
@@ -145,6 +145,12 @@
     "HostComponent": "HostComponentProcess/component_name",
     "HostComponentProcess": "HostComponentProcess/name"
   },
+  "Alert": {
+    "Cluster": "Alert/cluster_name",
+    "Service": "Alert/service_name",
+    "Host": "Alert/host_name",
+    "Alert": "Alert/id"
+  },
   "AlertDefinition": {
     "Cluster": "AlertDefinition/cluster_name",
     "AlertDefinition": "AlertDefinition/id"

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index accab44..eeef6ec 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -419,6 +419,22 @@
       "HostComponentProcess/name",
       "HostComponentProcess/status"
     ],
+    "Alert": [
+      "Alert/cluster_name",
+      "Alert/id",
+      "Alert/name",
+      "Alert/latest_timestamp",
+      "Alert/maintenance_state",
+      "Alert/original_timestamp",
+      "Alert/instance",
+      "Alert/label",
+      "Alert/state",
+      "Alert/text",
+      "Alert/component_name",
+      "Alert/host_name",
+      "Alert/service_name",
+      "Alert/scope"
+    ],
     "AlertDefinition": [
       "AlertDefinition/cluster_name",
       "AlertDefinition/service_name",

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/DefaultRendererTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/DefaultRendererTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/DefaultRendererTest.java
index eb0f28f..3e0617e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/DefaultRendererTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/DefaultRendererTest.java
@@ -50,6 +50,7 @@ public class DefaultRendererTest {
 
     // schema expectations
     expect(schemaFactory.getSchema(Resource.Type.Component)).andReturn(schema).anyTimes();
+    expect(schemaFactory.getSchema(Resource.Type.Alert)).andReturn(schema).anyTimes();
     expect(schema.getKeyPropertyId(Resource.Type.Component)).andReturn("ServiceComponentInfo/component_name").anyTimes();
     expect(schema.getKeyPropertyId(Resource.Type.Service)).andReturn("ServiceComponentInfo/service_name").anyTimes();
 
@@ -63,7 +64,7 @@ public class DefaultRendererTest {
     TreeNode<Set<String>> propertyTree = renderer.finalizeProperties(queryTree, false);
     // no properties should have been added
     assertTrue(propertyTree.getObject().isEmpty());
-    assertEquals(1, propertyTree.getChildren().size());
+    assertEquals(2, propertyTree.getChildren().size());
 
     TreeNode<Set<String>> componentNode = propertyTree.getChild("Component");
     assertEquals(2, componentNode.getObject().size());

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/MinimalRendererTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/MinimalRendererTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/MinimalRendererTest.java
index 16cbb2a..9b03c51 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/MinimalRendererTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/MinimalRendererTest.java
@@ -57,6 +57,7 @@ public class MinimalRendererTest {
 
     // schema expectations
     expect(schemaFactory.getSchema(Resource.Type.Component)).andReturn(schema).anyTimes();
+    expect(schemaFactory.getSchema(Resource.Type.Alert)).andReturn(schema).anyTimes();
     expect(schema.getKeyPropertyId(Resource.Type.Component)).andReturn("ServiceComponentInfo/component_name").anyTimes();
 
     replay(schemaFactory, schema);
@@ -69,7 +70,7 @@ public class MinimalRendererTest {
     TreeNode<Set<String>> propertyTree = renderer.finalizeProperties(queryTree, false);
     // no properties should have been added
     assertTrue(propertyTree.getObject().isEmpty());
-    assertEquals(1, propertyTree.getChildren().size());
+    assertEquals(2, propertyTree.getChildren().size());
 
     TreeNode<Set<String>> componentNode = propertyTree.getChild("Component");
     assertEquals(1, componentNode.getObject().size());

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ClusterResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ClusterResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ClusterResourceDefinitionTest.java
index eabb5ab..7296e8d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ClusterResourceDefinitionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/ClusterResourceDefinitionTest.java
@@ -50,7 +50,7 @@ public class ClusterResourceDefinitionTest {
     ResourceDefinition resource = new ClusterResourceDefinition();
     Set<SubResourceDefinition> subResources = resource.getSubResourceDefinitions();
 
-    assertEquals(9, subResources.size());
+    assertEquals(10, subResources.size());
     assertTrue(includesType(subResources, Resource.Type.Service));
     assertTrue(includesType(subResources, Resource.Type.Host));
     assertTrue(includesType(subResources, Resource.Type.Configuration));
@@ -60,6 +60,7 @@ public class ClusterResourceDefinitionTest {
     assertTrue(includesType(subResources, Resource.Type.AlertDefinition));
     assertTrue(includesType(subResources, Resource.Type.ServiceConfigVersion));
     assertTrue(includesType(subResources, Resource.Type.ClusterPrivilege));
+    assertTrue(includesType(subResources, Resource.Type.Alert));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertResourceProviderTest.java
new file mode 100644
index 0000000..4fd44af
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertResourceProviderTest.java
@@ -0,0 +1,241 @@
+/**
+ * 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.controller.internal;
+
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.captureLong;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+
+import org.apache.ambari.server.controller.AmbariManagementController;
+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.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+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.orm.entities.AlertHistoryEntity;
+import org.apache.ambari.server.state.AlertState;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.easymock.Capture;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+
+/**
+ * Test the AlertResourceProvider class
+ */
+public class AlertResourceProviderTest {
+
+  private static final Long ALERT_VALUE_ID = Long.valueOf(1000L);
+  private static final String ALERT_VALUE_LABEL = "My Label";
+  private static final Long ALERT_VALUE_TIMESTAMP = Long.valueOf(1L);
+  private static final String ALERT_VALUE_TEXT = "My Text";
+  private static final String ALERT_VALUE_COMPONENT = "component";
+  private static final String ALERT_VALUE_HOSTNAME = "host";
+  private static final String ALERT_VALUE_SERVICE = "service";
+
+  private AlertsDAO m_dao;
+//  private Injector m_injector;
+  private AmbariManagementController m_amc;
+
+  @Before
+  @SuppressWarnings("boxing")  
+  public void before() throws Exception {
+    Injector m_injector = Guice.createInjector(new MockModule());
+
+    m_amc = m_injector.getInstance(AmbariManagementController.class);
+
+    Cluster cluster = EasyMock.createMock(Cluster.class);
+    Clusters clusters = m_injector.getInstance(Clusters.class);
+    expect(m_amc.getClusters()).andReturn(clusters).atLeastOnce();
+    expect(clusters.getCluster(capture(new Capture<String>()))).andReturn(cluster).atLeastOnce();
+    expect(cluster.getClusterId()).andReturn(Long.valueOf(1L));
+    
+    replay(m_amc, clusters, cluster);
+    
+    m_dao = m_injector.getInstance(AlertsDAO.class);
+    
+    AlertResourceProvider.init(m_injector);
+  }
+
+
+  /**
+   * @throws Exception
+   */
+  @Test
+  public void testGetCluster() throws Exception {
+    expect(m_dao.findCurrentByCluster(
+        captureLong(new Capture<Long>()))).andReturn(getClusterMockEntities()).anyTimes();
+    
+    replay(m_dao);
+
+    Request request = PropertyHelper.getReadRequest(
+        AlertResourceProvider.ALERT_ID,
+        AlertResourceProvider.ALERT_NAME,
+        AlertResourceProvider.ALERT_LABEL);
+    
+    Predicate predicate = new PredicateBuilder().property(
+        AlertResourceProvider.ALERT_CLUSTER_NAME).equals("c1").toPredicate();
+    
+    AlertResourceProvider provider = createProvider();
+    Set<Resource> results = provider.getResources(request, predicate);
+
+    assertEquals(1, results.size());
+
+    Resource r = results.iterator().next();
+    assertEquals("c1", r.getPropertyValue(AlertResourceProvider.ALERT_CLUSTER_NAME));
+    
+    verify(m_dao);
+  }
+  
+  /**
+   * Test for service
+   */
+  @Test
+  public void testGetService() throws Exception {
+    expect(m_dao.findCurrentByService(captureLong(new Capture<Long>()),
+        capture(new Capture<String>()))).andReturn(getClusterMockEntities()).anyTimes();
+    
+    replay(m_dao);
+
+    Request request = PropertyHelper.getReadRequest(
+        AlertResourceProvider.ALERT_ID,
+        AlertResourceProvider.ALERT_NAME,
+        AlertResourceProvider.ALERT_LABEL);
+    
+    Predicate predicate = new PredicateBuilder().property(
+        AlertResourceProvider.ALERT_CLUSTER_NAME).equals("c1").and()
+        .property(AlertResourceProvider.ALERT_SERVICE).equals(ALERT_VALUE_SERVICE).toPredicate();
+    
+    AlertResourceProvider provider = createProvider();
+    Set<Resource> results = provider.getResources(request, predicate);
+
+    assertEquals(1, results.size());
+
+    Resource r = results.iterator().next();
+    assertEquals("c1", r.getPropertyValue(AlertResourceProvider.ALERT_CLUSTER_NAME));
+    assertEquals(ALERT_VALUE_SERVICE, r.getPropertyValue(AlertResourceProvider.ALERT_SERVICE));
+    
+    verify(m_dao);
+  }  
+
+  /**
+   * Test for service
+   */
+  @Test
+  public void testGetHost() throws Exception {
+    expect(m_dao.findCurrentByHost(captureLong(new Capture<Long>()),
+        capture(new Capture<String>()))).andReturn(getClusterMockEntities()).anyTimes();
+    
+    replay(m_dao);
+
+    Request request = PropertyHelper.getReadRequest(
+        AlertResourceProvider.ALERT_ID,
+        AlertResourceProvider.ALERT_NAME,
+        AlertResourceProvider.ALERT_LABEL);
+    
+    Predicate predicate = new PredicateBuilder().property(
+        AlertResourceProvider.ALERT_CLUSTER_NAME).equals("c1").and()
+        .property(AlertResourceProvider.ALERT_HOST).equals(ALERT_VALUE_HOSTNAME).toPredicate();
+    
+    AlertResourceProvider provider = createProvider();
+    Set<Resource> results = provider.getResources(request, predicate);
+
+    assertEquals(1, results.size());
+
+    Resource r = results.iterator().next();
+    assertEquals("c1", r.getPropertyValue(AlertResourceProvider.ALERT_CLUSTER_NAME));
+    assertEquals(ALERT_VALUE_HOSTNAME, r.getPropertyValue(AlertResourceProvider.ALERT_HOST));
+    
+    verify(m_dao);
+  }  
+
+  
+  
+  private AlertResourceProvider createProvider() {
+    return new AlertResourceProvider(
+        PropertyHelper.getPropertyIds(Resource.Type.Alert),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.Alert),
+        m_amc);
+  }
+
+  /**
+   * @return
+   */
+  private List<AlertCurrentEntity> getClusterMockEntities() throws Exception {
+    AlertCurrentEntity current = new AlertCurrentEntity();
+    current.setAlertId(Long.valueOf(1000L));
+    current.setLatestTimestamp(Long.valueOf(1L));
+    current.setOriginalTimestamp(Long.valueOf(2L));
+    
+    AlertHistoryEntity history = new AlertHistoryEntity();
+    history.setAlertId(ALERT_VALUE_ID);
+    history.setAlertInstance(null);
+    history.setAlertLabel(ALERT_VALUE_LABEL);
+    history.setAlertState(AlertState.OK);
+    history.setAlertText(ALERT_VALUE_TEXT);
+    history.setAlertTimestamp(ALERT_VALUE_TIMESTAMP);
+    history.setClusterId(Long.valueOf(1L));
+    history.setComponentName(ALERT_VALUE_COMPONENT);
+    history.setHostName(ALERT_VALUE_HOSTNAME);
+    history.setServiceName(ALERT_VALUE_SERVICE);
+    
+    AlertDefinitionEntity definition = new AlertDefinitionEntity();
+    
+    history.setAlertDefinition(definition);
+    current.setAlertHistory(history);
+    
+    return Arrays.asList(current);
+  }
+
+
+  /**
+  *
+  */
+  private class MockModule implements Module {
+    @Override
+    public void configure(Binder binder) {
+      binder.bind(EntityManager.class).toInstance(EasyMock.createMock(EntityManager.class));
+      binder.bind(AlertsDAO.class).toInstance(EasyMock.createMock(AlertsDAO.class));
+      binder.bind(AmbariManagementController.class).toInstance(createMock(AmbariManagementController.class));
+      
+      Clusters clusters = EasyMock.createNiceMock(Clusters.class);
+      
+      binder.bind(Clusters.class).toInstance(clusters);
+      
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/84c16c5c/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertsDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertsDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertsDAOTest.java
index 4500c1c..7c206a2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertsDAOTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertsDAOTest.java
@@ -81,13 +81,13 @@ public class AlertsDAOTest {
       definition.setComponentName(null);
       definition.setClusterId(clusterId);
       definition.setHash(UUID.randomUUID().toString());
-      definition.setScheduleInterval(60);
+      definition.setScheduleInterval(Integer.valueOf(60));
       definition.setScope(Scope.SERVICE);
       definition.setSource("Source " + i);
       definition.setSourceType("SCRIPT");
       definitionDao.create(definition);
     }
-
+    
     List<AlertDefinitionEntity> definitions = definitionDao.findAll();
     assertNotNull(definitions);
     assertEquals(5, definitions.size());
@@ -192,6 +192,54 @@ public class AlertsDAOTest {
     assertNotNull(currentAlerts);
     assertEquals(0, currentAlerts.size());
   }
+  
+  /**
+   * Test looking up current by a host name.
+   */
+  @Test
+  public void testFindCurrentByHost() {
+    // create a host
+    AlertDefinitionEntity hostDef = new AlertDefinitionEntity();
+    hostDef.setDefinitionName("Host Alert Definition ");
+    hostDef.setServiceName("HostService");
+    hostDef.setComponentName(null);
+    hostDef.setClusterId(clusterId);
+    hostDef.setHash(UUID.randomUUID().toString());
+    hostDef.setScheduleInterval(Integer.valueOf(60));
+    hostDef.setScope(Scope.HOST);
+    hostDef.setSource("HostService");
+    hostDef.setSourceType("SCRIPT");
+    definitionDao.create(hostDef);
+    
+    // history for the definition
+    AlertHistoryEntity history = new AlertHistoryEntity();
+    history.setServiceName(hostDef.getServiceName());
+    history.setClusterId(clusterId);
+    history.setAlertDefinition(hostDef);
+    history.setAlertLabel(hostDef.getDefinitionName());
+    history.setAlertText(hostDef.getDefinitionName());
+    history.setAlertTimestamp(Long.valueOf(1L));
+    history.setHostName("h2");
+    history.setAlertState(AlertState.OK);
+    
+    // current for the history
+    AlertCurrentEntity current = new AlertCurrentEntity();
+    current.setOriginalTimestamp(1L);
+    current.setLatestTimestamp(2L);
+    current.setAlertHistory(history);
+    dao.create(current);
+    
+    
+    List<AlertCurrentEntity> currentAlerts = dao.findCurrentByHost(clusterId, history.getHostName());
+
+    assertNotNull(currentAlerts);
+    assertEquals(1, currentAlerts.size());
+
+    currentAlerts = dao.findCurrentByHost(clusterId, "foo");
+
+    assertNotNull(currentAlerts);
+    assertEquals(0, currentAlerts.size());
+  }  
 
   /**
    *