@RequiresSession
  public List<AlertDefinitionEntity> findByServiceMaster(long clusterId,
      Set<String> services) {
    if (null == services || services.size() == 0) {
      return Collections.emptyList();
    }

    TypedQuery<AlertDefinitionEntity> query = entityManagerProvider.get().createNamedQuery(
        "AlertDefinitionEntity.findByServiceMaster",
        AlertDefinitionEntity.class);

    query.setParameter("clusterId", clusterId);
    query.setParameter("services", services);
    query.setParameter("scope", Scope.SERVICE);

    return daoUtils.selectList(query);
  }
Gets all alert definitions for the specified services that do not have a
component and do not belong to AGGREGATE source type. These definitions are assumed to be run on the master hosts.

@param clusterId
         the ID of the cluster.
@param services
         the services to match on.

@return all alert definitions for the services or empty list if none exist
        (never {@code null}).
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAO.java