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

This commit is contained in:
Erick Erickson 2020-07-02 23:56:17 -04:00
parent 2005c43667
commit e9568c3473
7 changed files with 3 additions and 56 deletions

View File

@ -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 ==================

View File

@ -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();
}
/**

View File

@ -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(() -> {

View File

@ -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
*

View File

@ -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!
*/

View File

@ -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.

View File

@ -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) {