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-12541: Metrics handler throws an error if there are transient cores.
Date Tue, 07 Aug 2018 11:21:54 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 08ca54f1f -> 208d59b5e


SOLR-12541: Metrics handler throws an error if there are transient cores.


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

Branch: refs/heads/master
Commit: 208d59b5e3dbc5207d9b150d56d70e53f81c0e3f
Parents: 08ca54f
Author: Andrzej Bialecki <ab@apache.org>
Authored: Tue Aug 7 13:20:44 2018 +0200
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Tue Aug 7 13:21:41 2018 +0200

----------------------------------------------------------------------
 solr/CHANGES.txt                                     |  2 ++
 .../org/apache/solr/handler/ReplicationHandler.java  |  4 ++--
 .../src/test/org/apache/solr/core/TestLazyCores.java | 15 +++++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/208d59b5/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ac8ff3c..d5edef3 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -213,6 +213,8 @@ Bug Fixes
 
 * SOLR-11770: NPE in tvrh if no field is specified and document doesn't contain any fields
with term vectors
 
+* SOLR-12541: Metrics handler throws an error if there are transient cores. (ab)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/208d59b5/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
index 93b8f25..5041841 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -837,13 +837,13 @@ public class ReplicationHandler extends RequestHandlerBase implements
SolrCoreAw
   public void initializeMetrics(SolrMetricManager manager, String registry, String tag, String
scope) {
     super.initializeMetrics(manager, registry, tag, scope);
 
-    manager.registerGauge(this, registry, () -> core != null ? NumberUtils.readableSize(core.getIndexSize())
: "",
+    manager.registerGauge(this, registry, () -> (core != null && !core.isClosed()
? NumberUtils.readableSize(core.getIndexSize()) : ""),
         tag, true, "indexSize", getCategory().toString(), scope);
     manager.registerGauge(this, registry, () -> (core != null && !core.isClosed()
? getIndexVersion().toString() : ""),
         tag, true, "indexVersion", getCategory().toString(), scope);
     manager.registerGauge(this, registry, () -> (core != null && !core.isClosed()
? getIndexVersion().generation : 0),
         tag, true, GENERATION, getCategory().toString(), scope);
-    manager.registerGauge(this, registry, () -> core != null ? core.getIndexDir() : "",
+    manager.registerGauge(this, registry, () -> (core != null && !core.isClosed()
? core.getIndexDir() : ""),
         tag, true, "indexPath", getCategory().toString(), scope);
     manager.registerGauge(this, registry, () -> isMaster,
         tag, true, "isMaster", getCategory().toString(), scope);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/208d59b5/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
index 9d03ca4..f8ffb84 100644
--- a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
+++ b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
@@ -33,9 +33,11 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.handler.admin.CoreAdminHandler;
+import org.apache.solr.handler.admin.MetricsHandler;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
@@ -240,6 +242,19 @@ public class TestLazyCores extends SolrTestCaseJ4 {
           "collection8", "collection9");
       checkNotInCores(cc, Arrays.asList("collection2", "collection3"));
 
+      // verify that getting metrics from an unloaded core doesn't cause exceptions (SOLR-12541)
+      MetricsHandler handler = new MetricsHandler(h.getCoreContainer());
+
+      SolrQueryResponse resp = new SolrQueryResponse();
+      handler.handleRequest(makeReq(core1, CommonParams.QT, "/admin/metrics"), resp);
+      NamedList values = resp.getValues();
+      assertNotNull(values.get("metrics"));
+      values = (NamedList) values.get("metrics");
+      NamedList nl = (NamedList) values.get("solr.core.collection2");
+      assertNotNull(nl);
+      Object o = nl.get("REPLICATION./replication.indexPath");
+      assertNotNull(o);
+
 
       // Note decrementing the count when the core is removed from the lazyCores list is
appropriate, since the
       // refcount is 1 when constructed. anyone _else_ who's opened up one has to close it.


Mime
View raw message