ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-11030 Queue-specific metrics cannot be queried as time series data via Ambari API (dsen)
Date Tue, 12 May 2015 20:46:20 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 891f668cc -> c94780aa3


AMBARI-11030 Queue-specific metrics cannot be queried as time series data via Ambari API (dsen)


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

Branch: refs/heads/trunk
Commit: c94780aa3e3636818e3011bede6acdf2066e3fe4
Parents: 891f668
Author: Dmytro Sen <dsen@apache.org>
Authored: Tue May 12 23:44:51 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Tue May 12 23:45:53 2015 +0300

----------------------------------------------------------------------
 .../controller/internal/BaseProvider.java       |  3 ++-
 .../controller/internal/BaseProviderTest.java   | 22 ++++++++++++++++++++
 .../timeline/AMSPropertyProviderTest.java       |  6 +++---
 3 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c94780aa/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
index a95342a..ca5e70e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
@@ -79,7 +79,8 @@ public abstract class BaseProvider {
    * <p/>
    * {@code metrics/yarn/Queue/-/AppsCompleted/-/foo/-/bar/-}
    */
-  private static final Pattern METRIC_ARGUMENT_METHOD_REPLACEMENT = Pattern.compile("\\$\\d+(\\.\\w+(\\(\\\\\"\\S+\\\\\"\\)|\\(\\d+\\)))*");
+  private static final Pattern METRIC_ARGUMENT_METHOD_REPLACEMENT =
+      Pattern.compile("\\$\\d+(\\.\\S+\\(\\S+\\))*");
 
   // ----- Constructors ------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c94780aa/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BaseProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BaseProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BaseProviderTest.java
index 380142e..4995fa6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BaseProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BaseProviderTest.java
@@ -326,6 +326,7 @@ public class BaseProviderTest {
     Set<String> propertyIds = new HashSet<String>();
     propertyIds.add("metrics/flume/$1.substring(0)/CHANNEL/$2.replaceAll(\"[^-]+\",\"\")EventPutSuccessCount/rate/sum");
     propertyIds.add("metrics/yarn/Queue/$1.replaceAll(\"([.])\",\"/\")/AppsCompleted");
+    propertyIds.add("metrics/yarn/Queue/$1.replaceAll(\",q(\\d+)=\",\"/\").substring(1)/AppsFailed");
 
     TestProvider provider = new TestProvider(propertyIds);
     Entry<String, Pattern> entry = provider.getRegexEntry("metrics/flume/flume");
@@ -347,6 +348,27 @@ public class BaseProviderTest {
     assertEquals(
         "metrics/flume/(\\S*)/CHANNEL/(\\S*)EventPutSuccessCount/rate",
         entry.getValue().pattern());
+
+    entry = provider.getRegexEntry("metrics/yarn/Queue/root/AppsCompleted");
+    assertEquals("metrics/yarn/Queue/$1.replaceAll(\"([.])\",\"/\")/AppsCompleted",
+        entry.getKey());
+    assertEquals(
+        "metrics/yarn/Queue/(\\S*)/AppsCompleted",
+        entry.getValue().pattern());
+
+    entry = provider.getRegexEntry("metrics/yarn/Queue/root/default/AppsCompleted");
+    assertEquals("metrics/yarn/Queue/$1.replaceAll(\"([.])\",\"/\")/AppsCompleted",
+        entry.getKey());
+    assertEquals(
+        "metrics/yarn/Queue/(\\S*)/AppsCompleted",
+        entry.getValue().pattern());
+
+    entry = provider.getRegexEntry("metrics/yarn/Queue/root/default/AppsFailed");
+    assertEquals("metrics/yarn/Queue/$1.replaceAll(\",q(\\d+)=\",\"/\").substring(1)/AppsFailed",
+        entry.getKey());
+    assertEquals(
+        "metrics/yarn/Queue/(\\S*)/AppsFailed",
+        entry.getValue().pattern());
   }
 
   static class TestProvider extends BaseProvider {

http://git-wip-us.apache.org/repos/asf/ambari/blob/c94780aa/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 1573708..6e389ed 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
@@ -245,7 +245,7 @@ public class AMSPropertyProviderTest {
         new HashMap<String, Map<String, PropertyInfo>>() {{
       put("RESOURCEMANAGER", new HashMap<String, PropertyInfo>() {{
         put("metrics/yarn/Queue/$1.replaceAll(\"([.])\",\"/\")/AvailableMB",
-            new PropertyInfo("yarn.QueueMetrics.(.+).AvailableMB", true, false));
+            new PropertyInfo("yarn.QueueMetrics.Queue=(.+).AvailableMB", true, false));
       }});
     }};
 
@@ -274,12 +274,12 @@ public class AMSPropertyProviderTest {
     Map<String, Object> properties = PropertyHelper.getProperties(resources.iterator().next());
     Assert.assertNotNull(properties);
     URIBuilder uriBuilder = AMSPropertyProvider.getAMSUriBuilder("localhost", 8188);
-    uriBuilder.addParameter("metricNames", "yarn.QueueMetrics.%.AvailableMB");
+    uriBuilder.addParameter("metricNames", "yarn.QueueMetrics.Queue=root.AvailableMB");
     uriBuilder.addParameter("appId", "RESOURCEMANAGER");
     uriBuilder.addParameter("startTime", "1416528819369");
     uriBuilder.addParameter("endTime", "1416528819569");
     Assert.assertEquals(uriBuilder.toString(), streamProvider.getLastSpec());
-    Number[][] val = (Number[][]) res.getPropertyValue("metrics/yarn/Queue/Queue=root/AvailableMB");
+    Number[][] val = (Number[][]) res.getPropertyValue("metrics/yarn/Queue/root/AvailableMB");
     Assert.assertEquals(238, val.length);
   }
 


Mime
View raw message