ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject ambari git commit: AMBARI-11467. API to fetch CPU metrics with average aggregation across all hosts returns value higher than the valid max bound. (swagle)
Date Wed, 27 May 2015 23:25:04 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f00daf006 -> 39b56b482


AMBARI-11467. API to fetch CPU metrics with average aggregation across all hosts returns value
higher than the valid max bound. (swagle)


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

Branch: refs/heads/trunk
Commit: 39b56b4829b604b103240dfc3c7a3f788a0949db
Parents: f00daf0
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Wed May 27 16:17:32 2015 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Wed May 27 16:20:54 2015 -0700

----------------------------------------------------------------------
 .../internal/AbstractPropertyProvider.java      | 12 +++-----
 .../MetricsDataTransferMethodFactory.java       | 29 ++++++++++++++------
 2 files changed, 25 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/39b56b48/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
index 96fa24b..133c8b5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
@@ -18,11 +18,13 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import org.apache.ambari.server.controller.metrics.MetricReportingAdapter;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.text.DecimalFormat;
-import java.util.Date;
-import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -31,12 +33,6 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.ambari.server.controller.metrics.MetricReportingAdapter;
-import org.apache.ambari.server.controller.spi.PropertyProvider;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric;
-
 /**
  *  Abstract property provider implementation.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/39b56b48/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsDataTransferMethodFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsDataTransferMethodFactory.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsDataTransferMethodFactory.java
index 3c683c8..9d70158 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsDataTransferMethodFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsDataTransferMethodFactory.java
@@ -17,24 +17,37 @@
  */
 package org.apache.ambari.server.controller.metrics;
 
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric;
 
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
+import static org.apache.ambari.server.controller.utilities.PropertyHelper.AGGREGATE_FUNCTION_IDENTIFIERS;
+
 public class MetricsDataTransferMethodFactory {
   private static final Set<String> PERCENTAGE_METRIC;
 
   static {
-    Set<String> temp = new HashSet<String>();
-    temp.add("cpu_wio");
-    temp.add("cpu_idle");
-    temp.add("cpu_nice");
-    temp.add("cpu_aidle");
-    temp.add("cpu_system");
-    temp.add("cpu_user");
-    PERCENTAGE_METRIC = Collections.unmodifiableSet(temp);
+    Set<String> percentMetrics = new HashSet<String>();
+    percentMetrics.add("cpu_wio");
+    percentMetrics.add("cpu_idle");
+    percentMetrics.add("cpu_nice");
+    percentMetrics.add("cpu_aidle");
+    percentMetrics.add("cpu_system");
+    percentMetrics.add("cpu_user");
+
+    Set<String> metricsWithAggregateFunctionIds = new HashSet<String>();
+    for (String metric : percentMetrics) {
+      for (String aggregateFunctionId : AGGREGATE_FUNCTION_IDENTIFIERS) {
+        metricsWithAggregateFunctionIds.add(metric + aggregateFunctionId);
+      }
+    }
+
+    percentMetrics.addAll(metricsWithAggregateFunctionIds);
+
+    PERCENTAGE_METRIC = Collections.unmodifiableSet(percentMetrics);
   }
 
   private static final MetricsDataTransferMethod percentageAdjustment = new PercentageAdjustmentTransferMethod();


Mime
View raw message