You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2015/06/14 20:48:43 UTC

ambari git commit: AMBARI-11899 Perf Cluster: Heatmaps page not loading (dsen)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 3390b8c32 -> 3131ad828


AMBARI-11899 Perf Cluster: Heatmaps page not loading (dsen)


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

Branch: refs/heads/branch-2.1
Commit: 3131ad828ff52e72fa5b05f16f71d195d6c79bff
Parents: 3390b8c
Author: Dmytro Sen <ds...@apache.org>
Authored: Sun Jun 14 21:48:16 2015 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Sun Jun 14 21:48:16 2015 +0300

----------------------------------------------------------------------
 .../ApplicationHistoryManagerImpl.java          |   1 -
 .../ApplicationHistoryServer.java               |   1 -
 .../metrics/loadsimulator/LoadRunner.java       |   2 -
 .../loadsimulator/MetricsSenderWorker.java      |   2 +-
 .../timeline/HBaseTimelineMetricStore.java      |  22 +--
 .../metrics/timeline/PhoenixHBaseAccessor.java  |  37 +++--
 .../metrics/timeline/Precision.java             |   1 -
 .../timeline/TimelineMetricConfiguration.java   |   1 -
 .../metrics/timeline/TimelineMetricStore.java   |   6 +-
 .../metrics/timeline/query/Condition.java       |   2 +-
 .../timeline/query/DefaultCondition.java        |  30 ++--
 .../timeline/query/PhoenixTransactSQL.java      |  93 ++++++++----
 .../query/SplitByMetricNamesCondition.java      |  25 +++-
 .../webapp/TimelineWebServices.java             |  11 +-
 .../metrics/timeline/ITClusterAggregator.java   |   4 +-
 .../metrics/timeline/ITMetricAggregator.java    |   6 +-
 .../timeline/ITPhoenixHBaseAccessor.java        |  12 +-
 .../timeline/TestPhoenixTransactSQL.java        |  48 ++++---
 .../timeline/TestTimelineMetricStore.java       |   4 +-
 .../metrics/timeline/AMSPropertyProvider.java   | 140 +++++++++++--------
 .../timeline/AMSPropertyProviderTest.java       |   8 +-
 .../ams/multiple_component_regexp_metrics.json  |   2 -
 .../resources/ams/multiple_host_metrics.json    |   4 +-
 .../resources/ams/single_component_metrics.json |   3 +-
 .../ams/single_host_component_metrics.json      |   4 +-
 .../test/resources/ams/single_host_metric.json  |   4 +-
 26 files changed, 273 insertions(+), 200 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java
index 84e9a39..386a9f1 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java
@@ -39,7 +39,6 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData;
 import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationHistoryData;
 import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData;
-import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.MemoryTimelineStore;
 import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
 
 import com.google.common.annotations.VisibleForTesting;

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
index ed4d057..24223a5 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
@@ -42,7 +42,6 @@ import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.LeveldbT
 import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.AHSWebApp;
 import org.apache.hadoop.yarn.webapp.WebApp;
 import org.apache.hadoop.yarn.webapp.WebApps;
-import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
 
 import com.google.common.annotations.VisibleForTesting;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/LoadRunner.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/LoadRunner.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/LoadRunner.java
index 7974a5f..e5da0a3 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/LoadRunner.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/LoadRunner.java
@@ -31,8 +31,6 @@ import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics
 import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics
   .loadsimulator.net.RestMetricsSender;
 import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics
-  .loadsimulator.net.StdOutMetricsSender;
-import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics
   .loadsimulator.util.TimeStampProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/MetricsSenderWorker.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/MetricsSenderWorker.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/MetricsSenderWorker.java
