You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/02/01 15:56:36 UTC
[1/2] lucene-solr:branch_6x: SOLR-10054: Core swapping doesn't work
with new metrics changes in place.
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x c99b39fca -> f51a38fd4
SOLR-10054: Core swapping doesn't work with new metrics changes in place.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8299378e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8299378e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8299378e
Branch: refs/heads/branch_6x
Commit: 8299378eab3282e4dcb14b92645a4f1d214f13cc
Parents: c99b39f
Author: Andrzej Bialecki <ab...@apache.org>
Authored: Wed Feb 1 10:20:08 2017 +0100
Committer: Andrzej Bialecki <ab...@apache.org>
Committed: Wed Feb 1 10:20:46 2017 +0100
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +
.../org/apache/solr/core/CoreContainer.java | 10 ++-
.../java/org/apache/solr/core/SolrCores.java | 4 +-
.../solr/metrics/SolrCoreMetricManager.java | 3 -
.../apache/solr/metrics/SolrMetricManager.java | 85 +++++++++++-------
.../solr/metrics/SolrMetricManagerTest.java | 21 ++---
.../client/solrj/request/CoreAdminRequest.java | 18 ++++
.../AbstractEmbeddedSolrServerTestCase.java | 22 ++++-
.../client/solrj/request/TestCoreAdmin.java | 95 ++++++++++++++++++++
9 files changed, 207 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c3b6e22..82c9d6a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -101,10 +101,13 @@ Jetty 9.3.14.v20161028
Bug Fixes
----------------------
* SOLR-9969: "Plugin/Stats" section of the UI doesn't display empty metric types (Tom�s Fern�ndez L�bbe)
+
* SOLR-8491: solr.cmd SOLR_SSL_OPTS is overwritten (Sam Yi, Andy Hind, Marcel Berteler, Kevin Risden)
* SOLR-10031: Validation of filename params in ReplicationHandler (Hrishikesh Gadre, janhoy)
+* SOLR-10054: Core swapping doesn't work with new metrics changes in place (ab)
+
================== 6.4.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/core/src/java/org/apache/solr/core/CoreContainer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index b63375a..12b6d94 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -72,6 +72,7 @@ import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.solr.handler.component.ShardHandlerFactory;
import org.apache.solr.logging.LogWatcher;
import org.apache.solr.logging.MDCLoggingContext;
+import org.apache.solr.metrics.SolrCoreMetricManager;
import org.apache.solr.metrics.SolrMetricManager;
import org.apache.solr.metrics.SolrMetricProducer;
import org.apache.solr.request.SolrRequestHandler;
@@ -1159,15 +1160,15 @@ public class CoreContainer {
SolrCore core = solrCores.remove(name);
coresLocator.delete(this, cd);
- // delete metrics specific to this core
- metricManager.removeRegistry(SolrMetricManager.getRegistryName(SolrInfoMBean.Group.core, name));
-
if (core == null) {
// transient core
SolrCore.deleteUnloadedCore(cd, deleteDataDir, deleteInstanceDir);
return;
}
+ // delete metrics specific to this core
+ metricManager.removeRegistry(core.getCoreMetricManager().getRegistryName());
+
if (zkSys.getZkController() != null) {
// cancel recovery in cloud mode
core.getSolrCoreState().cancelRecovery();
@@ -1193,6 +1194,9 @@ public class CoreContainer {
SolrIdentifierValidator.validateCoreName(toName);
try (SolrCore core = getCore(name)) {
if (core != null) {
+ String oldRegistryName = core.getCoreMetricManager().getRegistryName();
+ String newRegistryName = SolrCoreMetricManager.createRegistryName(core.getCoreDescriptor().getCollectionName(), toName);
+ metricManager.swapRegistries(oldRegistryName, newRegistryName);
registerCore(toName, core, true, false);
SolrCore old = solrCores.remove(name);
coresLocator.rename(this, old.getCoreDescriptor(), core.getCoreDescriptor());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/core/src/java/org/apache/solr/core/SolrCores.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCores.java b/solr/core/src/java/org/apache/solr/core/SolrCores.java
index 2bcea17..b25e9bb 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCores.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCores.java
@@ -239,7 +239,9 @@ class SolrCores {
}
cores.put(n0, c1);
cores.put(n1, c0);
-
+ container.getMetricManager().swapRegistries(
+ c0.getCoreMetricManager().getRegistryName(),
+ c1.getCoreMetricManager().getRegistryName());
c0.setName(n1);
c1.setName(n0);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
index 3bebcd3..eb5b687 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java
@@ -73,9 +73,6 @@ public class SolrCoreMetricManager implements Closeable {
}
// close old reporters
metricManager.closeReporters(oldRegistryName);
- metricManager.moveMetrics(oldRegistryName, registryName, null);
- // old registry is no longer used - we have moved the metrics
- metricManager.removeRegistry(oldRegistryName);
// load reporters again, using the new core name
loadReporters();
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
index caa8906..cac5389 100644
--- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
+++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricManager.java
@@ -85,6 +85,7 @@ public class SolrMetricManager {
private final Map<String, Map<String, SolrMetricReporter>> reporters = new HashMap<>();
private final Lock reportersLock = new ReentrantLock();
+ private final Lock swapLock = new ReentrantLock();
public SolrMetricManager() { }
@@ -178,18 +179,27 @@ public class SolrMetricManager {
if (isSharedRegistry(registry)) {
return SharedMetricRegistries.getOrCreate(registry);
} else {
- final MetricRegistry existing = registries.get(registry);
- if (existing == null) {
- final MetricRegistry created = new MetricRegistry();
- final MetricRegistry raced = registries.putIfAbsent(registry, created);
- if (raced == null) {
- return created;
- } else {
- return raced;
- }
+ swapLock.lock();
+ try {
+ return getOrCreate(registries, registry);
+ } finally {
+ swapLock.unlock();
+ }
+ }
+ }
+
+ private static MetricRegistry getOrCreate(ConcurrentMap<String, MetricRegistry> map, String registry) {
+ final MetricRegistry existing = map.get(registry);
+ if (existing == null) {
+ final MetricRegistry created = new MetricRegistry();
+ final MetricRegistry raced = map.putIfAbsent(registry, created);
+ if (raced == null) {
+ return created;
} else {
- return existing;
+ return raced;
}
+ } else {
+ return existing;
}
}
@@ -205,34 +215,47 @@ public class SolrMetricManager {
if (isSharedRegistry(registry)) {
SharedMetricRegistries.remove(registry);
} else {
- registries.remove(registry);
+ swapLock.lock();
+ try {
+ registries.remove(registry);
+ } finally {
+ swapLock.unlock();
+ }
}
}
/**
- * Move all matching metrics from one registry to another. This is useful eg. during
- * {@link org.apache.solr.core.SolrCore} rename or swap operations.
- * @param fromRegistry source registry
- * @param toRegistry target registry
- * @param filter optional {@link MetricFilter} to select what metrics to move. If null
- * then all metrics will be moved.
+ * Swap registries. This is useful eg. during
+ * {@link org.apache.solr.core.SolrCore} rename or swap operations. NOTE:
+ * this operation is not supported for shared registries.
+ * @param registry1 source registry
+ * @param registry2 target registry. Note: when used after core rename the target registry doesn't
+ * exist, so the swap operation will only rename the existing registry without creating
+ * an empty one under the previous name.
*/
- public void moveMetrics(String fromRegistry, String toRegistry, MetricFilter filter) {
- MetricRegistry from = registry(fromRegistry);
- MetricRegistry to = registry(toRegistry);
- if (from == to) {
- return;
+ public void swapRegistries(String registry1, String registry2) {
+ registry1 = overridableRegistryName(registry1);
+ registry2 = overridableRegistryName(registry2);
+ if (isSharedRegistry(registry1) || isSharedRegistry(registry2)) {
+ throw new UnsupportedOperationException("Cannot swap shared registry: " + registry1 + ", " + registry2);
}
- if (filter == null) {
- to.registerAll(from);
- from.removeMatching(MetricFilter.ALL);
- } else {
- for (Map.Entry<String, Metric> entry : from.getMetrics().entrySet()) {
- if (filter.matches(entry.getKey(), entry.getValue())) {
- to.register(entry.getKey(), entry.getValue());
- }
+ swapLock.lock();
+ try {
+ MetricRegistry from = registries.get(registry1);
+ MetricRegistry to = registries.get(registry2);
+ if (from == to) {
+ return;
+ }
+ MetricRegistry reg1 = registries.remove(registry1);
+ MetricRegistry reg2 = registries.remove(registry2);
+ if (reg2 != null) {
+ registries.put(registry1, reg2);
}
- from.removeMatching(filter);
+ if (reg1 != null) {
+ registries.put(registry2, reg1);
+ }
+ } finally {
+ swapLock.unlock();
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java
index 0d94c1a..3813488 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrMetricManagerTest.java
@@ -51,7 +51,7 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
}
@Test
- public void testMoveMetrics() throws Exception {
+ public void testSwapRegistries() throws Exception {
Random r = random();
SolrMetricManager metricManager = new SolrMetricManager();
@@ -65,13 +65,14 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
metricManager.register(fromName, entry.getValue(), false, entry.getKey(), "metrics1");
}
for (Map.Entry<String, Counter> entry : metrics2.entrySet()) {
- metricManager.register(fromName, entry.getValue(), false, entry.getKey(), "metrics2");
+ metricManager.register(toName, entry.getValue(), false, entry.getKey(), "metrics2");
}
- assertEquals(metrics1.size() + metrics2.size(), metricManager.registry(fromName).getMetrics().size());
+ assertEquals(metrics1.size(), metricManager.registry(fromName).getMetrics().size());
+ assertEquals(metrics2.size(), metricManager.registry(toName).getMetrics().size());
- // move metrics1
- metricManager.moveMetrics(fromName, toName, new SolrMetricManager.PrefixFilter("metrics1"));
- // check the remaining metrics
+ // swap
+ metricManager.swapRegistries(fromName, toName);
+ // check metrics
Map<String, Metric> fromMetrics = metricManager.registry(fromName).getMetrics();
assertEquals(metrics2.size(), fromMetrics.size());
for (Map.Entry<String, Counter> entry : metrics2.entrySet()) {
@@ -79,7 +80,6 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
assertNotNull(value);
assertEquals(entry.getValue(), value);
}
- // check the moved metrics
Map<String, Metric> toMetrics = metricManager.registry(toName).getMetrics();
assertEquals(metrics1.size(), toMetrics.size());
for (Map.Entry<String, Counter> entry : metrics1.entrySet()) {
@@ -87,13 +87,6 @@ public class SolrMetricManagerTest extends SolrTestCaseJ4 {
assertNotNull(value);
assertEquals(entry.getValue(), value);
}
-
- // move all remaining metrics
- metricManager.moveMetrics(fromName, toName, null);
- fromMetrics = metricManager.registry(fromName).getMetrics();
- assertEquals(0, fromMetrics.size());
- toMetrics = metricManager.registry(toName).getMetrics();
- assertEquals(metrics1.size() + metrics2.size(), toMetrics.size());
}
@Test
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
index 002bbc3..3967d41 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
@@ -619,6 +619,24 @@ public class CoreAdminRequest extends SolrRequest<CoreAdminResponse> {
return req.process( client );
}
+ /**
+ * Swap two existing cores.
+ * @param core1 name of the first core
+ * @param core2 name of the other core
+ * @param client SolrClient to use
+ * @return response
+ * @throws SolrServerException if one or both cores don't exist
+ * @throws IOException on IO errors
+ */
+ public static CoreAdminResponse swapCore(String core1, String core2, SolrClient client)
+ throws SolrServerException, IOException {
+ CoreAdminRequest req = new CoreAdminRequest();
+ req.setCoreName(core1);
+ req.setOtherCoreName(core2);
+ req.setAction( CoreAdminAction.SWAP );
+ return req.process( client );
+ }
+
public static CoreStatus getCoreStatus(String coreName, SolrClient client) throws SolrServerException, IOException {
return getCoreStatus(coreName, true, client);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java
index 117ec1d..2a5a08c 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java
@@ -19,26 +19,37 @@ package org.apache.solr.client.solrj.embedded;
import java.io.File;
import java.nio.file.Path;
+import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.core.CoreContainer;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
public abstract class AbstractEmbeddedSolrServerTestCase extends SolrTestCaseJ4 {
- protected static final Path SOLR_HOME = getFile("solrj/solr/shared").toPath().toAbsolutePath();
+ protected static Path SOLR_HOME;
+ protected static Path CONFIG_HOME;
protected CoreContainer cores = null;
protected File tempDir;
+ @BeforeClass
+ public static void setUpHome() throws Exception {
+ CONFIG_HOME = getFile("solrj/solr/shared").toPath().toAbsolutePath();
+ SOLR_HOME = createTempDir("solrHome");
+ FileUtils.copyDirectory(CONFIG_HOME.toFile(), SOLR_HOME.toFile());
+ }
+
@Override
@Before
public void setUp() throws Exception {
super.setUp();
System.setProperty("solr.solr.home", SOLR_HOME.toString());
- System.setProperty("configSetBase", SOLR_HOME.resolve("../configsets").normalize().toString());
+ System.setProperty("configSetBaseDir", CONFIG_HOME.resolve("../configsets").normalize().toString());
System.out.println("Solr home: " + SOLR_HOME.toString());
//The index is always stored within a temporary directory
@@ -73,6 +84,13 @@ public abstract class AbstractEmbeddedSolrServerTestCase extends SolrTestCaseJ4
super.tearDown();
}
+ @AfterClass
+ public static void tearDownHome() throws Exception {
+ if (SOLR_HOME != null) {
+ FileUtils.deleteDirectory(SOLR_HOME.toFile());
+ }
+ }
+
protected void deleteAdditionalFiles() {
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8299378e/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
index ef4dad7..19adf35 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
@@ -18,21 +18,29 @@ package org.apache.solr.client.solrj.request;
import java.io.File;
import java.lang.invoke.MethodHandles;
+import java.util.Collection;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+import com.codahale.metrics.MetricRegistry;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrIgnoredThreadsFilter;
import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.embedded.AbstractEmbeddedSolrServerTestCase;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
+import org.apache.solr.metrics.SolrCoreMetricManager;
+import org.apache.solr.metrics.SolrMetricManager;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -186,6 +194,93 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
assertTrue(exceptionMessage.contains("must consist entirely of periods, underscores, hyphens, and alphanumerics"));
}
}
+
+ @Test
+ public void testValidCoreRename() throws Exception {
+ Collection<String> names = cores.getAllCoreNames();
+ assertFalse(names.toString(), names.contains("coreRenamed"));
+ assertTrue(names.toString(), names.contains("core1"));
+ CoreAdminRequest.renameCore("core1", "coreRenamed", getSolrAdmin());
+ names = cores.getAllCoreNames();
+ assertTrue(names.toString(), names.contains("coreRenamed"));
+ assertFalse(names.toString(), names.contains("core1"));
+ // rename it back
+ CoreAdminRequest.renameCore("coreRenamed", "core1", getSolrAdmin());
+ names = cores.getAllCoreNames();
+ assertFalse(names.toString(), names.contains("coreRenamed"));
+ assertTrue(names.toString(), names.contains("core1"));
+ }
+
+ @Test
+ public void testCoreSwap() throws Exception {
+ // index marker docs to core0
+ SolrClient cli0 = getSolrCore0();
+ SolrInputDocument d = new SolrInputDocument("id", "core0-0");
+ cli0.add(d);
+ d = new SolrInputDocument("id", "core0-1");
+ cli0.add(d);
+ cli0.commit();
+ // index a marker doc to core1
+ SolrClient cli1 = getSolrCore1();
+ d = new SolrInputDocument("id", "core1-0");
+ cli1.add(d);
+ cli1.commit();
+
+ // initial state assertions
+ SolrQuery q = new SolrQuery("*:*");
+ QueryResponse rsp = cli0.query(q);
+ SolrDocumentList docs = rsp.getResults();
+ assertEquals(2, docs.size());
+ docs.forEach(doc -> {
+ assertTrue(doc.toString(), doc.getFieldValue("id").toString().startsWith("core0-"));
+ });
+
+ rsp = cli1.query(q);
+ docs = rsp.getResults();
+ assertEquals(1, docs.size());
+ docs.forEach(doc -> {
+ assertTrue(doc.toString(), doc.getFieldValue("id").toString().startsWith("core1-"));
+ });
+
+ // assert initial metrics
+ SolrMetricManager metricManager = cores.getMetricManager();
+ String core0RegistryName = SolrCoreMetricManager.createRegistryName(null, "core0");
+ String core1RegistryName = SolrCoreMetricManager.createRegistryName(null, "core1");
+ MetricRegistry core0Registry = metricManager.registry(core0RegistryName);
+ MetricRegistry core1Registry = metricManager.registry(core1RegistryName);
+
+ // 2 docs + 1 commit
+ assertEquals(3, core0Registry.counter("UPDATE./update.requests").getCount());
+ // 1 doc + 1 commit
+ assertEquals(2, core1Registry.counter("UPDATE./update.requests").getCount());
+
+ // swap
+ CoreAdminRequest.swapCore("core0", "core1", getSolrAdmin());
+
+ // assert state after swap
+ cli0 = getSolrCore0();
+ cli1 = getSolrCore1();
+
+ rsp = cli0.query(q);
+ docs = rsp.getResults();
+ assertEquals(1, docs.size());
+ docs.forEach(doc -> {
+ assertTrue(doc.toString(), doc.getFieldValue("id").toString().startsWith("core1-"));
+ });
+
+ rsp = cli1.query(q);
+ docs = rsp.getResults();
+ assertEquals(2, docs.size());
+ docs.forEach(doc -> {
+ assertTrue(doc.toString(), doc.getFieldValue("id").toString().startsWith("core0-"));
+ });
+
+ core0Registry = metricManager.registry(core0RegistryName);
+ core1Registry = metricManager.registry(core1RegistryName);
+
+ assertEquals(2, core0Registry.counter("UPDATE./update.requests").getCount());
+ assertEquals(3, core1Registry.counter("UPDATE./update.requests").getCount());
+ }
@BeforeClass
public static void before() {
[2/2] lucene-solr:branch_6x: SOLR-10035 Admin UI cannot find
dataimport handlers.
Posted by ab...@apache.org.
SOLR-10035 Admin UI cannot find dataimport handlers.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/f51a38fd
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/f51a38fd
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/f51a38fd
Branch: refs/heads/branch_6x
Commit: f51a38fd4cd5f98da3a26df55970d662227b633a
Parents: 8299378
Author: Andrzej Bialecki <ab...@apache.org>
Authored: Wed Feb 1 11:36:15 2017 +0100
Committer: Andrzej Bialecki <ab...@apache.org>
Committed: Wed Feb 1 12:24:19 2017 +0100
----------------------------------------------------------------------
solr/CHANGES.txt | 7 +++
.../handler/admin/SolrInfoMBeanHandler.java | 47 ++++++++++++++++++--
.../solr/handler/admin/MBeansHandlerTest.java | 35 +++++++++++++++
solr/webapp/web/css/angular/plugins.css | 9 ++--
solr/webapp/web/css/styles/plugins.css | 9 ++--
.../web/js/angular/controllers/dataimport.js | 2 +-
solr/webapp/web/js/scripts/dataimport.js | 2 +-
7 files changed, 99 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f51a38fd/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 82c9d6a..d003633 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -98,6 +98,13 @@ Apache UIMA 2.3.1
Apache ZooKeeper 3.4.6
Jetty 9.3.14.v20161028
+Upgrade Notes
+----------------------
+* SOLR-10035: Category names of some SolrInfoMBeans have been changed in release 6.4.0. This issue
+ changes the /admin/mbeans handler to return these beans both under the new and the old back-compatible
+ names. Old names are deprecated and will be eventually removed in Solr 7.0. They can be also removed via
+ system property "-Dsolr.mbeans.useOnlyNewNaming=true". (ab, Shawn Heisey, Jan H�ydahl)
+
Bug Fixes
----------------------
* SOLR-9969: "Plugin/Stats" section of the UI doesn't display empty metric types (Tom�s Fern�ndez L�bbe)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f51a38fd/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java
index f5f28c5..297cdbf 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SolrInfoMBeanHandler.java
@@ -33,6 +33,7 @@ import java.io.StringReader;
import java.net.URL;
import java.text.NumberFormat;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@@ -46,6 +47,21 @@ import java.util.HashSet;
@SuppressWarnings("unchecked")
public class SolrInfoMBeanHandler extends RequestHandlerBase {
+ // back-compat names, only needed in 6.x - see SOLR-10035
+ static final Map<String, String> newToOldCategories = new HashMap<String, String>() {{
+ put(Category.QUERY.toString(), "QUERYHANDLER");
+ put(Category.UPDATE.toString(), "UPDATEHANDLER");
+ put(Category.HIGHLIGHTER.toString(), "HIGHLIGHTING");
+ }};
+ static final Map<String, String> oldToNewCategories = new HashMap<String, String>() {{
+ put("QUERYHANDLER", Category.QUERY.toString());
+ put("UPDATEHANDLER", Category.UPDATE.toString());
+ put("HIGHLIGHTING", Category.HIGHLIGHTER.toString());
+ }};
+
+ static final boolean useOnlyNewNaming = Boolean.valueOf(System.getProperty("solr.mbeans.useOnlyNewNaming", "false"));
+
+
/**
* Take an array of any type and generate a Set containing the toString.
* Set is guarantee to never be null (but may be empty)
@@ -120,9 +136,22 @@ public class SolrInfoMBeanHandler extends RequestHandlerBase {
for (SolrInfoMBean.Category cat : SolrInfoMBean.Category.values()) {
cats.add(cat.name(), new SimpleOrderedMap<NamedList<Object>>());
}
+ if (!useOnlyNewNaming) {
+ for (String oldName : newToOldCategories.values()) {
+ cats.add(oldName, new SimpleOrderedMap<NamedList<Object>>());
+ }
+ }
} else {
for (String catName : requestedCats) {
cats.add(catName,new SimpleOrderedMap<NamedList<Object>>());
+ if (!useOnlyNewNaming) {
+ if (newToOldCategories.containsKey(catName)) {
+ cats.add(newToOldCategories.get(catName), new SimpleOrderedMap<NamedList<Object>>());
+ }
+ if (oldToNewCategories.containsKey(catName)) {
+ cats.add(oldToNewCategories.get(catName), new SimpleOrderedMap<NamedList<Object>>());
+ }
+ }
}
}
@@ -130,18 +159,28 @@ public class SolrInfoMBeanHandler extends RequestHandlerBase {
Map<String, SolrInfoMBean> reg = req.getCore().getInfoRegistry();
for (Map.Entry<String, SolrInfoMBean> entry : reg.entrySet()) {
- addMBean(req, cats, requestedKeys, entry.getKey(),entry.getValue());
+ String cat = entry.getValue().getCategory().name();
+ addMBean(req, cat, cats, requestedKeys, entry.getKey(),entry.getValue());
+ // add it also under back-compat name
+ if (!useOnlyNewNaming && newToOldCategories.containsKey(cat)) {
+ addMBean(req, newToOldCategories.get(cat), cats, requestedKeys, entry.getKey(),entry.getValue());
+ }
}
for (SolrInfoMBean infoMBean : req.getCore().getCoreDescriptor().getCoreContainer().getResourceLoader().getInfoMBeans()) {
- addMBean(req,cats,requestedKeys,infoMBean.getName(),infoMBean);
+ String cat = infoMBean.getCategory().name();
+ addMBean(req,cat, cats,requestedKeys,infoMBean.getName(),infoMBean);
+ // add it also under back-compat name
+ if (!useOnlyNewNaming && newToOldCategories.containsKey(cat)) {
+ addMBean(req, newToOldCategories.get(cat), cats, requestedKeys, infoMBean.getName(), infoMBean);
+ }
}
return cats;
}
- private void addMBean(SolrQueryRequest req, NamedList<NamedList<NamedList<Object>>> cats, Set<String> requestedKeys, String key, SolrInfoMBean m) {
+ private void addMBean(SolrQueryRequest req, String categoryName, NamedList<NamedList<NamedList<Object>>> cats, Set<String> requestedKeys, String key, SolrInfoMBean m) {
if ( ! ( requestedKeys.isEmpty() || requestedKeys.contains(key) ) ) return;
- NamedList<NamedList<Object>> catInfo = cats.get(m.getCategory().name());
+ NamedList<NamedList<Object>> catInfo = cats.get(categoryName);
if ( null == catInfo ) return;
NamedList<Object> mBeanInfo = new SimpleOrderedMap<>();
mBeanInfo.add("class", m.getName());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f51a38fd/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
index 21634b7..a5e0a6c 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/MBeansHandlerTest.java
@@ -25,6 +25,7 @@ import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequest;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -84,4 +85,38 @@ public class MBeansHandlerTest extends SolrTestCaseJ4 {
assertTrue("external entity ignored properly", true);
}
+
+ @Test
+ public void testBackCompatNames() throws Exception {
+ SolrQueryRequest req = req(
+ CommonParams.QT,"/admin/mbeans",
+ CommonParams.WT,"xml"
+ );
+ h.validateQuery(req,
+ "boolean(//lst[@name='QUERY'])",
+ "boolean(//lst[@name='QUERYHANDLER'])",
+ "boolean(//lst[@name='UPDATE'])",
+ "boolean(//lst[@name='UPDATEHANDLER'])",
+ "boolean(//lst[@name='HIGHLIGHTING'])",
+ "boolean(//lst[@name='HIGHLIGHTER'])"
+ );
+ req = req(
+ CommonParams.QT,"/admin/mbeans",
+ CommonParams.WT,"xml",
+ "cat", "QUERYHANDLER"
+ );
+ h.validateQuery(req,
+ "boolean(//lst[@name='QUERY'])",
+ "boolean(//lst[@name='QUERYHANDLER'])"
+ );
+ req = req(
+ CommonParams.QT,"/admin/mbeans",
+ CommonParams.WT,"xml",
+ "cat", "UPDATE"
+ );
+ h.validateQuery(req,
+ "boolean(//lst[@name='UPDATE'])",
+ "boolean(//lst[@name='UPDATEHANDLER'])"
+ );
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f51a38fd/solr/webapp/web/css/angular/plugins.css
----------------------------------------------------------------------
diff --git a/solr/webapp/web/css/angular/plugins.css b/solr/webapp/web/css/angular/plugins.css
index 0310e0e..eb524c4 100644
--- a/solr/webapp/web/css/angular/plugins.css
+++ b/solr/webapp/web/css/angular/plugins.css
@@ -25,9 +25,12 @@ limitations under the License.
#content #plugins #navigation .cache a { background-image: url( ../../img/ico/disk-black.png ); }
#content #plugins #navigation .core a { background-image: url( ../../img/ico/wooden-box.png ); }
#content #plugins #navigation .other a { background-image: url( ../../img/ico/zone.png ); }
-#content #plugins #navigation .highlighting a { background-image: url( ../../img/ico/highlighter-text.png ); }
-#content #plugins #navigation .updatehandler a{ background-image: url( ../../img/ico/arrow-circle.png ); }
-#content #plugins #navigation .queryhandler a { background-image: url( ../../img/ico/magnifier.png ); }
+#content #plugins #navigation .highlighting a { text-decoration: line-through; background-image: url( ../../img/ico/highlighter-text.png ); }
+#content #plugins #navigation .highlighter a { background-image: url( ../../img/ico/highlighter-text.png ); }
+#content #plugins #navigation .updatehandler a{ text-decoration: line-through; background-image: url( ../../img/ico/arrow-circle.png ); }
+#content #plugins #navigation .update a{ background-image: url( ../../img/ico/arrow-circle.png ); }
+#content #plugins #navigation .queryhandler a { text-decoration: line-through; background-image: url( ../../img/ico/magnifier.png ); }
+#content #plugins #navigation .query a { background-image: url( ../../img/ico/magnifier.png ); }
#content #plugins #navigation .queryparser a { background-image: url( ../../img/ico/asterisk.png ); }
#content #plugins #navigation .PLUGINCHANGES { margin-top: 20px; }
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f51a38fd/solr/webapp/web/css/styles/plugins.css
----------------------------------------------------------------------
diff --git a/solr/webapp/web/css/styles/plugins.css b/solr/webapp/web/css/styles/plugins.css
index f8ea769..290bdff 100644
--- a/solr/webapp/web/css/styles/plugins.css
+++ b/solr/webapp/web/css/styles/plugins.css
@@ -25,9 +25,12 @@ limitations under the License.
#content #plugins #navigation .cache a { background-image: url( ../../img/ico/disk-black.png ); }
#content #plugins #navigation .core a { background-image: url( ../../img/ico/wooden-box.png ); }
#content #plugins #navigation .other a { background-image: url( ../../img/ico/zone.png ); }
-#content #plugins #navigation .highlighting a { background-image: url( ../../img/ico/highlighter-text.png ); }
-#content #plugins #navigation .updatehandler a{ background-image: url( ../../img/ico/arrow-circle.png ); }
-#content #plugins #navigation .queryhandler a { background-image: url( ../../img/ico/magnifier.png ); }
+#content #plugins #navigation .highlighting a { text-decoration: line-through; background-image: url( ../../img/ico/highlighter-text.png ); }
+#content #plugins #navigation .highlighter a { background-image: url( ../../img/ico/highlighter-text.png ); }
+#content #plugins #navigation .updatehandler a{ text-decoration: line-through; background-image: url( ../../img/ico/arrow-circle.png ); }
+#content #plugins #navigation .update a{ background-image: url( ../../img/ico/arrow-circle.png ); }
+#content #plugins #navigation .queryhandler a { text-decoration: line-through; background-image: url( ../../img/ico/magnifier.png ); }
+#content #plugins #navigation .query a { background-image: url( ../../img/ico/magnifier.png ); }
#content #plugins #navigation .queryparser a { background-image: url( ../../img/ico/asterisk.png ); }
#content #plugins #navigation .PLUGINCHANGES { margin-top: 20px; }
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f51a38fd/solr/webapp/web/js/angular/controllers/dataimport.js
----------------------------------------------------------------------
diff --git a/solr/webapp/web/js/angular/controllers/dataimport.js b/solr/webapp/web/js/angular/controllers/dataimport.js
index d8fbc4f..3a26324 100644
--- a/solr/webapp/web/js/angular/controllers/dataimport.js
+++ b/solr/webapp/web/js/angular/controllers/dataimport.js
@@ -22,7 +22,7 @@ solrAdminApp.controller('DataImportController',
$scope.resetMenu("dataimport", Constants.IS_COLLECTION_PAGE);
$scope.refresh = function () {
- Mbeans.info({core: $routeParams.core, cat: 'QUERYHANDLER'}, function (data) {
+ Mbeans.info({core: $routeParams.core, cat: 'QUERY'}, function (data) {
var mbeans = data['solr-mbeans'][1];
$scope.handlers = [];
for (var key in mbeans) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f51a38fd/solr/webapp/web/js/scripts/dataimport.js
----------------------------------------------------------------------
diff --git a/solr/webapp/web/js/scripts/dataimport.js b/solr/webapp/web/js/scripts/dataimport.js
index ef2b896..20532c6 100644
--- a/solr/webapp/web/js/scripts/dataimport.js
+++ b/solr/webapp/web/js/scripts/dataimport.js
@@ -28,7 +28,7 @@ sammy.bind
$.ajax
(
{
- url : core_basepath + '/admin/mbeans?cat=QUERYHANDLER&wt=json',
+ url : core_basepath + '/admin/mbeans?cat=QUERY&wt=json',
dataType : 'json',
beforeSend : function( xhr, settings )
{