Skip to content

Apache Lucene open-source search software

SOLR-10742: SolrCores.getNamesForCore is quite inefficient and blocks other core operations

Erick Ericksone9568c347316
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 902540ee727..f6f816c64da 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -118,6 +118,8 @@ Other Changes
* SOLR-14592: Upgrade Zookeeper to 3.6.1. NOTE: this required upgrading netty to 4.1.50 (Erick Erickson)
+* SOLR-10742: SolrCores.getNamesForCore is quite inefficient and blocks other core operations.
+ NOTE: this experimental method has been removed (Erick Erickson)
================== 8.6.0 ==================
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 c9ef2969960..53373b6d1d7 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -1526,15 +1526,6 @@ public class CoreContainer {
return solrCores.getLoadedCoreNames();
}
- /**
- * This method is currently experimental.
- *
- * @return a Collection of the names that a specific core object is mapped to, there are more than one.
- */
- public Collection<String> getNamesForCore(SolrCore core) {
- return solrCores.getNamesForCore(core);
- }
-
/**
* get a list of all the cores that are currently known, whether currently loaded or not
*
@@ -1542,7 +1533,6 @@ public class CoreContainer {
*/
public Collection<String> getAllCoreNames() {
return solrCores.getAllCoreNames();
-
}
/**
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 04d4879531b..0b1c551b054 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1190,7 +1190,6 @@ public final class SolrCore implements SolrInfoBean, Closeable {
parentContext.gauge(() -> isClosed() ? 0 : getIndexSize(), true, "sizeInBytes", Category.INDEX.toString());
parentContext.gauge(() -> isClosed() ? "(closed)" : NumberUtils.readableSize(getIndexSize()), true, "size", Category.INDEX.toString());
if (coreContainer != null) {
- parentContext.gauge(() -> coreContainer.getNamesForCore(this), true, "aliases", Category.CORE.toString());
final CloudDescriptor cd = getCoreDescriptor().getCloudDescriptor();
if (cd != null) {
parentContext.gauge(() -> {
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 d0e87849d79..bfce95923d0 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCores.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCores.java
@@ -17,7 +17,6 @@
package org.apache.solr.core;
import com.google.common.collect.Lists;
-import org.apache.http.annotation.Experimental;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.logging.MDCLoggingContext;
@@ -210,28 +209,6 @@ class SolrCores {
}
return set;
}
-
- /** This method is currently experimental.
- *
- * @return a Collection of the names that a specific core object is mapped to, there are more than one.
- */
- @Experimental
- List<String> getNamesForCore(SolrCore core) {
- List<String> lst = new ArrayList<>();
-
- synchronized (modifyLock) {
- for (Map.Entry<String, SolrCore> entry : cores.entrySet()) {
- if (core == entry.getValue()) {
- lst.add(entry.getKey());
- }
- }
- if (getTransientCacheHandler() != null) {
- lst.addAll(getTransientCacheHandler().getNamesForCore(core));
- }
- }
- return lst;
- }
-
/**
* Gets a list of all cores, loaded and unloaded
*
diff --git a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCache.java b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCache.java
index 278590e9ff6..0947bd78380 100644
--- a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCache.java
+++ b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCache.java
@@ -19,12 +19,8 @@ package org.apache.solr.core;
import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
import java.util.Set;
-import org.apache.http.annotation.Experimental;
-
/**
* The base class for custom transient core maintenance. Any custom plugin that want's to take control of transient
* caches (i.e. any core defined with transient=true) should override this class.
@@ -105,12 +101,6 @@ public abstract class TransientSolrCoreCache {
// Remove the core descriptor from your list of transient descriptors.
public abstract CoreDescriptor removeTransientDescriptor(String name);
- // Find all the names a specific core is mapped to. Should not return null, return empty set instead.
- @Experimental
- public List<String> getNamesForCore(SolrCore core) {
- return Collections.emptyList();
- }
-
/**
* Must be called in order to free resources!
*/
diff --git a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java
index f579c775f8d..2ac94b10369 100644
--- a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java
+++ b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java
@@ -171,17 +171,6 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
return transientDescriptors.remove(name);
}
- @Override
- public List<String> getNamesForCore(SolrCore core) {
- List<String> ret = new ArrayList<>();
- for (Map.Entry<String, SolrCore> entry : transientCores.entrySet()) {
- if (core == entry.getValue()) {
- ret.add(entry.getKey());
- }
- }
- return ret;
- }
-
// For custom implementations to communicate arbitrary information as necessary.
@Override
public int getStatus(String coreName) { return 0; } //no_op for default handler.
diff --git a/solr/core/src/java/org/apache/solr/handler/export/ExportWriterStream.java b/solr/core/src/java/org/apache/solr/handler/export/ExportWriterStream.java
index 8cc31abd013..9ec0f4a41a0 100644
--- a/solr/core/src/java/org/apache/solr/handler/export/ExportWriterStream.java
+++ b/solr/core/src/java/org/apache/solr/handler/export/ExportWriterStream.java
@@ -66,7 +66,7 @@ public class ExportWriterStream extends TupleStream implements Expressible {
@Override
public EntryWriter put(CharSequence k, Object v) throws IOException {
if (v instanceof IteratorWriter) {
- List lst = new ArrayList();
+ List<Object> lst = new ArrayList<>();
((IteratorWriter)v).toList(lst);
v = lst;
} else if (v instanceof MapWriter) {