lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject lucene-solr:master: SOLR-10557: Make "compact" format default for /admin/metrics.
Date Mon, 24 Apr 2017 20:35:24 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master e17b98773 -> 114a65b33


SOLR-10557: Make "compact" format default for /admin/metrics.


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

Branch: refs/heads/master
Commit: 114a65b3316654507a434bf90793b5159022d6c7
Parents: e17b987
Author: Andrzej Bialecki <ab@apache.org>
Authored: Mon Apr 24 22:34:46 2017 +0200
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Mon Apr 24 22:35:18 2017 +0200

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../handler/admin/MetricsCollectorHandler.java  | 13 ++++++++---
 .../solr/handler/admin/MetricsHandler.java      |  2 +-
 .../reporters/solr/SolrClusterReporter.java     |  1 +
 .../metrics/reporters/solr/SolrReporter.java    | 21 ++++++++++++++---
 .../reporters/solr/SolrShardReporter.java       |  1 +
 .../solr/handler/admin/MetricsHandlerTest.java  | 24 ++++++++++----------
 .../reporters/solr/SolrCloudReportersTest.java  |  8 +++----
 8 files changed, 49 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/114a65b3/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 35fd327..8fbebdb 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -117,6 +117,8 @@ Other Changes
   Add support for selecting specific properties from any compound metric using 'property'
parameter to
   /admin/metrics handler. (ab)
 
