lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject [02/10] lucene-solr:jira/solr-10990: SOLR-11215: Support retrieval of any property of a regular metric when using 'key' parameter.
Date Fri, 08 Sep 2017 10:00:45 GMT
SOLR-11215: Support retrieval of any property of a regular metric when
using 'key' parameter.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/26ed40bc
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/26ed40bc
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/26ed40bc

Branch: refs/heads/jira/solr-10990
Commit: 26ed40bcdbd42fc94e18d9e491536da5515ac9fe
Parents: 5324c74
Author: Andrzej Bialecki <ab@apache.org>
Authored: Thu Sep 7 18:21:55 2017 +0200
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Thu Sep 7 18:21:55 2017 +0200

----------------------------------------------------------------------
 .../org/apache/solr/handler/admin/MetricsHandler.java    | 11 ++++++++---
 .../apache/solr/handler/admin/MetricsHandlerTest.java    |  9 +++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/26ed40bc/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
index a9a2d1f..ed1e474 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/MetricsHandler.java
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -139,14 +140,18 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
         continue;
       }
       MetricUtils.PropertyFilter propertyFilter = MetricUtils.PropertyFilter.ALL;
-      boolean simple = false;
       if (propertyName != null) {
         propertyFilter = (name) -> name.equals(propertyName);
-        simple = true;
         // use escaped versions
         key = parts[0] + ":" + parts[1];
       }
-      MetricUtils.convertMetric(key, m, propertyFilter, false, true, true, simple, ":", (k,
v) -> result.add(k, v));
+      MetricUtils.convertMetric(key, m, propertyFilter, false, true, true, false, ":", (k,
v) -> {
+        if ((v instanceof Map) && propertyName != null) {
+          ((Map)v).forEach((k1, v1) -> result.add(k + ":" + k1, v1));
+        } else {
+          result.add(k, v);
+        }
+      });
     }
     rsp.getValues().add("metrics", result);
     if (errors.size() > 0) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/26ed40bc/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
index 7eb8f12..0fe5ad7 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
@@ -277,6 +277,15 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     val = values.findRecursive("metrics", key3);
     assertNotNull(val);
 
+    String key4 = "solr.core.collection1:QUERY./select.requestTimes:1minRate";
+    resp = new SolrQueryResponse();
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
+        MetricsHandler.KEY_PARAM, key4), resp);
+    values = resp.getValues();
+    val = values.findRecursive("metrics", key4);
+    assertNotNull(val);
+    assertTrue(val instanceof Number);
+
     // test errors
 
     // invalid keys


Mime
View raw message