You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by av...@apache.org on 2017/05/02 22:13:51 UTC

ambari git commit: AMBARI-20913 : Grafana LLAP overview dashboard showing incorrect metrics. (avijayan)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 e3674352f -> 731b1a06b


AMBARI-20913 : Grafana LLAP overview dashboard showing incorrect metrics. (avijayan)


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

Branch: refs/heads/branch-2.5
Commit: 731b1a06b91ec42b32e0cca3224bf83245b10ddb
Parents: e367435
Author: Aravindan Vijayan <av...@hortonworks.com>
Authored: Tue May 2 15:13:30 2017 -0700
Committer: Aravindan Vijayan <av...@hortonworks.com>
Committed: Tue May 2 15:13:30 2017 -0700

----------------------------------------------------------------------
 .../aggregators/TimelineMetricClusterAggregator.java     | 11 +++++++++--
 .../timeline/aggregators/ITClusterAggregator.java        |  8 ++++----
 2 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/731b1a06/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregator.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregator.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregator.java
index 02677b9..0934356 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregator.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregator.java
@@ -91,6 +91,7 @@ public class TimelineMetricClusterAggregator extends AbstractTimelineAggregator
     MetricHostAggregate hostAggregate = null;
     Map<TimelineClusterMetric, MetricHostAggregate> hostAggregateMap =
       new HashMap<TimelineClusterMetric, MetricHostAggregate>();
+    int perMetricCount = 0;
 
     while (rs.next()) {
       TimelineClusterMetric currentMetric = readHelper.fromResultSet(rs);
@@ -106,14 +107,20 @@ public class TimelineMetricClusterAggregator extends AbstractTimelineAggregator
         currentMetric.setTimestamp(endTime);
         hostAggregate = new MetricHostAggregate();
         hostAggregateMap.put(currentMetric, hostAggregate);
+        perMetricCount++;
       }
 
       if (existingMetric.equalsExceptTime(currentMetric)) {
         // Recalculate totals with current metric
         updateAggregatesFromHost(hostAggregate, currentHostAggregate);
-
+        perMetricCount++;
       } else {
-        // Switched over to a new metric - save existing
+        // Switched over to a new metric - save new metric
+
+        hostAggregate.setSum(hostAggregate.getSum() / perMetricCount);
+        hostAggregate.setNumberOfSamples(Math.round((float)hostAggregate.getNumberOfSamples() / (float)perMetricCount));
+        perMetricCount = 1;
+
         hostAggregate = new MetricHostAggregate();
         currentMetric.setTimestamp(endTime);
         updateAggregatesFromHost(hostAggregate, currentHostAggregate);

http://git-wip-us.apache.org/repos/asf/ambari/blob/731b1a06/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/ITClusterAggregator.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/ITClusterAggregator.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/ITClusterAggregator.java
index 590f82a..f083731 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/ITClusterAggregator.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/ITClusterAggregator.java
@@ -659,14 +659,14 @@ public class ITClusterAggregator extends AbstractMiniHBaseClusterTest {
     while (rs.next()) {
       if ("disk_used".equals(rs.getString("METRIC_NAME"))) {
         assertEquals("APP_ID", "test_app", rs.getString("APP_ID"));
-        assertEquals("METRIC_SUM", 16.0, rs.getDouble("METRIC_SUM"));
-        assertEquals("METRIC_COUNT", 8, rs.getLong("METRIC_COUNT"));
+        assertEquals("METRIC_SUM", 4.0, rs.getDouble("METRIC_SUM"));
+        assertEquals("METRIC_COUNT", 2, rs.getLong("METRIC_COUNT"));
         assertEquals("METRIC_MAX", 4.0, rs.getDouble("METRIC_MAX"));
         assertEquals("METRIC_MIN", 0.0, rs.getDouble("METRIC_MIN"));
       } else if ("disk_free".equals(rs.getString("METRIC_NAME"))) {
         assertEquals("APP_ID", "test_app", rs.getString("APP_ID"));
-        assertEquals("METRIC_SUM", 4.0, rs.getDouble("METRIC_SUM"));
-        assertEquals("METRIC_COUNT", 8, rs.getLong("METRIC_COUNT"));
+        assertEquals("METRIC_SUM", 1.0, rs.getDouble("METRIC_SUM"));
+        assertEquals("METRIC_COUNT", 2, rs.getLong("METRIC_COUNT"));
         assertEquals("METRIC_MAX", 1.0, rs.getDouble("METRIC_MAX"));
         assertEquals("METRIC_MIN", 1.0, rs.getDouble("METRIC_MIN"));
       }