+* SOLR-10557: Make "compact" format default for /admin/metrics. (ab)
+
 ----------------------
 
 ==================  6.6.0 ==================

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/114a65b3/solr/core/src/java/org/apache/solr/handler/admin/MetricsCollectorHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/MetricsCollectorHandler.java
b/solr/core/src/java/org/apache/solr/handler/admin/MetricsCollectorHandler.java
index 8474f55..3d8b6e0 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/MetricsCollectorHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/MetricsCollectorHandler.java
@@ -174,9 +174,15 @@ public class MetricsCollectorHandler extends RequestHandlerBase {
       String labelId = (String)doc.getFieldValue(SolrReporter.LABEL_ID);
       doc.remove(SolrReporter.LABEL_ID);
       doc.forEach(f -> {
-        String key = MetricRegistry.name(labelId, metricName, f.getName());
+        String key;
+        if (doc.size() == 1 && f.getName().equals(MetricUtils.VALUE)) {
+          // only one "value" field - skip the unnecessary field name
+          key = MetricRegistry.name(labelId, metricName);
+        } else {
+          key = MetricRegistry.name(labelId, metricName, f.getName());
+        }
         MetricRegistry registry = metricManager.registry(groupId);
-        AggregateMetric metric = getOrRegister(registry, key, new AggregateMetric());
+        AggregateMetric metric = getOrCreate(registry, key);
         Object o = f.getFirstValue();
         if (o != null) {
           metric.set(reporterId, o);
@@ -187,11 +193,12 @@ public class MetricsCollectorHandler extends RequestHandlerBase {
       });
     }
 
-    private AggregateMetric getOrRegister(MetricRegistry registry, String name, AggregateMetric
add) {
+    private AggregateMetric getOrCreate(MetricRegistry registry, String name) {
       AggregateMetric existing = (AggregateMetric)registry.getMetrics().get(name);
       if (existing != null) {
         return existing;
       }
+      AggregateMetric add = new AggregateMetric();
       try {
         registry.register(name, add);
         return add;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/114a65b3/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 9dda6ae..11f6821 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
@@ -83,7 +83,7 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
       throw new SolrException(SolrException.ErrorCode.INVALID_STATE, "Core container instance
not initialized");
     }
 
-    boolean compact = req.getParams().getBool(COMPACT_PARAM, false);
+    boolean compact = req.getParams().getBool(COMPACT_PARAM, true);
     MetricFilter mustMatchFilter = parseMustMatchFilter(req);
     MetricUtils.PropertyFilter propertyFilter = parsePropertyFilter(req);
     List<MetricType> metricTypes = parseMetricTypes(req);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/114a65b3/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
index c437457..c677bea 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java
@@ -217,6 +217,7 @@ public class SolrClusterReporter extends SolrMetricReporter {
         .convertDurationsTo(TimeUnit.MILLISECONDS)
         .withHandler(handler)
         .withReporterId(reporterId)
+        .setCompact(true)
         .cloudClient(false) // we want to send reports specifically to a selected leader
instance
         .skipAggregateValues(true) // we don't want to transport details of aggregates
         .skipHistograms(true) // we don't want to transport histograms

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/114a65b3/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java
index 1923877..8d36cef 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrReporter.java
@@ -126,6 +126,7 @@ public class SolrReporter extends ScheduledReporter {
     private boolean skipHistograms;
     private boolean skipAggregateValues;
     private boolean cloudClient;
+    private boolean compact;
     private SolrParams params;
 
     /**
@@ -146,6 +147,7 @@ public class SolrReporter extends ScheduledReporter {
       this.skipHistograms = false;
       this.skipAggregateValues = false;
       this.cloudClient = false;
+      this.compact = true;
       this.params = null;
     }
 
@@ -170,6 +172,16 @@ public class SolrReporter extends ScheduledReporter {
     }
 
     /**
+     * If true then use "compact" data representation.
+     * @param compact compact representation.
+     * @return {@code this}
+     */
+    public Builder setCompact(boolean compact) {
+      this.compact = compact;
+      return this;
+    }
+
+    /**
      * Histograms are difficult / impossible to aggregate, so it may not be
      * worth to report them.
      * @param skipHistograms when true then skip histograms from reports
@@ -244,7 +256,7 @@ public class SolrReporter extends ScheduledReporter {
      */
     public SolrReporter build(HttpClient client, Supplier<String> urlProvider) {
       return new SolrReporter(client, urlProvider, metricManager, reports, handler, reporterId,
rateUnit, durationUnit,
-          params, skipHistograms, skipAggregateValues, cloudClient);
+          params, skipHistograms, skipAggregateValues, cloudClient, compact);
     }
 
   }
@@ -258,6 +270,7 @@ public class SolrReporter extends ScheduledReporter {
   private boolean skipHistograms;
   private boolean skipAggregateValues;
   private boolean cloudClient;
+  private boolean compact;
   private ModifiableSolrParams params;
   private Map<String, Object> metadata;
 
@@ -288,7 +301,8 @@ public class SolrReporter extends ScheduledReporter {
   public SolrReporter(HttpClient httpClient, Supplier<String> urlProvider, SolrMetricManager
metricManager,
                       List<Report> metrics, String handler,
                       String reporterId, TimeUnit rateUnit, TimeUnit durationUnit,
-                      SolrParams params, boolean skipHistograms, boolean skipAggregateValues,
boolean cloudClient) {
+                      SolrParams params, boolean skipHistograms, boolean skipAggregateValues,
+                      boolean cloudClient, boolean compact) {
     super(null, "solr-reporter", MetricFilter.ALL, rateUnit, durationUnit);
     this.metricManager = metricManager;
     this.urlProvider = urlProvider;
@@ -311,6 +325,7 @@ public class SolrReporter extends ScheduledReporter {
     this.skipHistograms = skipHistograms;
     this.skipAggregateValues = skipAggregateValues;
     this.cloudClient = cloudClient;
+    this.compact = compact;
     this.params = new ModifiableSolrParams();
     this.params.set(REPORTER_ID, reporterId);
     // allow overrides to take precedence
@@ -361,7 +376,7 @@ public class SolrReporter extends ScheduledReporter {
         }
         final String effectiveGroup = group;
         MetricUtils.toSolrInputDocuments(metricManager.registry(registryName), Collections.singletonList(report.filter),
MetricFilter.ALL,
-            MetricUtils.PropertyFilter.ALL, skipHistograms, skipAggregateValues, false, metadata,
doc -> {
+            MetricUtils.PropertyFilter.ALL, skipHistograms, skipAggregateValues, compact,
metadata, doc -> {
               doc.setField(REGISTRY_ID, registryName);
               doc.setField(GROUP_ID, effectiveGroup);
               if (effectiveLabel != null) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/114a65b3/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
index 0cf14db..6ae84ac 100644
--- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
+++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java
@@ -158,6 +158,7 @@ public class SolrShardReporter extends SolrMetricReporter {
         .convertDurationsTo(TimeUnit.MILLISECONDS)
         .withHandler(handler)
         .withReporterId(id)
+        .setCompact(true)
         .cloudClient(false) // we want to send reports specifically to a selected leader
instance
         .skipAggregateValues(true) // we don't want to transport details of aggregates
         .skipHistograms(true) // we don't want to transport histograms

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/114a65b3/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 eb86b1b..402cc25 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
@@ -45,7 +45,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     MetricsHandler handler = new MetricsHandler(h.getCoreContainer());
 
     SolrQueryResponse resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json"),
resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json"), resp);
     NamedList values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -64,7 +64,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     assertEquals(5, ((Map) nl.get("ADMIN./admin/authorization.clientErrors")).size());
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"group", "jvm,jetty"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "group", "jvm,jetty"), resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -74,7 +74,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
 
     resp = new SolrQueryResponse();
     // "collection" works too, because it's a prefix for "collection1"
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"registry", "solr.core.collection,solr.jvm"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "registry", "solr.core.collection,solr.jvm"), resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -84,7 +84,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
 
     resp = new SolrQueryResponse();
     // "collection" works too, because it's a prefix for "collection1"
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"registry", "solr.core.collection", "registry", "solr.jvm"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "registry", "solr.core.collection", "registry", "solr.jvm"),
resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -93,7 +93,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     assertNotNull(values.get("solr.jvm"));
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"group", "jvm,jetty"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "group", "jvm,jetty"), resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -102,7 +102,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     assertNotNull(values.get("solr.jvm"));
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"group", "jvm", "group", "jetty"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "group", "jvm", "group", "jetty"), resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -111,7 +111,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     assertNotNull(values.get("solr.jvm"));
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"group", "node", "type", "counter"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "group", "node", "type", "counter"), resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -121,7 +121,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     assertNull(values.get("ADMIN./admin/authorization.errors")); // this is a timer node
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"prefix", "CONTAINER.cores,CONTAINER.threadPool"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "prefix", "CONTAINER.cores,CONTAINER.threadPool"), resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -134,7 +134,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     assertNotNull(values.get("CONTAINER.threadPool.coreLoadExecutor.completed"));
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"prefix", "CONTAINER.cores", "regex", "C.*thread.*completed"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "prefix", "CONTAINER.cores", "regex", "C.*thread.*completed"),
resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -145,7 +145,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     assertNotNull(values.get("CONTAINER.threadPool.coreLoadExecutor.completed"));
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"prefix", "CACHE.core.fieldCache", "property", "entries_count", "compact", "true"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"prefix", "CACHE.core.fieldCache", "property", "entries_count", MetricsHandler.COMPACT_PARAM,
"true"), resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
@@ -157,14 +157,14 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
     assertNotNull(m.get("entries_count"));
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"group", "jvm", "prefix", "CONTAINER.cores"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "group", "jvm", "prefix", "CONTAINER.cores"), resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     values = (NamedList) values.get("metrics");
     assertEquals(0, values.size());
 
     resp = new SolrQueryResponse();
-    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", CommonParams.WT, "json",
"group", "node", "type", "timer", "prefix", "CONTAINER.cores"), resp);
+    handler.handleRequestBody(req(CommonParams.QT, "/admin/metrics", MetricsHandler.COMPACT_PARAM,
"false", CommonParams.WT, "json", "group", "node", "type", "timer", "prefix", "CONTAINER.cores"),
resp);
     values = resp.getValues();
     assertNotNull(values.get("metrics"));
     SimpleOrderedMap map = (SimpleOrderedMap) values.get("metrics");

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/114a65b3/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrCloudReportersTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrCloudReportersTest.java
b/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrCloudReportersTest.java
index f527a17..df7e642 100644
--- a/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrCloudReportersTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrCloudReportersTest.java
@@ -119,20 +119,20 @@ public class SolrCloudReportersTest extends SolrCloudTestCase {
         assertEquals(reporters.toString(), 0, reporters.size());
         // verify specific metrics
         Map<String, Metric> metrics = metricManager.registry(registryName).getMetrics();
-        String key = "QUERY./select.requests.count";
+        String key = "QUERY./select.requests";
         assertTrue(key, metrics.containsKey(key));
         assertTrue(key, metrics.get(key) instanceof AggregateMetric);
-        key = "UPDATE./update/json.requests.count";
+        key = "UPDATE./update/json.requests";
         assertTrue(key, metrics.containsKey(key));
         assertTrue(key, metrics.get(key) instanceof AggregateMetric);
       }
       if (metricManager.registryNames().contains("solr.cluster")) {
         clusterRegistries++;
         Map<String,Metric> metrics = metricManager.registry("solr.cluster").getMetrics();
-        String key = "jvm.memory.heap.init.value";
+        String key = "jvm.memory.heap.init";
         assertTrue(key, metrics.containsKey(key));
         assertTrue(key, metrics.get(key) instanceof AggregateMetric);
-        key = "leader.test_collection.shard1.UPDATE./update/json.requests.count.max";
+        key = "leader.test_collection.shard1.UPDATE./update/json.requests.max";
         assertTrue(key, metrics.containsKey(key));
         assertTrue(key, metrics.get(key) instanceof AggregateMetric);
       }


Mime
View raw message