lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [2/2] lucene-solr:jira/solr-10247: SOLR-10247 Fix issues after review.
Date Thu, 09 Mar 2017 17:24:46 GMT
SOLR-10247 Fix issues after review.


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

Branch: refs/heads/jira/solr-10247
Commit: 238e5a30ec6b716cafd3b609b7599fa48861e0a3
Parents: 18ed19b
Author: Andrzej Bialecki <ab@apache.org>
Authored: Thu Mar 9 18:24:19 2017 +0100
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Thu Mar 9 18:24:19 2017 +0100

----------------------------------------------------------------------
 .../org/apache/solr/handler/admin/MetricsHandler.java   |  9 ++++++++-
 .../org/apache/solr/update/DirectUpdateHandler2.java    | 10 +++++-----
 .../java/org/apache/solr/update/SolrIndexWriter.java    | 12 ++++++------
 .../java/org/apache/solr/util/stats/MetricUtils.java    |  2 +-
 .../org/apache/solr/update/DirectUpdateHandlerTest.java |  1 -
 5 files changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/238e5a30/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 073f8bd..d51c2b4 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
@@ -50,6 +50,10 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
   final CoreContainer container;
   final SolrMetricManager metricManager;
 
+  public static final String VERSION_PARAM = "version";
+  public static final int VERSION_1 = 1;
+  public static final int VERSION_2 = 2;
+
   public MetricsHandler() {
     this.container = null;
     this.metricManager = null;
@@ -71,6 +75,8 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
       throw new SolrException(SolrException.ErrorCode.INVALID_STATE, "Core container instance
not initialized");
     }
 
+    int version = req.getParams().getInt(VERSION_PARAM, VERSION_1);
+    boolean compact = version == VERSION_2;
     MetricFilter mustMatchFilter = parseMustMatchFilter(req);
     List<MetricType> metricTypes = parseMetricTypes(req);
     List<MetricFilter> metricFilters = metricTypes.stream().map(MetricType::asMetricFilter).collect(Collectors.toList());
@@ -79,7 +85,8 @@ public class MetricsHandler extends RequestHandlerBase implements PermissionName
     NamedList response = new NamedList();
     for (String registryName : requestedRegistries) {
       MetricRegistry registry = metricManager.registry(registryName);
-      response.add(registryName, MetricUtils.toNamedList(registry, metricFilters, mustMatchFilter,
false, false, false, null));
+      response.add(registryName, MetricUtils.toNamedList(registry, metricFilters, mustMatchFilter,
false,
+          false, compact, null));
     }
     rsp.getValues().add("metrics", response);
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/238e5a30/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index 86ab086..5202659 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -160,11 +160,11 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
     splitCommands = manager.meter(registry, "splits", getCategory().toString(), scope);
     mergeIndexesCommands = manager.meter(registry, "merges", getCategory().toString(), scope);
     expungeDeleteCommands = manager.meter(registry, "expungeDeletes", getCategory().toString(),
scope);
-    manager.registerGauge(registry, () -> numDocsPending, true, "docsPending", getCategory().toString(),
scope);
-    manager.registerGauge(registry, () -> addCommands, true, "adds", getCategory().toString(),
scope);
-    manager.registerGauge(registry, () -> deleteByIdCommands, true, "deletesById", getCategory().toString(),
scope);
-    manager.registerGauge(registry, () -> deleteByQueryCommands, true, "deletesByQuery",
getCategory().toString(), scope);
-    manager.registerGauge(registry, () -> numErrors, true, "errors", getCategory().toString(),
scope);
+    manager.registerGauge(registry, () -> numDocsPending.longValue(), true, "docsPending",
getCategory().toString(), scope);
+    manager.registerGauge(registry, () -> addCommands.longValue(), true, "adds", getCategory().toString(),
scope);
+    manager.registerGauge(registry, () -> deleteByIdCommands.longValue(), true, "deletesById",
getCategory().toString(), scope);
+    manager.registerGauge(registry, () -> deleteByQueryCommands.longValue(), true, "deletesByQuery",
getCategory().toString(), scope);
+    manager.registerGauge(registry, () -> numErrors.longValue(), true, "errors", getCategory().toString(),
scope);
 
     addCommandsCumulative = manager.meter(registry, "cumulativeAdds", getCategory().toString(),
scope);
     deleteByIdCommandsCumulative = manager.meter(registry, "cumulativeDeletesById", getCategory().toString(),
scope);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/238e5a30/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
index 20b947f..e4c0a62 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
@@ -157,12 +157,12 @@ public class SolrIndexWriter extends IndexWriter {
         minorMerge = metricManager.timer(registry, "minor", SolrInfoMBean.Category.INDEX.toString(),
"merge");
         majorMerge = metricManager.timer(registry, "major", SolrInfoMBean.Category.INDEX.toString(),
"merge");
         mergeErrors = metricManager.counter(registry, "errors", SolrInfoMBean.Category.INDEX.toString(),
"merge");
-        metricManager.registerGauge(registry, () -> runningMajorMerges, true, "running",
SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
-        metricManager.registerGauge(registry, () -> runningMinorMerges, true, "running",
SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
-        metricManager.registerGauge(registry, () -> runningMajorMergesDocs, true, "running.docs",
SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
-        metricManager.registerGauge(registry, () -> runningMinorMergesDocs, true, "running.docs",
SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
-        metricManager.registerGauge(registry, () -> runningMajorMergesSegments, true,
"running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
-        metricManager.registerGauge(registry, () -> runningMinorMergesSegments, true,
"running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
+        metricManager.registerGauge(registry, () -> runningMajorMerges.get(), true, "running",
SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
+        metricManager.registerGauge(registry, () -> runningMinorMerges.get(), true, "running",
SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
+        metricManager.registerGauge(registry, () -> runningMajorMergesDocs.get(), true,
"running.docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
+        metricManager.registerGauge(registry, () -> runningMinorMergesDocs.get(), true,
"running.docs", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
+        metricManager.registerGauge(registry, () -> runningMajorMergesSegments.get(),
true, "running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "major");
+        metricManager.registerGauge(registry, () -> runningMinorMergesSegments.get(),
true, "running.segments", SolrInfoMBean.Category.INDEX.toString(), "merge", "minor");
         flushMeter = metricManager.meter(registry, "flush", SolrInfoMBean.Category.INDEX.toString());
       }
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/238e5a30/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
index e96fd21..d65386c 100644
--- a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
@@ -185,7 +185,7 @@ public class MetricUtils {
     Map<String, Object> map = (Map<String, Object>)o;
     for (Map.Entry<String, Object> entry : map.entrySet()) {
       if (entry.getValue() instanceof Map) { // flatten recursively
-        toSolrInputDocument(entry.getKey(), doc, (Map<String, Object>)entry.getValue());
+        toSolrInputDocument(entry.getKey(), doc, entry.getValue());
       } else {
         String key = prefix != null ? prefix + "." + entry.getKey() : entry.getKey();
         doc.addField(key, entry.getValue());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/238e5a30/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
index 6f00947..462241a 100644
--- a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
@@ -22,7 +22,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.LongAdder;
 
 import com.codahale.metrics.Gauge;
 import com.codahale.metrics.Meter;


Mime
View raw message