ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From avija...@apache.org
Subject ambari git commit: AMBARI-15638 : AMS Sum Calculation Incorrect (avijayan)
Date Fri, 01 Apr 2016 19:32:48 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 638b0a267 -> f575da8da


 AMBARI-15638 : AMS Sum Calculation Incorrect (avijayan)


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

Branch: refs/heads/branch-2.2
Commit: f575da8da688a9989410f94484947344704e4000
Parents: 638b0a2
Author: Aravindan Vijayan <avijayan@hortonworks.com>
Authored: Fri Apr 1 12:32:10 2016 -0700
Committer: Aravindan Vijayan <avijayan@hortonworks.com>
Committed: Fri Apr 1 12:32:10 2016 -0700

----------------------------------------------------------------------
 .../metrics/timeline/aggregators/AggregatorUtils.java    |  4 +++-
 .../TimelineMetricClusterAggregatorSecond.java           | 11 +++++++----
 .../timeline/aggregators/TimelineMetricReadHelper.java   |  2 +-
 .../metrics/timeline/query/PhoenixTransactSQL.java       |  8 ++++----
 4 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f575da8d/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AggregatorUtils.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AggregatorUtils.java
b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AggregatorUtils.java
index ce79b6f..126b3a3 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AggregatorUtils.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/AggregatorUtils.java
@@ -43,9 +43,11 @@ public class AggregatorUtils {
             min = value;
           }
           sum += value;
+          if (value > 0.0) {
+            metricCount++;
+          }
         }
       }
-      metricCount = metricValues.values().size();
     }
     // BR: WHY ZERO is a good idea?
     values[0] = sum;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f575da8d/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregatorSecond.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregatorSecond.java
b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregatorSecond.java
index 9354bc3..67c463f 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregatorSecond.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricClusterAggregatorSecond.java
@@ -228,13 +228,16 @@ public class TimelineMetricClusterAggregatorSecond extends AbstractTimelineAggre
 
         // do a sum / count here to get average for all points in a slice
         int count = 1;
-        Double sum;
+        Double sum = 0.0;
         if (!timelineClusterMetricMap.containsKey(clusterMetric)) {
           sum = metric.getValue();
         } else {
-          count++;
-          Double oldValue = timelineClusterMetricMap.get(clusterMetric);
-          sum = oldValue + metric.getValue();
+          Double newValue = metric.getValue();
+          if (newValue > 0.0) {
+            count++;
+            Double oldValue = timelineClusterMetricMap.get(clusterMetric);
+            sum = oldValue + newValue;
+          }
         }
         double metricValue = sum / count;
         timelineClusterMetricMap.put(clusterMetric, metricValue);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f575da8d/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricReadHelper.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricReadHelper.java
b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricReadHelper.java
index 846ae92..bec103a 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricReadHelper.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/aggregators/TimelineMetricReadHelper.java
@@ -72,7 +72,7 @@ public class TimelineMetricReadHelper {
         value = rs.getDouble("METRIC_MAX");
         break;
       case SUM:
-        value = rs.getDouble("METRIC_SUM");
+        value = rs.getDouble("METRIC_SUM") / rs.getInt("METRIC_COUNT");
         break;
       default:
         value = rs.getDouble("METRIC_SUM") / rs.getInt("METRIC_COUNT");

http://git-wip-us.apache.org/repos/asf/ambari/blob/f575da8d/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 e67a5b8..e3030f6 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
@@ -261,7 +261,7 @@ public class PhoenixTransactSQL {
     "METRIC_SUM, METRIC_COUNT, METRIC_MAX, METRIC_MIN) " +
     "SELECT METRIC_NAME, HOSTNAME, APP_ID, INSTANCE_ID, %s AS SERVER_TIME, UNITS, " +
     "SUM(METRIC_SUM), SUM(METRIC_COUNT), MAX(METRIC_MAX), MIN(METRIC_MIN) " +
-    "FROM %s WHERE SERVER_TIME >= %s AND SERVER_TIME < %s " +
+    "FROM %s WHERE SERVER_TIME > %s AND SERVER_TIME <= %s " +
     "GROUP BY METRIC_NAME, HOSTNAME, APP_ID, INSTANCE_ID, UNITS";
 
   /**
@@ -271,9 +271,9 @@ public class PhoenixTransactSQL {
   public static final String GET_AGGREGATED_APP_METRIC_GROUPBY_SQL = "UPSERT %s " +
     "INTO %s (METRIC_NAME, APP_ID, INSTANCE_ID, SERVER_TIME, UNITS, " +
     "METRIC_SUM, METRIC_COUNT, METRIC_MAX, METRIC_MIN) SELECT METRIC_NAME, APP_ID, " +
-    "INSTANCE_ID, %s AS SERVER_TIME, UNITS, SUM(METRIC_SUM), SUM(%s), " +
-    "MAX(METRIC_MAX), MIN(METRIC_MIN) FROM %s WHERE SERVER_TIME >= %s AND " +
-    "SERVER_TIME < %s GROUP BY METRIC_NAME, APP_ID, INSTANCE_ID, UNITS";
+    "INSTANCE_ID, %s AS SERVER_TIME, UNITS, AVG(METRIC_SUM), AVG(%s), " +
+    "MAX(METRIC_MAX), MIN(METRIC_MIN) FROM %s WHERE SERVER_TIME > %s AND " +
+    "SERVER_TIME <= %s GROUP BY METRIC_NAME, APP_ID, INSTANCE_ID, UNITS";
 
   public static final String METRICS_RECORD_TABLE_NAME = "METRIC_RECORD";
   public static final String METRICS_AGGREGATE_MINUTE_TABLE_NAME =


Mime
View raw message