index c027933..d111eb6 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/MetricsSenderWorker.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/MetricsSenderWorker.java
@@ -52,7 +52,7 @@ public class MetricsSenderWorker implements Callable<String> {
     AppMetrics hostMetrics = hmg.createMetrics();
 
     try {
-      String request = new Json().serialize(hostMetrics);
+      String request = new Json().serialize(hostMetrics); //inject?
       String response = sender.pushMetrics(request);
 
       return response;

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java
index f5d6bc0..c615804 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java
@@ -123,7 +123,7 @@ public class HBaseTimelineMetricStore extends AbstractService
 
   @Override
   public TimelineMetrics getTimelineMetrics(List<String> metricNames,
-      String hostname, String applicationId, String instanceId,
+      List<String> hostnames, String applicationId, String instanceId,
       Long startTime, Long endTime, Precision precision, Integer limit,
       boolean groupedByHosts) throws SQLException, IOException {
 
@@ -142,18 +142,18 @@ public class HBaseTimelineMetricStore extends AbstractService
 
     Condition condition = new DefaultCondition(
       new ArrayList<String>(metricFunctions.keySet()),
-      hostname, applicationId, instanceId, startTime, endTime,
+      hostnames, applicationId, instanceId, startTime, endTime,
       precision, limit, groupedByHosts);
 
-    if (hostname == null) {
-      TimelineMetrics metrics = hBaseAccessor.getAggregateMetricRecords
-        (condition,  metricFunctions);
+    TimelineMetrics metrics;
 
-      return postProcessMetrics(metrics);
+    if (hostnames == null || hostnames.isEmpty()) {
+      metrics = hBaseAccessor.getAggregateMetricRecords(condition,
+          metricFunctions);
+    } else {
+      metrics = hBaseAccessor.getMetricRecords(condition, metricFunctions);
     }
-
-    return postProcessMetrics(
-      hBaseAccessor.getMetricRecords(condition, metricFunctions));
+    return postProcessMetrics(metrics);
   }
 
   private TimelineMetrics postProcessMetrics(TimelineMetrics metrics) {
@@ -227,7 +227,7 @@ public class HBaseTimelineMetricStore extends AbstractService
   }
 
   @Override
-  public TimelineMetric getTimelineMetric(String metricName, String hostname,
+  public TimelineMetric getTimelineMetric(String metricName, List<String> hostnames,
       String applicationId, String instanceId, Long startTime,
       Long endTime, Precision precision, Integer limit)
       throws SQLException, IOException {
@@ -247,7 +247,7 @@ public class HBaseTimelineMetricStore extends AbstractService
       parseMetricNamesToAggregationFunctions(Collections.singletonList(metricName));
 
     Condition condition = new DefaultCondition(
-      new ArrayList<String>(metricFunctions.keySet()), hostname, applicationId,
+      new ArrayList<String>(metricFunctions.keySet()), hostnames, applicationId,
       instanceId, startTime, endTime, precision, limit, true);
     TimelineMetrics metrics = hBaseAccessor.getMetricRecords(condition,
       metricFunctions);

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java
index bf1ae66..8e5d101 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/PhoenixHBaseAccessor.java
@@ -471,28 +471,23 @@ public class PhoenixHBaseAccessor {
 
     validateConditionIsNotEmpty(condition);
 
-    PreparedStatement stmt = null;
-    SplitByMetricNamesCondition splitCondition =
-      new SplitByMetricNamesCondition(condition);
+    PreparedStatement stmt;
 
-    for (String metricName: splitCondition.getOriginalMetricNames()) {
-      splitCondition.setCurrentMetric(metricName);
-      stmt = PhoenixTransactSQL.prepareGetLatestMetricSqlStmt(conn,
-        splitCondition);
-      ResultSet rs = null;
-      try {
-        rs = stmt.executeQuery();
-        while (rs.next()) {
-          TimelineMetric metric = getLastTimelineMetricFromResultSet(rs);
-          metrics.getMetrics().add(metric);
-        }
-      } finally {
-        if (rs != null) {
-          try {
-            rs.close();
-          } catch (SQLException e) {
-            // Ignore
-          }
+    stmt = PhoenixTransactSQL.prepareGetLatestMetricSqlStmt(conn,
+        condition);
+    ResultSet rs = null;
+    try {
+      rs = stmt.executeQuery();
+      while (rs.next()) {
+        TimelineMetric metric = getLastTimelineMetricFromResultSet(rs);
+        metrics.getMetrics().add(metric);
+      }
+    } finally {
+      if (rs != null) {
+        try {
+          rs.close();
+        } catch (SQLException e) {
+          // Ignore
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/Precision.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/Precision.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/Precision.java
index ee0e87c..eb95bdb 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/Precision.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/Precision.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline
  * Is used to determine metrics aggregate table.
  *
  * @see org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.TimelineWebServices#getTimelineMetric
- * @see org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.TimelineWebServices#getTimelineMetrics
  */
 public enum Precision {
   SECONDS,

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricConfiguration.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricConfiguration.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricConfiguration.java
index 0461261..d1483ea 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricConfiguration.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricConfiguration.java
@@ -17,7 +17,6 @@
  */
 package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricStore.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricStore.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricStore.java
index fa52797..e1da289 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricStore.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TimelineMetricStore.java
@@ -29,7 +29,7 @@ public interface TimelineMetricStore {
    * This method retrieves metrics stored byu the Timeline store.
    *
    * @param metricNames Names of the metric, e.g.: cpu_user
-   * @param hostname Name of the host where the metric originated from
+   * @param hostnames Names of the host where the metric originated from
    * @param applicationId Id of the application to which this metric belongs
    * @param instanceId Application instance id.
    * @param startTime Start timestamp
@@ -42,7 +42,7 @@ public interface TimelineMetricStore {
    * @return {@link TimelineMetric}
    * @throws java.sql.SQLException
    */
-  TimelineMetrics getTimelineMetrics(List<String> metricNames, String hostname,
+  TimelineMetrics getTimelineMetrics(List<String> metricNames, List<String> hostnames,
       String applicationId, String instanceId, Long startTime,
       Long endTime, Precision precision, Integer limit, boolean groupedByHosts)
     throws SQLException, IOException;
@@ -52,7 +52,7 @@ public interface TimelineMetricStore {
    * Return all records for a single metric satisfying the filter criteria.
    * @return {@link TimelineMetric}
    */
-  TimelineMetric getTimelineMetric(String metricName, String hostname,
+  TimelineMetric getTimelineMetric(String metricName, List<String> hostname,
       String applicationId, String instanceId, Long startTime,
       Long endTime, Precision precision, Integer limit)
       throws SQLException, IOException;

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/Condition.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/Condition.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/Condition.java
index b52748f..e0cb3d0 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/Condition.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/Condition.java
@@ -28,7 +28,7 @@ public interface Condition {
   boolean isPointInTime();
   boolean isGrouped();
   void setStatement(String statement);
-  String getHostname();
+  List<String> getHostnames();
   Precision getPrecision();
   void setPrecision(Precision precision);
   String getAppId();

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/DefaultCondition.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/DefaultCondition.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/DefaultCondition.java
index 9d6b7df..462c8d9 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/DefaultCondition.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/DefaultCondition.java
@@ -25,7 +25,7 @@ import java.util.Set;
 
 public class DefaultCondition implements Condition {
   List<String> metricNames;
-  String hostname;
+  List<String> hostnames;
   String appId;
   String instanceId;
   Long startTime;
@@ -38,11 +38,11 @@ public class DefaultCondition implements Condition {
   String statement;
   Set<String> orderByColumns = new LinkedHashSet<String>();
 
-  public DefaultCondition(List<String> metricNames, String hostname, String appId,
+  public DefaultCondition(List<String> metricNames, List<String> hostnames, String appId,
                    String instanceId, Long startTime, Long endTime, Precision precision,
                    Integer limit, boolean grouped) {
     this.metricNames = metricNames;
-    this.hostname = hostname;
+    this.hostnames = hostnames;
     this.appId = appId;
     this.instanceId = instanceId;
     this.startTime = startTime;
@@ -107,7 +107,21 @@ public class DefaultCondition implements Condition {
       }
     }
 
-    appendConjunction = append(sb, appendConjunction, getHostname(), " HOSTNAME = ?");
+    if (hostnames != null && getHostnames().size() > 1) {
+      StringBuilder hostnamesCondition = new StringBuilder();
+      for (String hostname: getHostnames()) {
+        if (hostnamesCondition.length() > 0) {
+          hostnamesCondition.append(" ,");
+        } else {
+          hostnamesCondition.append(" HOSTNAME IN (");
+        }
+        hostnamesCondition.append('?');
+      }
+      hostnamesCondition.append(')');
+      appendConjunction = append(sb, appendConjunction, getHostnames(), hostnamesCondition.toString());
+    } else {
+      appendConjunction = append(sb, appendConjunction, getHostnames(), " HOSTNAME = ?");
+    }
     appendConjunction = append(sb, appendConjunction, getAppId(), " APP_ID = ?");
     appendConjunction = append(sb, appendConjunction, getInstanceId(), " INSTANCE_ID = ?");
     appendConjunction = append(sb, appendConjunction, getStartTime(), " SERVER_TIME >= ?");
@@ -130,8 +144,8 @@ public class DefaultCondition implements Condition {
     return appendConjunction;
   }
 
-  public String getHostname() {
-    return hostname == null || hostname.isEmpty() ? null : hostname;
+  public List<String> getHostnames() {
+    return hostnames;
   }
 
   public Precision getPrecision() {
@@ -202,7 +216,7 @@ public class DefaultCondition implements Condition {
 
   public boolean isEmpty() {
     return (metricNames == null || metricNames.isEmpty())
-      && (hostname == null || hostname.isEmpty())
+      && (hostnames == null || hostnames.isEmpty())
       && (appId == null || appId.isEmpty())
       && (instanceId == null || instanceId.isEmpty())
       && startTime == null
@@ -244,7 +258,7 @@ public class DefaultCondition implements Condition {
   public String toString() {
     return "Condition{" +
       "metricNames=" + metricNames +
-      ", hostname='" + hostname + '\'' +
+      ", hostnames='" + hostnames + '\'' +
       ", appId='" + appId + '\'' +
       ", instanceId='" + instanceId + '\'' +
       ", startTime=" + startTime +

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
index a630e77..2606773 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/PhoenixTransactSQL.java
@@ -25,10 +25,6 @@ import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -163,6 +159,31 @@ public class PhoenixTransactSQL {
     "METRICS " +
     "FROM %s";
 
+  /**
+   * Get latest metrics for a number of hosts
+   */
+  public static final String GET_LATEST_METRIC_SQL = "SELECT " +
+      "E.METRIC_NAME AS METRIC_NAME, E.HOSTNAME AS HOSTNAME, " +
+      "E.APP_ID AS APP_ID, E.INSTANCE_ID AS INSTANCE_ID, " +
+      "E.SERVER_TIME AS SERVER_TIME, E.START_TIME AS START_TIME, " +
+      "E.UNITS AS UNITS, E.METRIC_SUM AS METRIC_SUM, " +
+      "E.METRIC_MAX AS METRIC_MAX, E.METRIC_MIN AS METRIC_MIN, " +
+      "E.METRIC_COUNT AS METRIC_COUNT, E.METRICS AS METRICS " +
+      "FROM %s AS E " +
+      "INNER JOIN " +
+      "(SELECT METRIC_NAME, HOSTNAME, MAX(SERVER_TIME) AS MAX_SERVER_TIME, " +
+      "APP_ID, INSTANCE_ID " +
+      "FROM %s " +
+      "WHERE " +
+      "%s " +
+      "GROUP BY METRIC_NAME, HOSTNAME, APP_ID, INSTANCE_ID) " +
+      "AS I " +
+      "ON E.METRIC_NAME=I.METRIC_NAME " +
+      "AND E.HOSTNAME=I.HOSTNAME " +
+      "AND E.SERVER_TIME=I.MAX_SERVER_TIME " +
+      "AND E.APP_ID=I.APP_ID " +
+      "AND E.INSTANCE_ID=I.INSTANCE_ID";
+
   public static final String GET_METRIC_AGGREGATE_ONLY_SQL = "SELECT %s " +
     "METRIC_NAME, HOSTNAME, APP_ID, INSTANCE_ID, SERVER_TIME, " +
     "UNITS, " +
@@ -307,11 +328,13 @@ public class PhoenixTransactSQL {
         stmt.setString(pos, condition.getMetricNames().get(pos - 1));
       }
     }
-    if (condition.getHostname() != null) {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Setting pos: " + pos + ", value: " + condition.getHostname());
+    if (condition.getHostnames() != null) {
+      for (String hostname: condition.getHostnames()) {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Setting pos: " + pos + ", value: " + hostname);
+        }
+        stmt.setString(pos++, hostname);
       }
-      stmt.setString(pos++, condition.getHostname());
     }
     if (condition.getAppId() != null) {
       if (LOG.isDebugEnabled()) {
@@ -390,27 +413,33 @@ public class PhoenixTransactSQL {
     if (condition.getStatement() != null) {
       stmtStr = condition.getStatement();
     } else {
-      stmtStr = String.format(GET_METRIC_SQL,
-        "",
-        METRICS_RECORD_TABLE_NAME);
-    }
-
-    StringBuilder sb = new StringBuilder(stmtStr);
-    sb.append(" WHERE ");
-    sb.append(condition.getConditionClause());
-    String orderByClause = condition.getOrderByClause(false);
-    if (orderByClause != null) {
-      sb.append(orderByClause);
-    } else {
-      sb.append(" ORDER BY METRIC_NAME DESC, HOSTNAME DESC, SERVER_TIME DESC ");
+      //if not a single metric for a single host
+      if (condition.getHostnames().size() > 1
+        && condition.getMetricNames().size() > 1) {
+        stmtStr = String.format(GET_LATEST_METRIC_SQL,
+          METRICS_RECORD_TABLE_NAME,
+          METRICS_RECORD_TABLE_NAME,
+          condition.getConditionClause());
+      } else {
+        StringBuilder sb = new StringBuilder(String.format(GET_METRIC_SQL,
+          "",
+          METRICS_RECORD_TABLE_NAME));
+        sb.append(" WHERE ");
+        sb.append(condition.getConditionClause());
+        String orderByClause = condition.getOrderByClause(false);
+        if (orderByClause != null) {
+          sb.append(orderByClause);
+        } else {
+          sb.append(" ORDER BY METRIC_NAME DESC, HOSTNAME DESC, SERVER_TIME DESC ");
+        }
+        stmtStr = sb.toString();
+      }
     }
 
-    sb.append(" LIMIT ").append(condition.getMetricNames().size());
-
     if (LOG.isDebugEnabled()) {
-      LOG.debug("SQL: " + sb.toString() + ", condition: " + condition);
+      LOG.debug("SQL: " + stmtStr + ", condition: " + condition);
     }
-    PreparedStatement stmt = connection.prepareStatement(sb.toString());
+    PreparedStatement stmt = connection.prepareStatement(stmtStr);
     int pos = 1;
     if (condition.getMetricNames() != null) {
       //IGNORE condition limit, set one based on number of metric names
@@ -421,11 +450,13 @@ public class PhoenixTransactSQL {
         stmt.setString(pos, condition.getMetricNames().get(pos - 1));
       }
     }
-    if (condition.getHostname() != null) {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Setting pos: " + pos + ", value: " + condition.getHostname());
+    if (condition.getHostnames() != null) {
+      for (String hostname: condition.getHostnames()) {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Setting pos: " + pos + ", value: " + hostname);
+        }
+        stmt.setString(pos++, hostname);
       }
-      stmt.setString(pos++, condition.getHostname());
     }
     if (condition.getAppId() != null) {
       if (LOG.isDebugEnabled()) {
@@ -437,7 +468,7 @@ public class PhoenixTransactSQL {
       if (LOG.isDebugEnabled()) {
         LOG.debug("Setting pos: " + pos + ", value: " + condition.getInstanceId());
       }
-      stmt.setString(pos++, condition.getInstanceId());
+      stmt.setString(pos, condition.getInstanceId());
     }
 
     if (condition.getFetchSize() != null) {
@@ -571,7 +602,7 @@ public class PhoenixTransactSQL {
       stmt.setString(pos++, condition.getAppId());
     }
     if (condition.getInstanceId() != null) {
-      stmt.setString(pos++, condition.getInstanceId());
+      stmt.setString(pos, condition.getInstanceId());
     }
 
     return stmt;

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/SplitByMetricNamesCondition.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/SplitByMetricNamesCondition.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/SplitByMetricNamesCondition.java
index 00d6a82..c8b8709 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/SplitByMetricNamesCondition.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/query/SplitByMetricNamesCondition.java
@@ -21,7 +21,7 @@ import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.
 
 import java.util.Collections;
 import java.util.List;
-
+// TODO get rid of this class
 public class SplitByMetricNamesCondition implements Condition {
   private final Condition adaptee;
   private String currentMetric;
@@ -56,8 +56,8 @@ public class SplitByMetricNamesCondition implements Condition {
   }
 
   @Override
-  public String getHostname() {
-    return adaptee.getHostname();
+  public List<String> getHostnames() {
+    return adaptee.getHostnames();
   }
 
   @Override
@@ -95,9 +95,22 @@ public class SplitByMetricNamesCondition implements Condition {
 
       appendConjunction = true;
     }
-
-    appendConjunction = DefaultCondition.append(sb, appendConjunction,
-      getHostname(), " HOSTNAME = ?");
+    // TODO prevent user from using this method with multiple hostnames and SQL LIMIT clause
+    if (getHostnames() != null && getHostnames().size() > 1) {
+      StringBuilder hostnamesCondition = new StringBuilder();
+      for (String hostname: getHostnames()) {
+        if (hostnamesCondition.length() > 0) {
+          hostnamesCondition.append(" ,");
+        } else {
+          hostnamesCondition.append(" HOSTNAME IN (");
+        }
+        hostnamesCondition.append('?');
+      }
+      hostnamesCondition.append(')');
+      appendConjunction = DefaultCondition.append(sb, appendConjunction, getHostnames(), hostnamesCondition.toString());
+    } else {
+      appendConjunction = DefaultCondition.append(sb, appendConjunction, getHostnames(), " HOSTNAME = ?");
+    }
     appendConjunction = DefaultCondition.append(sb, appendConjunction,
       getAppId(), " APP_ID = ?");
     appendConjunction = DefaultCondition.append(sb, appendConjunction,

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TimelineWebServices.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TimelineWebServices.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TimelineWebServices.java
index bf7cefb..f738f16 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TimelineWebServices.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TimelineWebServices.java
@@ -24,7 +24,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
-import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents;
@@ -61,7 +60,6 @@ import javax.xml.bind.annotation.XmlRootElement;
 import java.io.IOException;
 import java.sql.SQLException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.HashSet;
@@ -309,9 +307,10 @@ public class TimelineWebServices {
           "endTime: " + endTime);
       }
 
-      return timelineMetricStore.getTimelineMetric(metricName, hostname,
-        appId, instanceId, parseLongStr(startTime), parseLongStr(endTime),
-        Precision.getPrecision(precision), parseIntStr(limit));
+      return timelineMetricStore.getTimelineMetric(metricName,
+        parseListStr(hostname, ","), appId, instanceId, parseLongStr(startTime),
+        parseLongStr(endTime), Precision.getPrecision(precision),
+        parseIntStr(limit));
     } catch (NumberFormatException ne) {
       throw new BadRequestException("startTime, endTime and limit should be " +
         "numeric values");
@@ -371,7 +370,7 @@ public class TimelineWebServices {
       }
 
       return timelineMetricStore.getTimelineMetrics(
-        parseListStr(metricNames, ","), hostname, appId, instanceId,
+        parseListStr(metricNames, ","), parseListStr(hostname, ","), appId, instanceId,
         parseLongStr(startTime), parseLongStr(endTime),
         Precision.getPrecision(precision), parseIntStr(limit),
         parseBoolean(grouped));

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITClusterAggregator.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITClusterAggregator.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITClusterAggregator.java
index fb3bd31..13fa348 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITClusterAggregator.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITClusterAggregator.java
@@ -53,10 +53,8 @@ import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.ti
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.MetricTestHelper.prepareSingleTimelineMetric;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.CLUSTER_AGGREGATOR_APP_IDS;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.GET_CLUSTER_AGGREGATE_SQL;
-import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.GET_METRIC_SQL;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.METRICS_CLUSTER_AGGREGATE_HOURLY_TABLE_NAME;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.METRICS_CLUSTER_AGGREGATE_TABLE_NAME;
-import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.METRICS_RECORD_TABLE_NAME;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.query.PhoenixTransactSQL.NATIVE_TIME_RANGE_DELTA;
 
 public class ITClusterAggregator extends AbstractMiniHBaseClusterTest {
@@ -565,4 +563,4 @@ public class ITClusterAggregator extends AbstractMiniHBaseClusterTest {
     Statement stmt = conn.createStatement();
     return stmt.executeQuery(query);
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITMetricAggregator.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITMetricAggregator.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITMetricAggregator.java
index 5f646fe..b480b7a 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITMetricAggregator.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITMetricAggregator.java
@@ -36,6 +36,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.Statement;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
@@ -89,8 +90,9 @@ public class ITMetricAggregator extends AbstractMiniHBaseClusterTest {
     TimelineMetrics metricsSent = prepareTimelineMetrics(startTime, "local");
     hdb.insertMetricRecords(metricsSent);
 
-    Condition queryCondition = new DefaultCondition(null, "local", null, null,
-      startTime, startTime + (15 * 60 * 1000), null, null, false);
+    Condition queryCondition = new DefaultCondition(null,
+        Collections.singletonList("local"), null, null, startTime,
+        startTime + (15 * 60 * 1000), null, null, false);
     TimelineMetrics recordRead = hdb.getMetricRecords(queryCondition, null);
 
     // THEN

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java
index 00db767..09f1584 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/ITPhoenixHBaseAccessor.java
@@ -98,8 +98,8 @@ public class ITPhoenixHBaseAccessor extends AbstractMiniHBaseClusterTest {
     // WHEN
     long endTime = ctime + minute;
     Condition condition = new DefaultCondition(
-      Collections.singletonList("disk_free"), "local1", null, null, startTime,
-      endTime, Precision.SECONDS, null, true);
+      Collections.singletonList("disk_free"), Collections.singletonList("local1"),
+      null, null, startTime, endTime, Precision.SECONDS, null, true);
     TimelineMetrics timelineMetrics = hdb.getMetricRecords(condition,
       singletonValueFunctionMap("disk_free"));
 
@@ -133,8 +133,8 @@ public class ITPhoenixHBaseAccessor extends AbstractMiniHBaseClusterTest {
 
     // WHEN
     Condition condition = new DefaultCondition(
-        Collections.singletonList("disk_free"), "local1", null, null, startTime,
-        endTime, Precision.MINUTES, null, false);
+      Collections.singletonList("disk_free"), Collections.singletonList("local1"),
+      null, null, startTime, endTime, Precision.MINUTES, null, false);
     TimelineMetrics timelineMetrics = hdb.getMetricRecords(condition,
       singletonValueFunctionMap("disk_free"));
 
@@ -184,8 +184,8 @@ public class ITPhoenixHBaseAccessor extends AbstractMiniHBaseClusterTest {
 
     // WHEN
     Condition condition = new DefaultCondition(
-        Collections.singletonList("disk_used"), "test_host", "test_app", null,
-        startTime, endTime, Precision.HOURS, null, true);
+      Collections.singletonList("disk_used"), Collections.singletonList("test_host"),
+      "test_app", null, startTime, endTime, Precision.HOURS, null, true);
     TimelineMetrics timelineMetrics = hdb.getMetricRecords(condition,
       singletonValueFunctionMap("disk_used"));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
index 2aefce3..ee7a468 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
@@ -39,8 +39,8 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testConditionClause() throws Exception {
     Condition condition = new DefaultCondition(
-      Arrays.asList("cpu_user", "mem_free"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, null, null, false);
+      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      "a1", "i1", 1407959718L, 1407959918L, null, null, false);
 
     String preparedClause = condition.getConditionClause().toString();
     String expectedClause = "(METRIC_NAME IN (?, ?)) AND HOSTNAME = ? AND " +
@@ -53,8 +53,8 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testSplitByMetricNamesCondition() throws Exception {
     Condition c = new DefaultCondition(
-      Arrays.asList("cpu_user", "mem_free"), "h1", "a1", "i1",
-      1407959718L, 1407959918L, null, null, false);
+      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      "a1", "i1", 1407959718L, 1407959918L, null, null, false);
 
     SplitByMetricNamesCondition condition = new SplitByMetricNamesCondition(c);
     condition.setCurrentMetric(c.getMetricNames().get(0));
@@ -70,8 +70,9 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testLikeConditionClause() throws Exception {
     Condition condition = new DefaultCondition(
-        Arrays.asList("cpu_user", "some=%.metric"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, null, null, false);
+      Arrays.asList("cpu_user", "some=%.metric"),
+      Collections.singletonList("h1"), "a1", "i1", 1407959718L, 1407959918L,
+      null, null, false);
 
     String preparedClause = condition.getConditionClause().toString();
     String expectedClause = "(METRIC_NAME IN (?) OR METRIC_NAME LIKE ?) AND HOSTNAME = ? AND " +
@@ -82,7 +83,7 @@ public class TestPhoenixTransactSQL {
 
 
     condition = new DefaultCondition(
-        Collections.<String>emptyList(), "h1", "a1", "i1",
+        Collections.<String>emptyList(), Collections.singletonList("h1"), "a1", "i1",
         1407959718L, 1407959918L, null, null, false);
 
     preparedClause = condition.getConditionClause().toString();
@@ -94,7 +95,7 @@ public class TestPhoenixTransactSQL {
 
 
     condition = new DefaultCondition(
-        null, "h1", "a1", "i1",
+        null, Collections.singletonList("h1"), "a1", "i1",
         1407959718L, 1407959918L, null, null, false);
 
     preparedClause = condition.getConditionClause().toString();
@@ -106,7 +107,7 @@ public class TestPhoenixTransactSQL {
 
 
     condition = new DefaultCondition(
-        Arrays.asList("some=%.metric"), "h1", "a1", "i1",
+        Arrays.asList("some=%.metric"), Collections.singletonList("h1"), "a1", "i1",
         1407959718L, 1407959918L, null, null, false);
 
     preparedClause = condition.getConditionClause().toString();
@@ -118,8 +119,9 @@ public class TestPhoenixTransactSQL {
 
 
     condition = new DefaultCondition(
-        Arrays.asList("some=%.metric1", "some=%.metric2", "some=%.metric3"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, null, null, false);
+      Arrays.asList("some=%.metric1", "some=%.metric2", "some=%.metric3"),
+      Collections.singletonList("h1"), "a1", "i1",
+      1407959718L, 1407959918L, null, null, false);
 
     preparedClause = condition.getConditionClause().toString();
     expectedClause = "(METRIC_NAME LIKE ? OR METRIC_NAME LIKE ? OR METRIC_NAME LIKE ?) AND HOSTNAME = ? AND " +
@@ -132,8 +134,8 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testPrepareGetAggregatePrecisionMINUTES() throws SQLException {
     Condition condition = new DefaultCondition(
-        Arrays.asList("cpu_user", "mem_free"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, Precision.MINUTES, null, false);
+      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      "a1", "i1", 1407959718L, 1407959918L, Precision.MINUTES, null, false);
     Connection connection = createNiceMock(Connection.class);
     PreparedStatement preparedStatement = createNiceMock(PreparedStatement.class);
     Capture<String> stmtCapture = new Capture<String>();
@@ -150,8 +152,8 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testPrepareGetAggregateNoPrecision() throws SQLException {
     Condition condition = new DefaultCondition(
-        Arrays.asList("cpu_user", "mem_free"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, null, null, false);
+      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      "a1", "i1", 1407959718L, 1407959918L, null, null, false);
     Connection connection = createNiceMock(Connection.class);
     PreparedStatement preparedStatement = createNiceMock(PreparedStatement.class);
     Capture<String> stmtCapture = new Capture<String>();
@@ -168,8 +170,8 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testPrepareGetAggregatePrecisionHours() throws SQLException {
     Condition condition = new DefaultCondition(
-        Arrays.asList("cpu_user", "mem_free"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, Precision.HOURS, null, false);
+      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      "a1", "i1", 1407959718L, 1407959918L, Precision.HOURS, null, false);
     Connection connection = createNiceMock(Connection.class);
     PreparedStatement preparedStatement = createNiceMock(PreparedStatement.class);
     Capture<String> stmtCapture = new Capture<String>();
@@ -186,8 +188,8 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testPrepareGetMetricsPrecisionMinutes() throws SQLException {
     Condition condition = new DefaultCondition(
-        Arrays.asList("cpu_user", "mem_free"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, Precision.MINUTES, null, false);
+      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      "a1", "i1", 1407959718L, 1407959918L, Precision.MINUTES, null, false);
     Connection connection = createNiceMock(Connection.class);
     PreparedStatement preparedStatement = createNiceMock(PreparedStatement.class);
     Capture<String> stmtCapture = new Capture<String>();
@@ -204,8 +206,8 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testPrepareGetMetricsNoPrecision() throws SQLException {
     Condition condition = new DefaultCondition(
-        Arrays.asList("cpu_user", "mem_free"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, null, null, false);
+      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      "a1", "i1", 1407959718L, 1407959918L, null, null, false);
     Connection connection = createNiceMock(Connection.class);
     PreparedStatement preparedStatement = createNiceMock(PreparedStatement.class);
     Capture<String> stmtCapture = new Capture<String>();
@@ -222,8 +224,8 @@ public class TestPhoenixTransactSQL {
   @Test
   public void testPrepareGetMetricsPrecisionHours() throws SQLException {
     Condition condition = new DefaultCondition(
-        Arrays.asList("cpu_user", "mem_free"), "h1", "a1", "i1",
-        1407959718L, 1407959918L, Precision.HOURS, null, false);
+      Arrays.asList("cpu_user", "mem_free"), Collections.singletonList("h1"),
+      "a1", "i1", 1407959718L, 1407959918L, Precision.HOURS, null, false);
     Connection connection = createNiceMock(Connection.class);
     PreparedStatement preparedStatement = createNiceMock(PreparedStatement.class);
     Capture<String> stmtCapture = new Capture<String>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestTimelineMetricStore.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestTimelineMetricStore.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestTimelineMetricStore.java
index a2d55af..b0aad57 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestTimelineMetricStore.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestTimelineMetricStore.java
@@ -29,7 +29,7 @@ import java.util.List;
 public class TestTimelineMetricStore implements TimelineMetricStore {
   @Override
   public TimelineMetrics getTimelineMetrics(List<String> metricNames,
-      String hostname, String applicationId, String instanceId, Long startTime,
+      List<String> hostnames, String applicationId, String instanceId, Long startTime,
       Long endTime, Precision precision, Integer limit, boolean groupedByHost) throws SQLException,
     IOException {
     TimelineMetrics timelineMetrics = new TimelineMetrics();
@@ -65,7 +65,7 @@ public class TestTimelineMetricStore implements TimelineMetricStore {
   }
 
   @Override
-  public TimelineMetric getTimelineMetric(String metricName, String hostname,
+  public TimelineMetric getTimelineMetric(String metricName, List<String> hostname,
       String applicationId, String instanceId, Long startTime, Long endTime,
       Precision precision, Integer limit) throws SQLException, IOException {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
index 43cf858..b87118b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
@@ -63,17 +63,12 @@ import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider
 import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
 
 public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
-  static final Map<String, String> TIMELINE_APPID_MAP = new HashMap<String, String>();
   private static ObjectMapper mapper;
   private final static ObjectReader timelineObjectReader;
   private static final String METRIC_REGEXP_PATTERN = "\\([^)]*\\)";
   private static final int COLLECTOR_DEFAULT_PORT = 6188;
 
   static {
-    TIMELINE_APPID_MAP.put(HBASE_MASTER.name(), "HBASE");
-    TIMELINE_APPID_MAP.put(HBASE_REGIONSERVER.name(), "HBASE");
-    TIMELINE_APPID_MAP.put(METRICS_COLLECTOR.name(), "AMS-HBASE");
-
     mapper = new ObjectMapper();
     AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
     mapper.setAnnotationIntrospector(introspector);
@@ -128,24 +123,27 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
     private final Map<String, Set<Resource>> resources = new HashMap<String, Set<Resource>>();
     private final Map<String, Set<String>> metrics = new HashMap<String, Set<String>>();
     private final URIBuilder uriBuilder;
-    private final String dummyHostName = "__SummaryInfo__";
     // Metrics with amsHostMetric = true
     // Basically a host metric to be returned for a hostcomponent
     private final Set<String> hostComponentHostMetrics = new HashSet<String>();
+    private String clusterName;
 
-    private MetricsRequest(TemporalInfo temporalInfo, URIBuilder uriBuilder) {
+    private MetricsRequest(TemporalInfo temporalInfo, URIBuilder uriBuilder,
+                           String clusterName) {
       this.temporalInfo = temporalInfo;
       this.uriBuilder = uriBuilder;
+      this.clusterName = clusterName;
     }
 
-    public void putResource(String hostname, Resource resource) {
-      if (hostname == null) {
-        hostname = dummyHostName;
-      }
-      Set<Resource> resourceSet = resources.get(hostname);
+    public String getClusterName() {
+      return clusterName;
+    }
+
+    public void putResource(String componentName, Resource resource) {
+      Set<Resource> resourceSet = resources.get(componentName);
       if (resourceSet == null) {
         resourceSet = new HashSet<Resource>();
-        resources.put(hostname, resourceSet);
+        resources.put(componentName, resourceSet);
       }
       resourceSet.add(resource);
     }
@@ -220,34 +218,17 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
       }
 
       for (Map.Entry<String, Set<Resource>> resourceEntry : resources.entrySet()) {
-        String hostname = resourceEntry.getKey();
+        String componentName = resourceEntry.getKey();
         Set<Resource> resourceSet = resourceEntry.getValue();
 
-        for (Resource resource : resourceSet) {
-          String clusterName = (String) resource.getPropertyValue(clusterNamePropertyId);
-
-          // Check liveliness of host
-          if (!hostProvider.isCollectorHostLive(clusterName, TIMELINE_METRICS)) {
-            LOG.info("METRICS_COLLECTOR host is not live. Skip populating " +
-              "resources with metrics.");
-            return Collections.emptySet();
-          }
-
-          // Check liveliness of Collector
-          if (!hostProvider.isCollectorComponentLive(clusterName, TIMELINE_METRICS)) {
-            LOG.info("METRICS_COLLECTOR is not live. Skip populating resources" +
-              " with metrics.");
-            return Collections.emptySet();
-          }
-
           TimelineMetrics timelineMetrics;
           // Allow for multiple requests since host metrics for a
           // hostcomponent need the HOST appId
-          if (hostComponentHostMetrics.isEmpty()) {
-            String spec = getSpec(hostname, resource);
+          if (hostComponentHostMetrics.isEmpty()) { //HOST
+            String spec = getSpec(componentName);
             timelineMetrics = getTimelineMetricsForSpec(spec);
           } else {
-            Set<String> specs = getSpecsForHostComponentMetrics(hostname, resource);
+            Set<String> specs = getSpecsForHostComponentMetrics(componentName);
             timelineMetrics = new TimelineMetrics();
             for (String spec : specs) {
               if (!StringUtils.isEmpty(spec)) {
@@ -258,14 +239,24 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
               }
             }
           }
-
-          Set<String> patterns = createPatterns(metrics.keySet());
-
-          if (timelineMetrics != null) {
-            for (TimelineMetric metric : timelineMetrics.getMetrics()) {
-              if (metric.getMetricName() != null
-                  && metric.getMetricValues() != null
-                  && checkMetricName(patterns, metric.getMetricName())) {
+        Map<String, Set<TimelineMetric>> metricsMap = new HashMap<String, Set<TimelineMetric>>();
+        Set<String> patterns = createPatterns(metrics.keySet());
+        if (timelineMetrics != null) {
+          for (TimelineMetric metric : timelineMetrics.getMetrics()) {
+            if (metric.getMetricName() != null
+                && metric.getMetricValues() != null
+                && checkMetricName(patterns, metric.getMetricName())) {
+              String hostname = metric.getHostName();
+              if (!metricsMap.containsKey(hostname)) {
+                metricsMap.put(hostname, new HashSet<TimelineMetric>());
+              }
+              metricsMap.get(hostname).add(metric);
+            }
+          }
+          for (Resource resource : resourceSet) {
+            String hostname = getHostName(resource);
+            if (metricsMap.containsKey(hostname)) {
+              for (TimelineMetric metric : metricsMap.get(hostname)) {
                 // Pad zeros or nulls if needed
                 metricsPaddingMethod.applyPaddingStrategy(metric, temporalInfo);
                 populateResource(resource, metric);
@@ -283,28 +274,28 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
      * host metrics.
      * @return @Set Urls
      */
-    private Set<String> getSpecsForHostComponentMetrics(String hostname, Resource resource) {
+    private Set<String> getSpecsForHostComponentMetrics(String componentName) {
       Set<String> nonHostComponentMetrics = new HashSet<String>(metrics.keySet());
       nonHostComponentMetrics.removeAll(hostComponentHostMetrics);
 
       Set<String> specs = new HashSet<String>();
+      String hostnames = getHostnames(resources.get(componentName));
       if (!hostComponentHostMetrics.isEmpty()) {
         String hostComponentHostMetricParams = getSetString(processRegexps(hostComponentHostMetrics), -1);
-        setQueryParams(resource, hostComponentHostMetricParams, hostname, "HOST");
+        setQueryParams(hostComponentHostMetricParams, hostnames, true, componentName);
         specs.add(uriBuilder.toString());
       }
 
       if (!nonHostComponentMetrics.isEmpty()) {
         String nonHostComponentHostMetricParams = getSetString(processRegexps(nonHostComponentMetrics), -1);
-        setQueryParams(resource, nonHostComponentHostMetricParams, hostname, null);
+        setQueryParams(nonHostComponentHostMetricParams, hostnames, false, componentName);
         specs.add(uriBuilder.toString());
       }
-
       return specs;
     }
 
-    private void setQueryParams(Resource resource, String metricsParam,
-                                String hostname, String appId) {
+    private void setQueryParams(String metricsParam,
+                                String hostname, boolean isHostMetric, String componentName) {
       // Reuse uriBuilder
       uriBuilder.removeQuery();
 
@@ -312,16 +303,15 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
         uriBuilder.setParameter("metricNames", metricsParam);
       }
 
-      if (hostname != null && !hostname.isEmpty() && !hostname.equals(dummyHostName)) {
+      if (hostname != null && !hostname.isEmpty()) {
         uriBuilder.setParameter("hostname", hostname);
       }
 
-      if (appId != null) {
-        uriBuilder.setParameter("appId", appId);
+      if (isHostMetric) {
+        uriBuilder.setParameter("appId", "HOST");
       } else {
-        String componentName = getComponentName(resource);
-        if (componentName != null && !componentName.isEmpty()) {
-          String clusterName = (String) resource.getPropertyValue(clusterNamePropertyId);
+        if (componentName != null && !componentName.isEmpty()
+          && !componentName.equalsIgnoreCase("HOST")) {
           StackId stackId;
           try {
             AmbariManagementController managementController = AmbariServer.getController();
@@ -339,8 +329,8 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
           } catch (Exception e) {
             e.printStackTrace();
           }
-          uriBuilder.setParameter("appId", componentName);
         }
+        uriBuilder.setParameter("appId", componentName);
       }
 
       if (temporalInfo != null) {
@@ -356,10 +346,10 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
       }
     }
 
-    private String getSpec(String hostname, Resource resource) {
+    private String getSpec(String componentName) {
       String metricsParam = getSetString(processRegexps(metrics.keySet()), -1);
-
-      setQueryParams(resource, metricsParam, hostname, null);
+      String hostnames = getHostnames(resources.get(componentName));
+      setQueryParams(metricsParam, hostnames, false, componentName);
 
       return uriBuilder.toString();
     }
@@ -445,6 +435,21 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
     }
   }
 
+  private String getHostnames(Set<Resource> resources) {
+    StringBuilder hostnames = new StringBuilder();
+    for (Resource resource: resources) {
+      String hostname = getHostName(resource);
+      if (hostname == null) {
+        break;
+      }
+      if (hostnames.length() > 0) {
+        hostnames.append(',');
+      }
+      hostnames.append(hostname);
+    }
+    return hostnames.toString();
+  }
+
   @Override
   public Set<Resource> populateResourcesWithProperties(Set<Resource> resources,
                Request request, Set<String> propertyIds) throws SystemException {
@@ -509,6 +514,20 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
         continue;
       }
 
+      // Check liveliness of host
+      if (!hostProvider.isCollectorHostLive(clusterName, TIMELINE_METRICS)) {
+        LOG.info("METRICS_COLLECTOR host is not live. Skip populating " +
+            "resources with metrics.");
+        continue;
+      }
+
+      // Check liveliness of Collector
+      if (!hostProvider.isCollectorComponentLive(clusterName, TIMELINE_METRICS)) {
+        LOG.info("METRICS_COLLECTOR is not live. Skip populating resources" +
+            " with metrics.");
+        continue;
+      }
+
       Map<TemporalInfo, MetricsRequest> requests = requestMap.get(clusterName);
       if (requests == null) {
         requests = new HashMap<TemporalInfo, MetricsRequest>();
@@ -549,10 +568,11 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
             if (metricsRequest == null) {
               metricsRequest = new MetricsRequest(temporalInfo,
                 getAMSUriBuilder(collectorHostName,
-                  collectorPort != null ? Integer.parseInt(collectorPort) : COLLECTOR_DEFAULT_PORT));
+                  collectorPort != null ? Integer.parseInt(collectorPort) : COLLECTOR_DEFAULT_PORT),
+                 (String) resource.getPropertyValue(clusterNamePropertyId));
               requests.put(temporalInfo, metricsRequest);
             }
-            metricsRequest.putResource(getHostName(resource), resource);
+            metricsRequest.putResource(getComponentName(resource), resource);
             metricsRequest.putPropertyId(propertyInfo.getPropertyId(), propertyId);
             // If request is for a host metric we need to create multiple requests
             if (propertyInfo.isAmsHostMetric()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProviderTest.java
index e7146d1..859fda4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProviderTest.java
@@ -116,6 +116,7 @@ public class AMSPropertyProviderTest {
     uriBuilder.addParameter("endTime", "1416445244901");
     Assert.assertEquals(uriBuilder.toString(), streamProvider.getLastSpec());
     Number[][] val = (Number[][]) res.getPropertyValue(PROPERTY_ID1);
+    Assert.assertNotNull("No value for property " + PROPERTY_ID1, val);
     Assert.assertEquals(111, val.length);
   }
 
@@ -204,8 +205,10 @@ public class AMSPropertyProviderTest {
     Assert.assertTrue(uriBuilder.toString().equals(streamProvider.getLastSpec())
         || uriBuilder2.toString().equals(streamProvider.getLastSpec()));
     Double val1 = (Double) res.getPropertyValue(PROPERTY_ID1);
+    Assert.assertNotNull("No value for property " + PROPERTY_ID1, val1);
     Assert.assertEquals(41.088, val1, 0.001);
     Double val2 = (Double)res.getPropertyValue(PROPERTY_ID2);
+    Assert.assertNotNull("No value for property " + PROPERTY_ID2, val2);
     Assert.assertEquals(2.47025664E8, val2, 0.1);
   }
 
@@ -289,7 +292,7 @@ public class AMSPropertyProviderTest {
     String propertyId1 = "metrics/yarn/Queue/root/AvailableMB";
     Resource resource = new ResourceImpl(Resource.Type.Component);
     resource.setProperty(CLUSTER_NAME_PROPERTY_ID, "c1");
-    resource.setProperty(HOST_NAME_PROPERTY_ID, "h1");
+    resource.setProperty(HOST_NAME_PROPERTY_ID, "h1");// should be set?
     resource.setProperty(COMPONENT_NAME_PROPERTY_ID, "RESOURCEMANAGER");
     Map<String, TemporalInfo> temporalInfoMap = new HashMap<String, TemporalInfo>();
     temporalInfoMap.put(propertyId1, new TemporalInfoImpl(1416528819369L, 1416528819569L, 1L));
@@ -308,6 +311,7 @@ public class AMSPropertyProviderTest {
     uriBuilder.addParameter("endTime", "1416528819569");
     Assert.assertEquals(uriBuilder.toString(), streamProvider.getLastSpec());
     Number[][] val = (Number[][]) res.getPropertyValue("metrics/yarn/Queue/root/AvailableMB");
+    Assert.assertNotNull("No value for property metrics/yarn/Queue/root/AvailableMB", val);
     Assert.assertEquals(238, val.length);
   }
 
@@ -352,6 +356,7 @@ public class AMSPropertyProviderTest {
     uriBuilder.addParameter("endTime", "1416528819569");
     Assert.assertEquals(uriBuilder.toString(), streamProvider.getLastSpec());
     Number[][] val = (Number[][]) res.getPropertyValue(propertyId);
+    Assert.assertNotNull("No value for property " + propertyId, val);
     Assert.assertEquals(238, val.length);
   }
 
@@ -583,6 +588,7 @@ public class AMSPropertyProviderTest {
     Number[][] val = (Number[][]) res.getPropertyValue(PROPERTY_ID1);
     Assert.assertEquals(111, val.length);
     val = (Number[][]) res.getPropertyValue(PROPERTY_ID3);
+    Assert.assertNotNull("No value for property " + PROPERTY_ID3, val);
     Assert.assertEquals(8, val.length);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-server/src/test/resources/ams/multiple_component_regexp_metrics.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/ams/multiple_component_regexp_metrics.json b/ambari-server/src/test/resources/ams/multiple_component_regexp_metrics.json
index 393cc27..d0d30e6 100644
--- a/ambari-server/src/test/resources/ams/multiple_component_regexp_metrics.json
+++ b/ambari-server/src/test/resources/ams/multiple_component_regexp_metrics.json
@@ -4,7 +4,6 @@
         "type": "Double",
         "metricname": "yarn.QueueMetrics.Queue=root.PendingMB",
         "appid": "resourcemanager",
-        "hostname": "h1",
         "starttime": 1416528759233,
         "metrics": {
             "1416528759233": 10.333333333333332,
@@ -252,7 +251,6 @@
         "type": "Double",
         "metricname": "yarn.QueueMetrics.Queue=root.AvailableMB",
         "appid": "resourcemanager",
-        "hostname": "h1",
         "starttime": 1416528759233,
         "metrics": {
             "1416528759233": 10.333333333333332,

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-server/src/test/resources/ams/multiple_host_metrics.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/ams/multiple_host_metrics.json b/ambari-server/src/test/resources/ams/multiple_host_metrics.json
index 2868573..031e777 100644
--- a/ambari-server/src/test/resources/ams/multiple_host_metrics.json
+++ b/ambari-server/src/test/resources/ams/multiple_host_metrics.json
@@ -3,6 +3,7 @@
         "timestamp": 1416445244801,
         "metricname": "cpu_user",
         "appid": "HOST",
+        "hostname":"h1",
         "starttime": 1416445244801,
         "metrics": {
           "1416445244801": 4006.085,
@@ -123,6 +124,7 @@
         "timestamp": 1416445244801,
         "metricname": "mem_free",
         "appid": "HOST",
+        "hostname":"h1",
         "starttime": 1416445244801,
         "metrics": {
           "1416445244801": "2.46272E8",
@@ -213,4 +215,4 @@
           "1416447344801": "2.47025664E8"
         }
     }
-]}
\ No newline at end of file
+]}

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-server/src/test/resources/ams/single_component_metrics.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/ams/single_component_metrics.json b/ambari-server/src/test/resources/ams/single_component_metrics.json
index 1cbbb3c..d44d812 100644
--- a/ambari-server/src/test/resources/ams/single_component_metrics.json
+++ b/ambari-server/src/test/resources/ams/single_component_metrics.json
@@ -4,7 +4,6 @@
         "type": "Double",
         "metricname": "rpc.rpc.RpcQueueTimeAvgTime",
         "appid": "namenode",
-        "hostname": "h1",
         "starttime": 1416528759233,
         "metrics": {
             "1416528759233": 10.333333333333332,
@@ -247,4 +246,4 @@
             "1416531129231": 0.0
         }
     }
-]}
\ No newline at end of file
+]}

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-server/src/test/resources/ams/single_host_component_metrics.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/ams/single_host_component_metrics.json b/ambari-server/src/test/resources/ams/single_host_component_metrics.json
index f3e6554..b8c4e24 100644
--- a/ambari-server/src/test/resources/ams/single_host_component_metrics.json
+++ b/ambari-server/src/test/resources/ams/single_host_component_metrics.json
@@ -5,7 +5,7 @@
     "type": "Long",
     "metricname": "dfs.datanode.BlocksReplicated",
     "appid": "datanode",
-    "hostname": "c6402.ambari.apache.org",
+    "hostname": "h1",
     "starttime": 1416445244801,
     "metrics": {
       "1416445244801": 0.0,
@@ -18,4 +18,4 @@
       "1416445251801": 0.0
     }
   }
-]}
\ No newline at end of file
+]}

http://git-wip-us.apache.org/repos/asf/ambari/blob/3131ad82/ambari-server/src/test/resources/ams/single_host_metric.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/ams/single_host_metric.json b/ambari-server/src/test/resources/ams/single_host_metric.json
index 83f2cdf..59ec685 100644
--- a/ambari-server/src/test/resources/ams/single_host_metric.json
+++ b/ambari-server/src/test/resources/ams/single_host_metric.json
@@ -4,7 +4,7 @@
     "timestamp": 1416445244801,
     "metricname": "cpu_user",
     "appid": "HOST",
-    "hostname": "c6402.ambari.apache.org",
+    "hostname": "h1",
     "starttime": 1416445244801,
     "metrics": {
       "1416445244801": 4006.085,
@@ -121,4 +121,4 @@
       "1416448936464": 4108.2
     }
   }
-]}
\ No newline at end of file
+]}