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 2016/04/06 02:21:36 UTC
ambari git commit: Revert "AMBARI-15638 : [AMS] Sum Calculation
Incorrect - Patch 2 (avijayan)"
Repository: ambari
Updated Branches:
refs/heads/branch-2.2 599a64ae8 -> 81aa8548b
Revert "AMBARI-15638 : [AMS] Sum Calculation Incorrect - Patch 2 (avijayan)"
This reverts commit 599a64ae8fb7dc653e870814c23cd6cd301d51d1.
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/81aa8548
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/81aa8548
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/81aa8548
Branch: refs/heads/branch-2.2
Commit: 81aa8548b119a6950a7fef637cbd47086226c379
Parents: 599a64a
Author: Aravindan Vijayan <av...@hortonworks.com>
Authored: Tue Apr 5 17:21:20 2016 -0700
Committer: Aravindan Vijayan <av...@hortonworks.com>
Committed: Tue Apr 5 17:21:20 2016 -0700
----------------------------------------------------------------------
.../timeline/aggregators/AggregatorUtils.java | 4 ++-
.../TimelineMetricClusterAggregatorSecond.java | 34 +++++++-------------
.../timeline/query/PhoenixTransactSQL.java | 2 +-
3 files changed, 15 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/81aa8548/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/81aa8548/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 dacb32f..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
@@ -209,11 +209,6 @@ public class TimelineMetricClusterAggregatorSecond extends AbstractTimelineAggre
timeShift = 0l;
}
- Long prevTimestamp = -1l;
- TimelineClusterMetric prevMetric = null;
- int count = 0;
- double sum = 0.0;
-
Map<Long,Double> timeSliceValueMap = new HashMap<>();
for (Map.Entry<Long, Double> metric : timelineMetric.getMetricValues().entrySet()) {
// TODO: investigate null values - pre filter
@@ -231,31 +226,24 @@ public class TimelineMetricClusterAggregatorSecond extends AbstractTimelineAggre
timestamp,
timelineMetric.getType());
- if (prevTimestamp < 0 || timestamp.equals(prevTimestamp)) {
+ // do a sum / count here to get average for all points in a slice
+ int count = 1;
+ Double sum = 0.0;
+ if (!timelineClusterMetricMap.containsKey(clusterMetric)) {
+ sum = metric.getValue();
+ } else {
Double newValue = metric.getValue();
if (newValue > 0.0) {
- sum += newValue;
count++;
+ Double oldValue = timelineClusterMetricMap.get(clusterMetric);
+ sum = oldValue + newValue;
}
- } else {
- double metricValue = (count > 0) ? (sum / count) : 0.0;
- timelineClusterMetricMap.put(prevMetric, metricValue);
- timeSliceValueMap.put(timestamp, metricValue);
- sum = metric.getValue();
- count = sum > 0.0 ? 1 : 0;
}
-
- prevTimestamp = timestamp;
- prevMetric = clusterMetric;
+ double metricValue = sum / count;
+ timelineClusterMetricMap.put(clusterMetric, metricValue);
+ timeSliceValueMap.put(timestamp, metricValue);
}
}
-
- if (prevTimestamp > 0) {
- double metricValue = (count > 0) ? (sum / count) : 0.0;
- timelineClusterMetricMap.put(prevMetric, metricValue);
- timeSliceValueMap.put(prevTimestamp, metricValue);
- }
-
if (interpolationEnabled) {
interpolateMissingPeriods(timelineClusterMetricMap, timelineMetric, timeSlices, timeSliceValueMap);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/81aa8548/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 6a231c2..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
@@ -271,7 +271,7 @@ 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, ROUND(AVG(METRIC_SUM),2), ROUND(AVG(%s)), " +
+ "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";