Apache Solr open-source search software
SOLR-17932: Remove deprecated Solr Transient Cores (#3699)
Eric Pughcb6dd31eca74
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 89c9ff2a3dc..3dccd4cd69e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -165,6 +165,8 @@ Deprecation Removalsfor that (which will be removed eventually), and many tests still use it. Also, there were server metricsrelating to HTTP client connection pools that no longer exist. (David Smiley)+* SOLR-17932: Remove transient Solr cores capability. (Eric Pugh, David Smiley)+Dependency Upgrades---------------------diff --git a/solr/api/src/java/org/apache/solr/client/api/model/CreateCoreParams.java b/solr/api/src/java/org/apache/solr/client/api/model/CreateCoreParams.javaindex 80337968fd4..2df4dc12dee 100644--- a/solr/api/src/java/org/apache/solr/client/api/model/CreateCoreParams.java+++ b/solr/api/src/java/org/apache/solr/client/api/model/CreateCoreParams.java@@ -17,7 +17,6 @@package org.apache.solr.client.api.model;import com.fasterxml.jackson.annotation.JsonProperty;-import io.swagger.v3.oas.annotations.media.Schema;import java.util.Map;public class CreateCoreParams {@@ -38,10 +37,6 @@ public class CreateCoreParams {@JsonProperty public Boolean loadOnStartup;- @Schema(name = "isTransient")- @JsonProperty("transient")- public Boolean isTransient;-@JsonProperty public String shard;@JsonProperty public String collection;diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.javaindex f79148804b4..50fe493d16f 100644--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java@@ -239,7 +239,6 @@ public class CoreContainer {protected volatile LogWatcher<?> logging = null;- private volatile CloserThread backgroundCloser = null;protected final NodeConfig cfg;protected final SolrResourceLoader loader;@@ -894,12 +893,6 @@ public class CoreContainer {"loaded",SolrInfoBean.Category.CONTAINER.toString(),"cores");- solrMetricsContext.gauge(- solrCores::getNumLoadedTransientCores,- true,- "lazy",- SolrInfoBean.Category.CONTAINER.toString(),- "cores");solrMetricsContext.gauge(solrCores::getNumUnloadedCores,true,@@ -1028,7 +1021,7 @@ public class CoreContainer {status |= CORE_DISCOVERY_COMPLETE;for (final CoreDescriptor cd : cds) {- if (cd.isTransient() || !cd.isLoadOnStartup()) {+ if (!cd.isLoadOnStartup()) {solrCores.addCoreDescriptor(cd);} else if (asyncSolrCoreLoad) {solrCores.markCoreAsLoading(cd);@@ -1069,10 +1062,6 @@ public class CoreContainer {}}- // Start the background thread- backgroundCloser = new CloserThread(this, solrCores, cfg);- backgroundCloser.start();-} finally {coreLoadExecutor.shutdown(); // doesn't blockif (!asyncSolrCoreLoad) {@@ -1259,31 +1248,6 @@ public class CoreContainer {ExecutorUtil.shutdownAndAwaitTermination(coreLoadExecutor); // actually already shutdown- // First wake up the closer thread, it'll terminate almost immediately since it checks- // isShutDown.- synchronized (solrCores.getModifyLock()) {- solrCores.getModifyLock().notifyAll(); // wake up anyone waiting- }- if (backgroundCloser- != null) { // Doesn't seem right, but tests get in here without initializing the core.- try {- while (true) {- backgroundCloser.join(15000);- if (backgroundCloser.isAlive()) {- synchronized (solrCores.getModifyLock()) {- solrCores.getModifyLock().notifyAll(); // there is a race we have to protect against- }- } else {- break;- }- }- } catch (InterruptedException e) {- Thread.currentThread().interrupt();- if (log.isDebugEnabled()) {- log.debug("backgroundCloser thread was interrupted before finishing");- }- }- }// Now clear all the cores that are being operated upon.solrCores.close();@@ -1877,13 +1841,8 @@ public class CoreContainer {}/**- * Gets the permanent and transient cores that are currently loaded, i.e. cores that have 1:- * loadOnStartup=true and are either not-transient or, if transient, have been loaded and have not- * been aged out 2: loadOnStartup=false and have been loaded but are either non-transient or have- * not been aged out.- *- * <p>Put another way, this will not return any names of cores that are lazily loaded but have not- * been called for yet or are transient and either not loaded or have been swapped out.+ * Gets the cores that are currently loaded, i.e. cores that have 1: loadOnStartup=true and have+ * been loaded and 2: loadOnStartup=false and have been subsequently loaded.** <p>For efficiency, prefer to check {@link #isLoaded(String)} instead of {@link* #getLoadedCoreNames()}.contains(coreName).@@ -1896,8 +1855,7 @@ public class CoreContainer {}/**- * Gets a collection of all the cores, permanent and transient, that are currently known, whether- * they are loaded or not.+ * Gets a collection of all the cores that are currently known, whether they are loaded or not.** <p>For efficiency, prefer to check {@link #getCoreDescriptor(String)} != null instead of {@link* #getAllCoreNames()}.contains(coreName).@@ -1910,8 +1868,8 @@ public class CoreContainer {}/**- * Gets the total number of cores, including permanent and transient cores, loaded and unloaded- * cores. Faster equivalent for {@link #getAllCoreNames()}.size().+ * Gets the total number of cores, including both loaded and unloaded cores. Faster equivalent to+ * {@link #getAllCoreNames()}.size().*/public int getNumAllCores() {return solrCores.getNumAllCores();@@ -2143,16 +2101,11 @@ public class CoreContainer {ErrorCode.BAD_REQUEST, "Cannot unload non-existent core [" + name + "]");}- boolean close = solrCores.isLoadedNotPendingClose(name);+ boolean close = solrCores.isLoaded(name);SolrCore core = solrCores.remove(name);solrCores.removeCoreDescriptor(cd);coresLocator.delete(this, cd);- if (core == null) {- // transient core- SolrCore.deleteUnloadedCore(cd, deleteDataDir, deleteInstanceDir);- return;- }// delete metrics specific to this coremetricManager.removeRegistry(core.getCoreMetricManager().getRegistryName());@@ -2264,16 +2217,13 @@ public class CoreContainer {// if there was an error initializing this core, throw a 500// error with the details for clients attempting to access it.CoreLoadFailure loadFailure = getCoreInitFailures().get(name);- if (null != loadFailure) {+ if (loadFailure != null) {throw new SolrCoreInitializationException(name, loadFailure.exception);}- // This is a bit of awkwardness where SolrCloud and transient cores don't play nice together.- // For transient cores, we have to allow them to be created at any time there hasn't been a core- // load failure (use reload to cure that). But for- // TestConfigSetsAPI.testUploadWithScriptUpdateProcessor, this needs to _not_ try to load the- // core if the core is null and there was an error. If you change this, be sure to run both- // TestConfigSetsAPI and TestLazyCores- if (desc == null || zkSys.getZkController() != null) return null;++ if (desc == null || zkSys.getZkController() != null) {+ return null;+ }// This will put an entry in pending core ops if the core isn't loaded. Here's where moving the// waitAddPendingCoreOps to createFromDescriptor would introduce a race condition.@@ -2574,45 +2524,3 @@ public class CoreContainer {});}}--class CloserThread extends Thread {- CoreContainer container;- SolrCores solrCores;- NodeConfig cfg;-- CloserThread(CoreContainer container, SolrCores solrCores, NodeConfig cfg) {- super("CloserThread");- this.container = container;- this.solrCores = solrCores;- this.cfg = cfg;- }-- // It's important that this be the _only_ thread removing things from pendingDynamicCloses!- // This is single-threaded, but I tried a multithreaded approach and didn't see any performance- // gains, so there's no good justification for the complexity. I suspect that the locking on- // things like DefaultSolrCoreState essentially create a single-threaded process anyway.- @Override- public void run() {- while (!container.isShutDown()) {- synchronized (solrCores.getModifyLock()) { // need this so we can wait and be awoken.- try {- solrCores.getModifyLock().wait();- } catch (InterruptedException e) {- // Well, if we've been told to stop, we will. Otherwise, continue on and check to see if- // there are any cores to close.- }- }-- SolrCore core;- while (!container.isShutDown() && (core = solrCores.getCoreToClose()) != null) {- assert core.getOpenCount() == 1;- try {- MDCLoggingContext.setCore(core);- core.close(); // will clear MDC- } finally {- solrCores.removeFromPendingOps(core.getName());- }- }- }- }-}diff --git a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.javaindex 5785b43017b..d38c5ff0b35 100644--- a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java+++ b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java@@ -56,7 +56,6 @@ public class CoreDescriptor {public static final String CORE_COLLECTION = "collection";public static final String CORE_PROPERTIES = "properties";public static final String CORE_LOADONSTARTUP = "loadOnStartup";- public static final String CORE_TRANSIENT = "transient";public static final String CORE_NODE_NAME = "coreNodeName";public static final String CORE_CONFIGSET = "configSet";public static final String CORE_CONFIGSET_PROPERTIES = "configSetProperties";@@ -89,7 +88,6 @@ public class CoreDescriptor {CORE_SCHEMA, "schema.xml",CORE_CONFIGSET_PROPERTIES, ConfigSetProperties.DEFAULT_FILENAME,CORE_DATADIR, "data" + FileSystems.getDefault().getSeparator(),- CORE_TRANSIENT, "false",CORE_LOADONSTARTUP, "true");private static final List<String> requiredProperties = List.of(CORE_NAME);@@ -104,7 +102,6 @@ public class CoreDescriptor {CORE_PROPERTIES,CORE_CONFIGSET_PROPERTIES,CORE_LOADONSTARTUP,- CORE_TRANSIENT,CORE_CONFIGSET,// cloud propsCORE_SHARD,@@ -338,11 +335,6 @@ public class CoreDescriptor {return Boolean.parseBoolean(stringValue);}- public boolean isTransient() {- String stringValue = coreProperties.getProperty(CORE_TRANSIENT, "false");- return PropertiesUtil.toBoolean(stringValue);- }-public String getUlogDir() {return coreProperties.getProperty(CORE_ULOGDIR);}diff --git a/solr/core/src/java/org/apache/solr/core/NodeConfig.java b/solr/core/src/java/org/apache/solr/core/NodeConfig.javaindex 415430e12b1..1aad555057b 100644--- a/solr/core/src/java/org/apache/solr/core/NodeConfig.java+++ b/solr/core/src/java/org/apache/solr/core/NodeConfig.java@@ -107,8 +107,6 @@ public class NodeConfig {private final int indexSearcherExecutorThreads;- @Deprecated private final int transientCacheSize;-private final boolean useSchemaCache;private final String managementPath;@@ -147,7 +145,6 @@ public class NodeConfig {Integer coreLoadThreads,int replayUpdatesThreads,int indexSearcherExecutorThreads,- int transientCacheSize,boolean useSchemaCache,String managementPath,Path solrHome,@@ -187,7 +184,6 @@ public class NodeConfig {this.coreLoadThreads = coreLoadThreads;this.replayUpdatesThreads = replayUpdatesThreads;this.indexSearcherExecutorThreads = indexSearcherExecutorThreads;- this.transientCacheSize = transientCacheSize;this.useSchemaCache = useSchemaCache;this.managementPath = managementPath;this.solrHome = solrHome;@@ -401,10 +397,6 @@ public class NodeConfig {return cloudConfig;}- public int getTransientCacheSize() {- return transientCacheSize;- }-protected final Path solrHome;protected final SolrResourceLoader loader;protected final Properties solrProperties;@@ -607,7 +599,6 @@ public class NodeConfig {private int coreLoadThreads = DEFAULT_CORE_LOAD_THREADS;private int replayUpdatesThreads = Runtime.getRuntime().availableProcessors();private int indexSearcherExecutorThreads = DEFAULT_INDEX_SEARCHER_EXECUTOR_THREADS;- @Deprecated private int transientCacheSize = -1;private boolean useSchemaCache = false;private String managementPath;private Properties solrProperties = new Properties();@@ -773,14 +764,6 @@ public class NodeConfig {return this;}- // Remove in Solr 10.0-- @Deprecated- public NodeConfigBuilder setTransientCacheSize(int transientCacheSize) {- this.transientCacheSize = transientCacheSize;- return this;- }-public NodeConfigBuilder setUseSchemaCache(boolean useSchemaCache) {this.useSchemaCache = useSchemaCache;return this;@@ -915,7 +898,6 @@ public class NodeConfig {coreLoadThreads,replayUpdatesThreads,indexSearcherExecutorThreads,- transientCacheSize,useSchemaCache,managementPath,solrHome,diff --git a/solr/core/src/java/org/apache/solr/core/SolrCores.java b/solr/core/src/java/org/apache/solr/core/SolrCores.javaindex 39b1f68b155..6d4874ee230 100644--- a/solr/core/src/java/org/apache/solr/core/SolrCores.java+++ b/solr/core/src/java/org/apache/solr/core/SolrCores.java@@ -37,7 +37,7 @@ import org.slf4j.Logger;import org.slf4j.LoggerFactory;/** AKA CoreManager: Holds/manages {@link SolrCore}s within {@link CoreContainer}. */-public class SolrCores {+class SolrCores {private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());@@ -59,17 +59,8 @@ public class SolrCores {// being operated upon.private final Set<String> pendingCoreOps = new HashSet<>();- // Due to the fact that closes happen potentially whenever anything is _added_ to the transient- // core list, we need to essentially queue them up to be handled via pendingCoreOps.- private final List<SolrCore> pendingCloses = new ArrayList<>();-- public static SolrCores newSolrCores(CoreContainer coreContainer) {- final int transientCacheSize = coreContainer.getConfig().getTransientCacheSize();- if (transientCacheSize > 0) {- return new TransientSolrCores(coreContainer, transientCacheSize);- } else {- return new SolrCores(coreContainer);- }+ static SolrCores newSolrCores(CoreContainer coreContainer) {+ return new SolrCores(coreContainer);}SolrCores(CoreContainer container) {@@ -91,7 +82,7 @@ public class SolrCores {// We are shutting down. You can't hold the lock on the various lists of cores while they shut// down, so we need to make a temporary copy of the names and shut them down outside the lock.protected void close() {- waitForLoadingCoresToFinish(30 * 1000);+ waitForLoadingCoresToFinish(30_000);// It might be possible for one of the cores to move from one list to another while we're// closing them. So loop through the lists until they're all empty. In particular, the core@@ -107,9 +98,6 @@ public class SolrCores {coreList.add(core);}}-- coreList.addAll(pendingCloses);- pendingCloses.clear();}if (coreList.isEmpty()) {@@ -208,12 +196,6 @@ public class SolrCores {}}- /** Gets the number of currently loaded transient cores. */- public int getNumLoadedTransientCores() {- // TODO; this metric ought to simply not exist here- return 0;- }-/** Gets the number of unloaded cores, including permanent and transient cores. */public int getNumUnloadedCores() {synchronized (modifyLock) {@@ -298,54 +280,18 @@ public class SolrCores {}}- // See SOLR-5366 for why the UNLOAD command needs to know whether a core is actually loaded or- // not, it might have to close the core. However, there's a race condition. If the core happens to- // be in the pending "to close" queue, we should NOT close it in unload core.- public boolean isLoadedNotPendingClose(String name) {- synchronized (modifyLock) {- if (!isLoaded(name)) {- return false;- }- // Check pending- for (SolrCore core : pendingCloses) {- if (core.getName().equals(name)) {- return false;- }- }-- return true;- }- }-public boolean isLoaded(String name) {synchronized (modifyLock) {return cores.containsKey(name);}}- /** The core is currently loading, unloading, or reloading. */- protected boolean hasPendingCoreOps(String name) {- synchronized (modifyLock) {- return pendingCoreOps.contains(name);- }- }-// Wait here until any pending operations (load, unload or reload) are completed on this core.public SolrCore waitAddPendingCoreOps(String name) {// Keep multiple threads from operating on a core at one time.synchronized (modifyLock) {- boolean pending;- do { // Are we currently doing anything to this core? Loading, unloading, reloading?- pending = pendingCoreOps.contains(name); // wait for the core to be done being operated upon- if (!pending) { // Linear list, but shouldn't be too long- for (SolrCore core : pendingCloses) {- if (core.getName().equals(name)) {- pending = true;- break;- }- }- }+ while (true) { // Are we currently doing anything to this core? Loading, unloading, reloading?if (container.isShutDown()) {// Just stop already.// Seems best to throw a SolrException if shutting down, because returning any value,@@ -353,17 +299,21 @@ public class SolrCores {throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Server is shutting down");}- if (pending) {- try {- modifyLock.wait();- } catch (InterruptedException e) {- // Seems best to throw a SolrException if interrupted, because returning any value,- // including null, would mean the waiting is complete.- Thread.currentThread().interrupt();- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);- }+ if (!pendingCoreOps.contains(name)) {+ break;+ }++ // wait for the core to be done being operated upon+ try {+ modifyLock.wait();+ } catch (InterruptedException e) {+ // Seems best to throw a SolrException if interrupted, because returning any value,+ // including null, would mean the waiting is complete.+ Thread.currentThread().interrupt();+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);}- } while (pending);+ }+// We _really_ need to do this within the synchronized block!if (!pendingCoreOps.add(name)) {log.warn("Replaced an entry in pendingCoreOps {}, we should not be doing this", name);@@ -388,23 +338,6 @@ public class SolrCores {return modifyLock;}- // Be a little careful. We don't want to either open or close a core unless it's _not_ being- // opened or closed by another thread. So within this lock we'll walk along the list of pending- // closes until we find something NOT in the list of threads currently being loaded or reloaded.- // The "usual" case will probably return the very first one anyway.- public SolrCore getCoreToClose() {- synchronized (modifyLock) {- for (SolrCore core : pendingCloses) {- if (!pendingCoreOps.contains(core.getName())) {- pendingCoreOps.add(core.getName());- pendingCloses.remove(core);- return core;- }- }- }- return null;- }-/*** Return the CoreDescriptor corresponding to a given core name. Blocks if the SolrCore is still* loading until it is ready.@@ -485,11 +418,4 @@ public class SolrCores {public boolean isCoreLoading(String name) {return currentlyLoadingCores.contains(name);}-- public void queueCoreToClose(SolrCore coreToClose) {- synchronized (modifyLock) {- pendingCloses.add(coreToClose); // Essentially just queue this core up for closing.- modifyLock.notifyAll(); // Wakes up closer thread too- }- }}diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.javaindex 1206dea0d3a..11016e3bf7c 100644--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java@@ -384,10 +384,6 @@ public class SolrXmlConfig {case "indexSearcherExecutorThreads":builder.setIndexSearcherExecutorThreads(it.intVal(-1));break;- case "transientCacheSize":- log.warn("solr.xml transientCacheSize -- transient cores is deprecated");- builder.setTransientCacheSize(it.intVal(-1));- break;case "allowUrls":builder.setAllowUrls(separateStrings(it.txt()));break;diff --git a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCache.java b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCache.javadeleted file mode 100644index 51a625f2b7f..00000000000--- a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCache.java+++ /dev/null@@ -1,119 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.solr.core;--import java.util.Collection;-import java.util.Set;--/**- * The base class for custom transient core maintenance. Any custom plugin that wants to take- * control of transient caches (i.e. any core defined with transient=true) should override this- * class.- *- * <p>WARNING: There is quite a bit of higher-level locking done by the CoreContainer to avoid- * various race conditions etc. You should _only_ manipulate them within the method calls designed- * to change them. E.g. only add to the transient core descriptors in addTransientDescriptor etc.- *- * <p>Trust the higher-level code (mainly SolrCores and CoreContainer) to call the appropriate- * operations when necessary and to coordinate shutting down cores, manipulating the internal- * structures and the like.- *- * <p>The only real action you should _initiate_ is to close a core for whatever reason, and do that- * by calling notifyCoreCloseListener(coreToClose); The observer will call back to removeCore(name)- * at the appropriate time. There is no need to directly remove the core _at that time_ from the- * transientCores list, a call will come back to this class when CoreContainer is closing this core.- *- * <p>CoreDescriptors are read-once. During "core discovery" all valid descriptors are enumerated- * and added to the appropriate list. Thereafter, they are NOT re-read from disk. In those- * situations where you want to re-define the coreDescriptor, maintain a "side list" of changed core- * descriptors. Then override getTransientDescriptor to return your new core descriptor. NOTE:- * assuming you've already closed the core, the _next_ time that core is required- * getTransientDescriptor will be called and if you return the new core descriptor your- * re-definition should be honored. You'll have to maintain this list for the duration of this Solr- * instance running. If you persist the coreDescriptor, then next time Solr starts up the new- * definition will be read.- *- * <p>If you need to manipulate the return, for instance block a core from being loaded for some- * period of time, override say getTransientDescriptor and return null.- *- * <p>In particular, DO NOT reach into the transientCores structure from a method called to- * manipulate core descriptors or vice-versa.- */-@Deprecated(since = "9.2")-public abstract class TransientSolrCoreCache {-- /** Adds the newly-opened core to the list of open cores. */- public abstract SolrCore addCore(String name, SolrCore core);-- /** Returns the names of all possible cores, whether they are currently loaded or not. */- public abstract Set<String> getAllCoreNames();-- /** Returns the names of all currently loaded cores. */- public abstract Set<String> getLoadedCoreNames();-- /**- * Removes a core from the internal structures, presumably it being closed. If the core is- * re-opened, it will be re-added by CoreContainer.- */- public abstract SolrCore removeCore(String name);-- /** Gets the core associated with the name. Returns null if there is none. */- public abstract SolrCore getCore(String name);-- /** Returns whether the cache contains the named core. */- public abstract boolean containsCore(String name);-- // These methods allow the implementation to maintain control over the core descriptors.-- /**- * Adds a new {@link CoreDescriptor}. This method will only be called during core discovery at- * startup.- */- public abstract void addTransientDescriptor(String rawName, CoreDescriptor cd);-- /**- * Gets the {@link CoreDescriptor} for a transient core (loaded or unloaded). This method is used- * when opening cores and the like. If you want to change a core's descriptor, override this- * method and return the current core descriptor.- */- public abstract CoreDescriptor getTransientDescriptor(String name);-- /** Gets the {@link CoreDescriptor} for all transient cores (loaded and unloaded). */- public abstract Collection<CoreDescriptor> getTransientDescriptors();-- /** Removes a {@link CoreDescriptor} from the list of transient cores descriptors. */- public abstract CoreDescriptor removeTransientDescriptor(String name);-- /** Called in order to free resources. */- public void close() {- // Nothing to do currently- }- ;-- /**- * Gets a custom status for the given core name. Allows custom implementations to communicate- * arbitrary information as necessary.- */- public abstract int getStatus(String coreName);-- /**- * Sets a custom status for the given core name. Allows custom implementations to communicate- * arbitrary information as necessary.- */- public abstract void setStatus(String coreName, int status);-}diff --git a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.javadeleted file mode 100644index c3c1ac0b620..00000000000--- a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java+++ /dev/null@@ -1,184 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.solr.core;--import com.github.benmanes.caffeine.cache.Cache;-import com.github.benmanes.caffeine.cache.Caffeine;-import java.lang.invoke.MethodHandles;-import java.util.Collection;-import java.util.Collections;-import java.util.Map;-import java.util.Set;-import org.apache.solr.common.util.CollectionUtil;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--/**- * Cache of the most frequently accessed transient cores. Keeps track of all the registered- * transient cores descriptors, including the cores in the cache as well as all the others.- */-@Deprecated(since = "9.2")-public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {- // TODO move into TransientSolrCores; remove TransientSolrCoreCache base/abstraction.-- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());- public static final int DEFAULT_TRANSIENT_CACHE_SIZE = Integer.MAX_VALUE;- public static final String TRANSIENT_CACHE_SIZE = "transientCacheSize";-- private final TransientSolrCores solrCores;-- /**- * "Lazily loaded" cores cache with limited size. When the max size is reached, the least accessed- * core is evicted to make room for a new core.- */- protected final Cache<String, SolrCore> transientCores;-- /**- * Unlimited map of all the descriptors for all the registered transient cores, including the- * cores in the {@link #transientCores} as well as all the others.- */- protected final Map<String, CoreDescriptor> transientDescriptors;-- public TransientSolrCoreCacheDefault(TransientSolrCores solrCores, int cacheMaxSize) {- this.solrCores = solrCores;-- // Now don't allow ridiculous allocations here, if the size is > 1,000, we'll just deal with- // adding cores as they're opened. This blows up with the marker value of -1.- int initialCapacity = Math.min(cacheMaxSize, 1024);- log.info(- "Allocating transient core cache for max {} cores with initial capacity of {}",- cacheMaxSize,- initialCapacity);- Caffeine<String, SolrCore> transientCoresCacheBuilder =- Caffeine.newBuilder()- .initialCapacity(initialCapacity)- // Use the current thread to queue evicted cores for closing. This ensures the- // cache max size is respected (with a different thread the max size would be- // respected asynchronously only eventually).- .executor(Runnable::run)- .removalListener(- (coreName, core, cause) -> {- if (core != null && cause.wasEvicted()) {- onEvict(core);- }- });- if (cacheMaxSize != Integer.MAX_VALUE) {- transientCoresCacheBuilder.maximumSize(cacheMaxSize);- }- transientCores = transientCoresCacheBuilder.build();-- transientDescriptors = CollectionUtil.newLinkedHashMap(initialCapacity);- }-- private void onEvict(SolrCore core) {- assert Thread.holdsLock(solrCores.getModifyLock());- // note: the cache's maximum size isn't strictly enforced; it can grow some if we un-evict- if (solrCores.hasPendingCoreOps(core.getName())) {- // core is loading, unloading, or reloading- if (log.isInfoEnabled()) {- log.info(- "NOT evicting transient core [{}]; it's loading or something else. Size: {}",- core.getName(),- transientCores.estimatedSize());- }- transientCores.put(core.getName(), core); // put back- } else if (core.getOpenCount() > 1) {- // maybe a *long* running operation is happening or intense load- if (log.isInfoEnabled()) {- log.info(- "NOT evicting transient core [{}]; it's still in use. Size: {}",- core.getName(),- transientCores.estimatedSize());- }- transientCores.put(core.getName(), core); // put back- } else {- // common case -- can evict it- if (log.isInfoEnabled()) {- log.info("Closing transient core [{}] evicted from the cache", core.getName());- }- solrCores.queueCoreToClose(core);- }- }-- @Override- public void close() {- transientCores.invalidateAll();- transientCores.cleanUp();- }-- @Override- public SolrCore addCore(String name, SolrCore core) {- return transientCores.asMap().put(name, core);- }-- @Override- public Set<String> getAllCoreNames() {- return Collections.unmodifiableSet(transientDescriptors.keySet());- }-- @Override- public Set<String> getLoadedCoreNames() {- return Collections.unmodifiableSet(transientCores.asMap().keySet());- }-- @Override- public SolrCore removeCore(String name) {- return transientCores.asMap().remove(name);- }-- @Override- public SolrCore getCore(String name) {- return name == null ? null : transientCores.getIfPresent(name);- }-- @Override- public boolean containsCore(String name) {- return name != null && transientCores.asMap().containsKey(name);- }-- @Override- public void addTransientDescriptor(String rawName, CoreDescriptor cd) {- transientDescriptors.put(rawName, cd);- }-- @Override- public CoreDescriptor getTransientDescriptor(String name) {- return transientDescriptors.get(name);- }-- @Override- public Collection<CoreDescriptor> getTransientDescriptors() {- return Collections.unmodifiableCollection(transientDescriptors.values());- }-- @Override- public CoreDescriptor removeTransientDescriptor(String name) {- return transientDescriptors.remove(name);- }-- @Override- public int getStatus(String coreName) {- // no_op for default handler.- return 0;- }-- @Override- public void setStatus(String coreName, int status) {- // no_op for default handler.- }-}diff --git a/solr/core/src/java/org/apache/solr/core/TransientSolrCores.java b/solr/core/src/java/org/apache/solr/core/TransientSolrCores.javadeleted file mode 100644index 2b50b2d81e3..00000000000--- a/solr/core/src/java/org/apache/solr/core/TransientSolrCores.java+++ /dev/null@@ -1,173 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.solr.core;--import java.util.ArrayList;-import java.util.Collection;-import java.util.HashSet;-import java.util.List;--/** A {@link SolrCores} that supports {@link CoreDescriptor#isTransient()}. */-@Deprecated(since = "9.2")-public class TransientSolrCores extends SolrCores {-- protected final TransientSolrCoreCache transientSolrCoreCache;-- public TransientSolrCores(CoreContainer container, int cacheSize) {- super(container);- transientSolrCoreCache = new TransientSolrCoreCacheDefault(this, cacheSize);- }-- @Override- protected void close() {- super.close();- transientSolrCoreCache.close();- }-- @Override- public void addCoreDescriptor(CoreDescriptor p) {- if (p.isTransient()) {- synchronized (modifyLock) {- transientSolrCoreCache.addTransientDescriptor(p.getName(), p);- }- } else {- super.addCoreDescriptor(p);- }- }-- @Override- public void removeCoreDescriptor(CoreDescriptor p) {- if (p.isTransient()) {- synchronized (modifyLock) {- transientSolrCoreCache.removeTransientDescriptor(p.getName());- }- } else {- super.removeCoreDescriptor(p);- }- }-- @Override- // Returns the old core if there was a core of the same name.- // WARNING! This should be the _only_ place you put anything into the list of transient cores!- public SolrCore putCore(CoreDescriptor cd, SolrCore core) {- if (cd.isTransient()) {- synchronized (modifyLock) {- addCoreDescriptor(cd); // cd must always be registered if we register a core- return transientSolrCoreCache.addCore(cd.getName(), core);- }- } else {- return super.putCore(cd, core);- }- }-- @Override- public List<String> getLoadedCoreNames() {- synchronized (modifyLock) {- List<String> coreNames = super.getLoadedCoreNames(); // mutable- coreNames.addAll(transientSolrCoreCache.getLoadedCoreNames());- assert isSet(coreNames);- return coreNames;- }- }-- @Override- public List<String> getAllCoreNames() {- synchronized (modifyLock) {- List<String> coreNames = super.getAllCoreNames(); // mutable- coreNames.addAll(transientSolrCoreCache.getAllCoreNames());- assert isSet(coreNames);- return coreNames;- }- }-- private static boolean isSet(Collection<?> collection) {- return collection.size() == new HashSet<>(collection).size();- }-- @Override- public int getNumLoadedTransientCores() {- synchronized (modifyLock) {- return transientSolrCoreCache.getLoadedCoreNames().size();- }- }-- @Override- public int getNumUnloadedCores() {- synchronized (modifyLock) {- return super.getNumUnloadedCores()- + transientSolrCoreCache.getAllCoreNames().size()- - transientSolrCoreCache.getLoadedCoreNames().size();- }- }-- @Override- public int getNumAllCores() {- synchronized (modifyLock) {- return super.getNumAllCores() + transientSolrCoreCache.getAllCoreNames().size();- }- }-- @Override- public SolrCore remove(String name) {- synchronized (modifyLock) {- SolrCore ret = super.remove(name);- // It could have been a newly-created core. It could have been a transient core. The- // newly-created cores in particular should be checked. It could have been a dynamic core.- if (ret == null) {- ret = transientSolrCoreCache.removeCore(name);- }- return ret;- }- }-- @Override- protected SolrCore getLoadedCoreWithoutIncrement(String name) {- synchronized (modifyLock) {- final var core = super.getLoadedCoreWithoutIncrement(name);- return core != null ? core : transientSolrCoreCache.getCore(name);- }- }-- @Override- public boolean isLoaded(String name) {- synchronized (modifyLock) {- return super.isLoaded(name) || transientSolrCoreCache.containsCore(name);- }- }-- @Override- public CoreDescriptor getCoreDescriptor(String coreName) {- synchronized (modifyLock) {- CoreDescriptor coreDescriptor = super.getCoreDescriptor(coreName);- if (coreDescriptor != null) {- return coreDescriptor;- }- return transientSolrCoreCache.getTransientDescriptor(coreName);- }- }-- @Override- public List<CoreDescriptor> getCoreDescriptors() {- synchronized (modifyLock) {- List<CoreDescriptor> coreDescriptors = new ArrayList<>(getNumAllCores());- coreDescriptors.addAll(super.getCoreDescriptors());- coreDescriptors.addAll(transientSolrCoreCache.getTransientDescriptors());- return coreDescriptors;- }- }-}diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.javaindex 86c68759774..a4ee0251fda 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java@@ -267,7 +267,6 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNaMap.entry(CoreAdminParams.ULOG_DIR, CoreDescriptor.CORE_ULOGDIR),Map.entry(CoreAdminParams.CONFIGSET, CoreDescriptor.CORE_CONFIGSET),Map.entry(CoreAdminParams.LOAD_ON_STARTUP, CoreDescriptor.CORE_LOADONSTARTUP),- Map.entry(CoreAdminParams.TRANSIENT, CoreDescriptor.CORE_TRANSIENT),Map.entry(CoreAdminParams.SHARD, CoreDescriptor.CORE_SHARD),Map.entry(CoreAdminParams.COLLECTION, CoreDescriptor.CORE_COLLECTION),Map.entry(CoreAdminParams.CORE_NODE_NAME, CoreDescriptor.CORE_NODE_NAME),diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-implicitproperties.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-implicitproperties.xmlindex 072cae1d869..75be3374cab 100644--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-implicitproperties.xml+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-implicitproperties.xml@@ -60,7 +60,6 @@<str name="dummy2">${solr.core.dataDir}</str><str name="dummy3">${solr.core.config}</str><str name="dummy4">${solr.core.schema}</str>- <str name="dummy5">${solr.core.transient}</str></lst></requestHandler>diff --git a/solr/core/src/test-files/solr/solr-50-all.xml b/solr/core/src/test-files/solr/solr-50-all.xmlindex 53a682050ca..50781f5a718 100644--- a/solr/core/src/test-files/solr/solr-50-all.xml+++ b/solr/core/src/test-files/solr/solr-50-all.xml@@ -28,7 +28,6 @@<str name="shareSchema">${shareSchema:true}</str><str name="coresLocator">testCoresLocator</str><str name="coreSorter">testCoreSorter</str>- <int name="transientCacheSize">66</int><int name="replayUpdatesThreads">100</int><int name="indexSearcherExecutorThreads">7</int><int name="maxBooleanClauses">42</int>diff --git a/solr/core/src/test-files/solr/solr-transientCores.xml b/solr/core/src/test-files/solr/solr-transientCores.xmldeleted file mode 100644index 4ab0f389938..00000000000--- a/solr/core/src/test-files/solr/solr-transientCores.xml+++ /dev/null@@ -1,20 +0,0 @@-<!--- ~ Licensed to the Apache Software Foundation (ASF) under one or more- ~ contributor license agreements. See the NOTICE file distributed with- ~ this work for additional information regarding copyright ownership.- ~ The ASF licenses this file to You under the Apache License, Version 2.0- ~ (the "License"); you may not use this file except in compliance with- ~ the License. You may obtain a copy of the License at- ~- ~ http://www.apache.org/licenses/LICENSE-2.0- ~- ~ Unless required by applicable law or agreed to in writing, software- ~ distributed under the License is distributed on an "AS IS" BASIS,- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- ~ See the License for the specific language governing permissions and- ~ limitations under the License.- -->--<solr>- <int name="transientCacheSize">4</int>-</solr>\ No newline at end of filediff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.javaindex 09639b28839..0bf2d7b89ee 100644--- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java+++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java@@ -35,11 +35,9 @@ import java.util.List;import java.util.Map;import java.util.Properties;import java.util.Set;-import java.util.concurrent.TimeUnit;import org.apache.lucene.util.IOUtils;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.SolrException;-import org.apache.solr.common.util.RetryUtil;import org.junit.After;import org.junit.AssumptionViolatedException;import org.junit.BeforeClass;@@ -72,13 +70,11 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {setMeUp(null);}- private Properties makeCoreProperties(- String name, boolean isTransient, boolean loadOnStartup, String... extraProps) {+ private Properties makeCoreProperties(String name, boolean loadOnStartup, String... extraProps) {Properties props = new Properties();props.put(CoreDescriptor.CORE_NAME, name);props.put(CoreDescriptor.CORE_SCHEMA, "schema-tiny.xml");props.put(CoreDescriptor.CORE_CONFIG, "solrconfig-minimal.xml");- props.put(CoreDescriptor.CORE_TRANSIENT, Boolean.toString(isTransient));props.put(CoreDescriptor.CORE_LOADONSTARTUP, Boolean.toString(loadOnStartup));props.put(CoreDescriptor.CORE_DATADIR, "${core.dataDir:stuffandnonsense}");@@ -155,24 +151,19 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {public void testDiscovery() throws Exception {setMeUp();- // name, isLazy, loadOnStartup- addCoreWithProps("core1", makeCoreProperties("core1", false, true, "dataDir=core1"));- addCoreWithProps("core2", makeCoreProperties("core2", false, false, "dataDir=core2"));-- // I suspect what we're adding in here is a "configset" rather than a schema or solrconfig.- //- addCoreWithProps("lazy1", makeCoreProperties("lazy1", true, false, "dataDir=lazy1"));+ // name, loadOnStartup+ addCoreWithProps("core1", makeCoreProperties("core1", true, "dataDir=core1"));+ addCoreWithProps("core2", makeCoreProperties("core2", false, "dataDir=core2"));CoreContainer cc = init();try {TestLazyCores.checkLoadedCores(cc, "core1");- TestLazyCores.checkCoresNotLoaded(cc, "lazy1", "core2");+ TestLazyCores.checkCoresNotLoaded(cc, "core2");- // force loading of core2 and lazy1 by getting them from the CoreContainer+ // force loading of core2 by getting it from the CoreContainertry (SolrCore core1 = cc.getCore("core1");- SolrCore core2 = cc.getCore("core2");- SolrCore lazy1 = cc.getCore("lazy1")) {+ SolrCore core2 = cc.getCore("core2"); ) {// Let's assert we did the right thing for implicit properties too.CoreDescriptor desc = core1.getCoreDescriptor();@@ -185,7 +176,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {assertEquals("solrconfig-minimal.xml", desc.getConfigName());assertEquals("schema-tiny.xml", desc.getSchemaName());- TestLazyCores.checkLoadedCores(cc, "core1", "core2", "lazy1");+ TestLazyCores.checkLoadedCores(cc, "core1", "core2");// Can we persist an existing core's properties?// Insure we can persist a new properties file if we want.@@ -232,12 +223,12 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {setMeUp();// Test that an existing core.properties file is _not_ deleted if the core fails to load.- Properties badProps = makeCoreProperties("corep1", false, true);+ Properties badProps = makeCoreProperties("corep1", true);badProps.setProperty(CoreDescriptor.CORE_SCHEMA, "not-there.xml");addCoreWithProps("corep1", badProps);// Sanity check that a core did get loaded- addCoreWithProps("corep2", makeCoreProperties("corep2", false, true));+ addCoreWithProps("corep2", makeCoreProperties("corep2", true));Path coreP1PropFile = solrHomeDirectory.resolve("corep1").resolve("core.properties");assertTrue(@@ -275,7 +266,6 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {CoreDescriptor.CORE_NAME, "corep4",CoreDescriptor.CORE_SCHEMA, "not-there.xml",CoreDescriptor.CORE_CONFIG, "solrconfig-minimal.xml",- CoreDescriptor.CORE_TRANSIENT, "false",CoreDescriptor.CORE_LOADONSTARTUP, "true"));});assertTrue(thrown.getMessage().contains("Can't find resource"));@@ -298,88 +288,13 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {}}- // Ensure that if the number of transient cores that are loaded on startup is greater than the- // cache size that Solr "does the right thing". Which means- // 1> stop loading cores after transient cache size is reached, in this case that magic number is- // 3 one non-transient and two transient.- // 2> still loads cores as time passes.- //- // This seems like a silly test, but it hangs forever on 4.10 so let's guard against it in the- // future.- // The behavior has gone away with the removal of the complexity around the old-style solr.xml- // files.- //- // NOTE: The order that cores are loaded depends upon how the core discovery is traversed. I don't- // think we can make the test depend on that order, so after load just ensure that the cores- // counts are correct.-- @Test- public void testTooManyTransientCores() throws Exception {-- setMeUp();-- // name, isLazy, loadOnStartup- addCoreWithProps("coreLOS", makeCoreProperties("coreLOS", false, true, "dataDir=coreLOS"));- addCoreWithProps("coreT1", makeCoreProperties("coreT1", true, true, "dataDir=coreT1"));- addCoreWithProps("coreT2", makeCoreProperties("coreT2", true, true, "dataDir=coreT2"));- addCoreWithProps("coreT3", makeCoreProperties("coreT3", true, true, "dataDir=coreT3"));- addCoreWithProps("coreT4", makeCoreProperties("coreT4", true, true, "dataDir=coreT4"));- addCoreWithProps("coreT5", makeCoreProperties("coreT5", true, true, "dataDir=coreT5"));- addCoreWithProps("coreT6", makeCoreProperties("coreT6", true, true, "dataDir=coreT6"));-- // Do this specially since we need to search.- final CoreContainer cc = new CoreContainer(solrHomeDirectory, new Properties());- try {- cc.load();- // Just check that the proper number of cores are loaded since making the test depend on order- // would be fragile- RetryUtil.retryUntil(- "There should only be 3 cores loaded, coreLOS and two coreT# cores",- 20,- 200,- TimeUnit.MILLISECONDS,- () -> {- // See SOLR-16104 about this flakiness- final var loadedCoreNames = cc.getLoadedCoreNames();- if (3 == loadedCoreNames.size() || 4 == loadedCoreNames.size()) {- // 4 sometimes... Caffeine or background threads makes it hard to be deterministic?- return true;- }- log.warn("Waiting for 3|4 loaded cores but got: {}", loadedCoreNames);- return false;- });-- SolrCore c1 = cc.getCore("coreT1");- assertNotNull("Core T1 should NOT BE NULL", c1);- SolrCore c2 = cc.getCore("coreT2");- assertNotNull("Core T2 should NOT BE NULL", c2);- SolrCore c3 = cc.getCore("coreT3");- assertNotNull("Core T3 should NOT BE NULL", c3);- SolrCore c4 = cc.getCore("coreT4");- assertNotNull("Core T4 should NOT BE NULL", c4);- SolrCore c5 = cc.getCore("coreT5");- assertNotNull("Core T5 should NOT BE NULL", c5);- SolrCore c6 = cc.getCore("coreT6");- assertNotNull("Core T6 should NOT BE NULL", c6);-- c1.close();- c2.close();- c3.close();- c4.close();- c5.close();- c6.close();- } finally {- cc.shutdown();- }- }-@Testpublic void testDuplicateNames() throws Exception {setMeUp();// name, isLazy, loadOnStartup- addCoreWithProps("core1", makeCoreProperties("core1", false, true));- addCoreWithProps("core2", makeCoreProperties("core2", false, false, "name=core1"));+ addCoreWithProps("core1", makeCoreProperties("core1", true));+ addCoreWithProps("core2", makeCoreProperties("core2", false, "name=core1"));SolrException thrown =expectThrows(SolrException.class,@@ -414,10 +329,10 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {setMeUp(alt.toAbsolutePath().toString());addCoreWithProps(- makeCoreProperties("core1", false, true, "dataDir=core1"),+ makeCoreProperties("core1", true, "dataDir=core1"),alt.resolve("core1").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));addCoreWithProps(- makeCoreProperties("core2", false, false, "dataDir=core2"),+ makeCoreProperties("core2", false, "dataDir=core2"),alt.resolve("core2").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));CoreContainer cc = init();try (SolrCore core1 = cc.getCore("core1");@@ -437,20 +352,20 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {setMeUp(relative);// two cores under the relative directoryaddCoreWithProps(- makeCoreProperties("core1", false, true, "dataDir=core1"),+ makeCoreProperties("core1", true, "dataDir=core1"),solrHomeDirectory.resolve(relative).resolve("core1").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));addCoreWithProps(- makeCoreProperties("core2", false, false, "dataDir=core2"),+ makeCoreProperties("core2", false, "dataDir=core2"),solrHomeDirectory.resolve(relative).resolve("core2").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));// one core *not* under the relative directoryaddCoreWithProps(- makeCoreProperties("core0", false, true, "datadir=core0"),+ makeCoreProperties("core0", true, "datadir=core0"),solrHomeDirectory.resolve("core0").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));CoreContainer cc = init();@@ -474,10 +389,10 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {Path noCoreDir = createTempDir();setMeUp(noCoreDir.toAbsolutePath().toString());addCoreWithProps(- makeCoreProperties("core1", false, true),+ makeCoreProperties("core1", true),noCoreDir.resolve("core1").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));addCoreWithProps(- makeCoreProperties("core2", false, false),+ makeCoreProperties("core2", false),noCoreDir.resolve("core2").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));CoreContainer cc = init();try (SolrCore core1 = cc.getCore("core1");@@ -494,12 +409,12 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {Path coreDir = solrHomeDirectory;setMeUp(coreDir.toAbsolutePath().toString());addCoreWithProps(- makeCoreProperties("core1", false, true),+ makeCoreProperties("core1", true),coreDir.resolve("core1").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));// Ensure that another core is opened successfullyaddCoreWithProps(- makeCoreProperties("core2", false, false, "dataDir=core2"),+ makeCoreProperties("core2", false, "dataDir=core2"),coreDir.resolve("core2").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));Path toSet = coreDir.resolve("core1");@@ -535,11 +450,11 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {Path coreDir = solrHomeDirectory;setMeUp(coreDir.toAbsolutePath().toString());addCoreWithProps(- makeCoreProperties("core1", false, true),+ makeCoreProperties("core1", true),coreDir.resolve("core1").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));addCoreWithProps(- makeCoreProperties("core2", false, false, "dataDir=core2"),+ makeCoreProperties("core2", false, "dataDir=core2"),coreDir.resolve("core2").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));Path toSet = solrHomeDirectory.resolve("cantReadDir");@@ -582,7 +497,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {Path coreDir = solrHomeDirectory;setMeUp(coreDir.toAbsolutePath().toString());addCoreWithProps(- makeCoreProperties("core1", false, true),+ makeCoreProperties("core1", true),coreDir.resolve("core1").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));Path toSet = solrHomeDirectory.resolve("cantReadFile");@@ -621,8 +536,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {@Testpublic void testSolrHomeDoesntExist() throws Exception {- Path homeDir = solrHomeDirectory;- IOUtils.rm(homeDir);+ IOUtils.rm(solrHomeDirectory);CoreContainer cc = null;try {cc = init();@@ -642,7 +556,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {Path homeDir = solrHomeDirectory;setMeUp(homeDir.toAbsolutePath().toString());addCoreWithProps(- makeCoreProperties("core1", false, true),+ makeCoreProperties("core1", true),homeDir.resolve("core1").resolve(CorePropertiesLocator.PROPERTIES_FILENAME));try {@@ -680,7 +594,6 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {// For testing whether finding a solr.xml overrides looking at solr.propertiesprivate static final String SOLR_XML ="<solr> "- + "<int name=\"transientCacheSize\">2</int> "+ "<str name=\"configSetBaseDir\">"+ TEST_HOME().resolve("configsets")+ "</str>"diff --git a/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java b/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.javaindex e7fb137cf79..841ab763471 100644--- a/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java+++ b/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java@@ -48,8 +48,7 @@ public class TestImplicitCoreProperties extends SolrTestCaseJ4 {"//str[@name='dummy1'][.='collection1']","//str[@name='dummy2'][.='data']","//str[@name='dummy3'][.='solrconfig-implicitproperties.xml']",- "//str[@name='dummy4'][.='schema.xml']",- "//str[@name='dummy5'][.='false']");+ "//str[@name='dummy4'][.='schema.xml']");}// SOLR-5279@@ -61,8 +60,7 @@ public class TestImplicitCoreProperties extends SolrTestCaseJ4 {"//str[@name='dummy1'][.='collection1']","//str[@name='dummy2'][.='data']","//str[@name='dummy3'][.='solrconfig-implicitproperties.xml']",- "//str[@name='dummy4'][.='schema.xml']",- "//str[@name='dummy5'][.='false']");+ "//str[@name='dummy4'][.='schema.xml']");}// SOLR-8712diff --git a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java b/solr/core/src/test/org/apache/solr/core/TestLazyCores.javaindex 3cc8ed7c77f..87e8c336920 100644--- a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java+++ b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java@@ -24,55 +24,32 @@ import java.nio.file.StandardCopyOption;import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;-import java.util.Collections;import java.util.List;import java.util.Map;-import java.util.concurrent.CountDownLatch;import java.util.regex.Pattern;import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.client.solrj.SolrServerException;-import org.apache.solr.client.solrj.StreamingResponseCallback;-import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;-import org.apache.solr.common.SolrDocument;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;import org.apache.solr.update.AddUpdateCommand;import org.apache.solr.update.CommitUpdateCommand;import org.apache.solr.update.UpdateHandler;-import org.apache.solr.util.LogListener;import org.apache.solr.util.ReadOnlyCoresLocator;-import org.junit.BeforeClass;import org.junit.Test;public class TestLazyCores extends SolrTestCaseJ4 {- /** Transient core cache max size defined in the test solr-transientCores.xml */- private static final int TRANSIENT_CORE_CACHE_MAX_SIZE = 4;-private Path solrHomeDirectory;- @BeforeClass- public static void setupClass() throws Exception {- // Need to use a disk-based directory because there are tests that close a core after adding- // documents then expect to be able to re-open that core and execute a search- useFactory("solr.StandardDirectoryFactory");- }-private static CoreDescriptor makeCoreDescriptor(- CoreContainer cc, String coreName, String isTransient, String loadOnStartup) {+ CoreContainer cc, String coreName, String loadOnStartup) {return new CoreDescriptor(coreName,cc.getCoreRootDirectory().resolve(coreName),cc,- CoreDescriptor.CORE_TRANSIENT,- isTransient,CoreDescriptor.CORE_LOADONSTARTUP,loadOnStartup);}@@ -82,22 +59,16 @@ public class TestLazyCores extends SolrTestCaseJ4 {@Overridepublic List<CoreDescriptor> discover(CoreContainer cc) {return List.of(- makeCoreDescriptor(cc, "collection1", "false", "true"),- makeCoreDescriptor(cc, "collection2", "true", "true"),- makeCoreDescriptor(cc, "collection3", "on", "false"),- makeCoreDescriptor(cc, "collection4", "false", "false"),- makeCoreDescriptor(cc, "collection5", "false", "true"),- makeCoreDescriptor(cc, "collection6", "true", "false"),- makeCoreDescriptor(cc, "collection7", "true", "false"),- makeCoreDescriptor(cc, "collection8", "true", "false"),- makeCoreDescriptor(cc, "collection9", "true", "false"));+ makeCoreDescriptor(cc, "collection1", "true"),+ makeCoreDescriptor(cc, "collection4", "false"),+ makeCoreDescriptor(cc, "collection5", "true"));}};private CoreContainer init() throws Exception {solrHomeDirectory = createTempDir();- copyXmlToHome(solrHomeDirectory, "solr-transientCores.xml");+ copyXmlToHome(solrHomeDirectory, "solr.xml");for (int idx = 1; idx < 10; ++idx) {copyMinConf(solrHomeDirectory.resolve("collection" + idx));}@@ -106,60 +77,26 @@ public class TestLazyCores extends SolrTestCaseJ4 {return createCoreContainer(cfg, testCores);}- private CoreContainer initEmpty() throws IOException {- solrHomeDirectory = createTempDir();- copyXmlToHome(solrHomeDirectory, "solr-transientCores.xml");- NodeConfig cfg = NodeConfig.loadNodeConfig(solrHomeDirectory, null);- return createCoreContainer(- cfg,- new ReadOnlyCoresLocator() {- @Override- public List<CoreDescriptor> discover(CoreContainer cc) {- return Collections.emptyList();- }- });- }-@Testpublic void testLazyLoad() throws Exception {CoreContainer cc = init();try {// NOTE: This checks the initial state for loading, no need to do this elsewhere.- checkLoadedCores(cc, "collection1", "collection2", "collection5");- checkCoresNotLoaded(- cc,- "collection3",- "collection4",- "collection6",- "collection7",- "collection8",- "collection9");+ checkLoadedCores(cc, "collection1", "collection5");+ checkCoresNotLoaded(cc, "collection4");SolrCore core1 = cc.getCore("collection1");- assertFalse("core1 should not be transient", core1.getCoreDescriptor().isTransient());assertTrue("core1 should be loadable", core1.getCoreDescriptor().isLoadOnStartup());assertNotNull(core1.getSolrConfig());- SolrCore core2 = cc.getCore("collection2");- assertTrue("core2 should be transient", core2.getCoreDescriptor().isTransient());- assertTrue("core2 should be loadable", core2.getCoreDescriptor().isLoadOnStartup());-- SolrCore core3 = cc.getCore("collection3");- assertTrue("core3 should be transient", core3.getCoreDescriptor().isTransient());- assertFalse("core3 should not be loadable", core3.getCoreDescriptor().isLoadOnStartup());-SolrCore core4 = cc.getCore("collection4");- assertFalse("core4 should not be transient", core4.getCoreDescriptor().isTransient());assertFalse("core4 should not be loadable", core4.getCoreDescriptor().isLoadOnStartup());SolrCore core5 = cc.getCore("collection5");- assertFalse("core5 should not be transient", core5.getCoreDescriptor().isTransient());assertTrue("core5 should be loadable", core5.getCoreDescriptor().isLoadOnStartup());core1.close();- core2.close();- core3.close();core4.close();core5.close();} finally {@@ -209,7 +146,7 @@ public class TestLazyCores extends SolrTestCaseJ4 {public void testLazySearch() throws Exception {CoreContainer cc = init();try {- // Make sure Lazy4 isn't loaded. Should be loaded on the get+ // Make sure collection4 isn't loaded. Should be loaded on the getcheckCoresNotLoaded(cc, "collection4");SolrCore core4 = cc.getCore("collection4");@@ -223,7 +160,7 @@ public class TestLazyCores extends SolrTestCaseJ4 {makeReq(collection1, "q", "{!raw f=v_t}hello", "wt", "xml"),"//result[@numFound='0']");- checkLoadedCores(cc, "collection1", "collection2", "collection4", "collection5");+ checkLoadedCores(cc, "collection1", "collection4", "collection5");core4.close();collection1.close();@@ -232,122 +169,6 @@ public class TestLazyCores extends SolrTestCaseJ4 {}}- @Test- public void testCachingLimit() throws Exception {- CoreContainer cc = init();- try {- // First check that all the cores that should be loaded at startup actually are.-- checkLoadedCores(cc, "collection1", "collection2", "collection5");- checkCoresNotLoaded(- cc,- "collection3",- "collection4",- "collection6",- "collection7",- "collection8",- "collection9");-- // By putting these in non-alpha order, we're also checking that we're not just seeing an- // artifact.- getCoreAndPutBack(cc, "collection1");- getCoreAndPutBack(cc, "collection3");- getCoreAndPutBack(cc, "collection4");- getCoreAndPutBack(cc, "collection2");- getCoreAndPutBack(cc, "collection5");-- checkLoadedCores(- cc, "collection1", "collection2", "collection3", "collection4", "collection5");- checkCoresNotLoaded(cc, "collection6", "collection7", "collection8", "collection9");-- // map should be full up, add one more and verify- getCoreAndPutBack(cc, "collection6");- checkLoadedCores(- cc,- "collection1",- "collection2",- "collection3",- "collection4",- "collection5",- "collection6");- checkCoresNotLoaded(cc, "collection7", "collection8", "collection9");-- getCoreAndPutBack(cc, "collection7");- checkLoadedCores(- cc,- "collection1",- "collection2",- "collection3",- "collection4",- "collection5",- "collection6",- "collection7");- checkCoresNotLoaded(cc, "collection8", "collection9");-- getCoreAndPutBack(cc, "collection8");- checkLoadedCores(cc, "collection1", "collection4", "collection5", "collection8");- checkSomeLoadedCores(- cc,- TRANSIENT_CORE_CACHE_MAX_SIZE,- "collection2",- "collection3",- "collection6",- "collection7",- "collection8");- checkCoresNotLoaded(cc, "collection9");- checkSomeCoresNotLoaded(- cc,- 5 - TRANSIENT_CORE_CACHE_MAX_SIZE,- "collection2",- "collection3",- "collection6",- "collection7");-- getCoreAndPutBack(cc, "collection9");- checkLoadedCores(cc, "collection1", "collection4", "collection5", "collection9");- checkSomeLoadedCores(- cc,- TRANSIENT_CORE_CACHE_MAX_SIZE,- "collection2",- "collection3",- "collection6",- "collection7",- "collection8",- "collection9");- checkSomeCoresNotLoaded(- cc,- 6 - TRANSIENT_CORE_CACHE_MAX_SIZE,- "collection2",- "collection3",- "collection6",- "collection7",- "collection8");-- // verify that getting metrics from an unloaded core doesn't cause exceptions (SOLR-12541)- try (SolrCore core1 = cc.getCore("collection1");- 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);- }-- } finally {- cc.shutdown();- }- }-- private void getCoreAndPutBack(CoreContainer cc, String name) {- SolrCore core1 = cc.getCore(name);- core1.close(); // note: the core can't have a refCount > 1 to be an eviction candidate- }-// Test case for SOLR-4300@Test@@ -359,15 +180,13 @@ public class TestLazyCores extends SolrTestCaseJ4 {Thread[] threads = new Thread[15];for (int idx = 0; idx < threads.length; idx++) {threads[idx] =- new Thread() {- @Override- public void run() {- SolrCore core = cc.getCore("collection3");- synchronized (theCores) {- theCores.add(core);- }- }- };+ new Thread(+ () -> {+ SolrCore core = cc.getCore("collection4");+ synchronized (theCores) {+ theCores.add(core);+ }+ });threads[idx].start();}for (Thread thread : threads) {@@ -419,53 +238,22 @@ public class TestLazyCores extends SolrTestCaseJ4 {public void testCreateSame() throws Exception {final CoreContainer cc = init();try {- // First, try all 4 combinations of load on startup and transientfinal CoreAdminHandler admin = new CoreAdminHandler(cc);- SolrCore lc2 = cc.getCore("collection2");SolrCore lc4 = cc.getCore("collection4");SolrCore lc5 = cc.getCore("collection5");- SolrCore lc6 = cc.getCore("collection6");- copyMinConf(solrHomeDirectory.resolve("t2"));- copyMinConf(solrHomeDirectory.resolve("t4"));- copyMinConf(solrHomeDirectory.resolve("t5"));- copyMinConf(solrHomeDirectory.resolve("t6"));-- // Should also fail with the same name- tryCreateFail(admin, "collection2", "t12", "Core with name", "collection2", "already exists");+ // Should fail with the same nametryCreateFail(admin, "collection4", "t14", "Core with name", "collection4", "already exists");tryCreateFail(admin, "collection5", "t15", "Core with name", "collection5", "already exists");- tryCreateFail(admin, "collection6", "t16", "Core with name", "collection6", "already exists");- lc2.close();lc4.close();lc5.close();- lc6.close();} finally {cc.shutdown();}}- private void createViaAdmin(- CoreContainer cc, String name, boolean isTransient, boolean loadOnStartup) throws Exception {-- try (final CoreAdminHandler admin = new CoreAdminHandler(cc)) {- SolrQueryResponse resp = new SolrQueryResponse();- admin.handleRequestBody(- req(- CoreAdminParams.ACTION,- CoreAdminParams.CoreAdminAction.CREATE.toString(),- CoreAdminParams.NAME,- name,- CoreAdminParams.TRANSIENT,- Boolean.toString(isTransient),- CoreAdminParams.LOAD_ON_STARTUP,- Boolean.toString(loadOnStartup)),- resp);- }- }-private void unloadViaAdmin(CoreContainer cc, String name) throws Exception {try (final CoreAdminHandler admin = new CoreAdminHandler(cc)) {@@ -480,95 +268,6 @@ public class TestLazyCores extends SolrTestCaseJ4 {}}- // Make sure that creating a transient core from the admin handler correctly respects the- // transient limits etc.- @Test- public void testCreateTransientFromAdmin() throws Exception {- final CoreContainer cc = initEmpty();- try {- copyMinConf(solrHomeDirectory.resolve("core1"));- copyMinConf(solrHomeDirectory.resolve("core2"));- copyMinConf(solrHomeDirectory.resolve("core3"));- copyMinConf(solrHomeDirectory.resolve("core4"));- copyMinConf(solrHomeDirectory.resolve("core5"));-- createViaAdmin(cc, "core1", true, true);- createViaAdmin(cc, "core2", true, false);- createViaAdmin(cc, "core3", true, true);- createViaAdmin(cc, "core4", true, false);- createViaAdmin(cc, "core5", true, false);-- final var coreNames = new String[] {"core1", "core2", "core3", "core4", "core5"};- checkSomeCoresNotLoaded(cc, coreNames.length - TRANSIENT_CORE_CACHE_MAX_SIZE, coreNames);-- final SolrCore c1 = cc.getCore("core1");- final SolrCore c2 = cc.getCore("core2");- final SolrCore c3 = cc.getCore("core3");- final SolrCore c4 = cc.getCore("core4");- final SolrCore c5 = cc.getCore("core5");-- // no cores should be unloaded because we have references to them- checkSomeCoresNotLoaded(cc, 0, coreNames);-- checkSomeLoadedCores(cc, 5, coreNames);-- // While we're at it, a test for SOLR-5366, unloading transient core that's been unloaded b/c- // it's transient generates a "too many closes" error-- class TestThread extends Thread {-- @Override- public void run() {-- final int sleep_millis = random().nextInt(1000);- try {- if (sleep_millis > 0) {- if (VERBOSE) {- System.out.println(- "TestLazyCores.testCreateTransientFromAdmin Thread.run sleeping for "- + sleep_millis- + " ms");- }- Thread.sleep(sleep_millis);- }- } catch (InterruptedException ie) {- if (VERBOSE) {- System.out.println(- "TestLazyCores.testCreateTransientFromAdmin Thread.run caught "- + ie- + " whilst sleeping for "- + sleep_millis- + " ms");- }- }-- c1.close();- c2.close();- c3.close();- c4.close();- c5.close();- }- }- ;-- // with SOLR-6279 UNLOAD will wait for the core's reference count to have reached zero- // hence cN.close() need to proceed or run in parallel with unloadViaAdmin(...)- final TestThread cThread = new TestThread();- cThread.start();-- unloadViaAdmin(cc, "core1");- unloadViaAdmin(cc, "core2");- unloadViaAdmin(cc, "core3");- unloadViaAdmin(cc, "core4");- unloadViaAdmin(cc, "core5");-- cThread.join();-- } finally {- cc.shutdown();- }- }-// Test that transient cores// 1> produce errors as appropriate when the config or schema files are foo'd// 2> "self-heal". That is, if the problem is corrected can the core be reloaded and used?@@ -626,7 +325,6 @@ public class TestLazyCores extends SolrTestCaseJ4 {cc.reload("badSchema1");cc.reload("badSchema2");SolrCore bc1 = cc.getCore("badConfig1");- ;SolrCore bc2 = cc.getCore("badConfig2");SolrCore bs1 = cc.getCore("badSchema1");SolrCore bs2 = cc.getCore("badSchema2");@@ -958,155 +656,4 @@ public class TestLazyCores extends SolrTestCaseJ4 {cc.shutdown();}}-- // Ensure that when a core is evicted from the transient cache, any uncommitted docs are- // preserved. Note, this needs FS-based indexes to persist! Cores 2, 3, 6, 7, 8, 9 are transient- @Test- public void testNoCommit() throws Exception {- CoreContainer cc = init();- String[] transientCoreNames =- new String[] {- "collection2", "collection3", "collection6", "collection7", "collection8", "collection9"- };- try {- // First, go through all the transient cores and add some docs. DO NOT COMMIT!- // The evicted core should commit the docs when it gets closed.- for (String coreName : transientCoreNames) {- try (SolrCore core = cc.getCore(coreName)) {- add10(core);- }- }-- // Just proving that some cores have been evicted to respect transient core cache max size.- checkSomeCoresNotLoaded(- cc, transientCoreNames.length - TRANSIENT_CORE_CACHE_MAX_SIZE, transientCoreNames);-- // We still should have 4 transient cores loaded, their reference counts have NOT dropped to- // zero- checkLoadedCores(cc, "collection1", "collection5");- checkSomeLoadedCores(cc, TRANSIENT_CORE_CACHE_MAX_SIZE, transientCoreNames);-- Collection<String> loadedCoreNames = cc.getLoadedCoreNames();- int notLoadedCoreCount = 0;- List<SolrCore> openCores = new ArrayList<>();- for (String coreName : transientCoreNames) {- // The point of this test is to ensure that when cores are evicted and re-opened- // that the docs are there, so ensure that the core we're testing is gone, gone, gone.- if (!loadedCoreNames.contains(coreName)) {- notLoadedCoreCount++;- checkCoresNotLoaded(cc, coreName);-- // Load the core up again.- SolrCore core = cc.getCore(coreName);- openCores.add(core);- checkLoadedCores(cc, coreName);-- // Insure docs are still there.- check10(core);- }- }- assertEquals(transientCoreNames.length - TRANSIENT_CORE_CACHE_MAX_SIZE, notLoadedCoreCount);- openCores.forEach(SolrCore::close);- } finally {- cc.shutdown();- }- }-- private void add10(SolrCore core) throws IOException {- for (int idx = 0; idx < 10; ++idx) {- addLazy(core, "id", "0" + idx);- }- SolrQueryRequest req = makeReq(core);- }-- private void check10(SolrCore core) {- // Just get a couple of searches to work!- assertQ(- "test closing core without committing",- makeReq(core, "q", "*:*"),- "//result[@numFound='10']");- }-- public void testDontEvictUsedCore() throws Exception {- // If a core is being used for a long time (say a long indexing batch) but nothing else for it,- // and if the transient cache has pressure and thus wants to unload a core, we should not- // unload it (yet).-- CoreContainer cc = init();- String[] transientCoreNames =- new String[] {- "collection2", "collection3", "collection6", "collection7", "collection8", "collection9"- };-- try (LogListener logs =- LogListener.info(TransientSolrCoreCacheDefault.class.getName())- .substring("NOT evicting transient core [" + transientCoreNames[0] + "]")) {- cc.waitForLoadingCoresToFinish(1000);- var solr = new EmbeddedSolrServer(cc, null);- final var longReqTimeMs = 5000; // plenty of time for a slow/busy CI-- // First, start a long request on the first transient core.- // We do this via relying on EmbeddedSolrServer to keep the core open as it works with- // this streaming callback mechanism.- var longRequestLatch = new CountDownLatch(1);- var thread =- new Thread("longRequest") {- @Override- public void run() {- try {- solr.queryAndStreamResponse(- transientCoreNames[0],- params("q", "*:*"),- new StreamingResponseCallback() {- @Override- public void streamSolrDocument(SolrDocument doc) {}-- @Override- public void streamDocListInfo(long numFound, long start, Float maxScore) {- try {- // the core remains open until the test calls countDown()- longRequestLatch.await();- } catch (InterruptedException e) {- Thread.currentThread().interrupt();- throw new RuntimeException(e);- }- }- });- } catch (SolrServerException | IOException e) {- fail(e.toString());- }- }- };- thread.start();-- System.out.println("Inducing pressure on cache by querying many cores...");- // Now hammer on other transient cores to create transient cache pressure- for (int round = 0; round < 5 && logs.getCount() == 0; round++) {- // note: we skip over the first; we want the first to remain non-busy- for (int i = 1; i < transientCoreNames.length; i++) {- solr.query(transientCoreNames[i], params("q", "*:*"));- }- }- // Show that the cache logs that it was asked to evict but did not.- // To show the bug behavior, comment this out and also comment out the corresponding logic- // that fixes it at the spot this message is logged.- assertTrue(logs.getCount() > 0);-- System.out.println("Done inducing pressure; now load first core");- assertTrue("long request should still be busy", thread.isAlive());- // Do another request on the first core- solr.query(transientCoreNames[0], params("q", "id:wakeUp"));-- longRequestLatch.countDown();- thread.join(longReqTimeMs);- assertFalse(thread.isAlive());-- // Do another request on the first core- solr.query(transientCoreNames[0], params("q", "id:justCheckingAgain"));-- logs.getQueue().clear();- } finally {- cc.shutdown();- }- }}diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java b/solr/core/src/test/org/apache/solr/core/TestSolrXml.javaindex 4d9faac73f5..9cfc310ba0d 100644--- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java+++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java@@ -115,7 +115,6 @@ public class TestSolrXml extends SolrTestCaseJ4 {assertEquals("manage path", "testManagementPath", cfg.getManagementPath());assertEquals("shardLib", "testSharedLib", cfg.getSharedLibDirectory());assertTrue("schema cache", cfg.hasSchemaCache());- assertEquals("trans cache size", 66, cfg.getTransientCacheSize());assertEquals("zk client timeout", 77, ccfg.getZkClientTimeout());assertEquals("zk host", "testZkHost", ccfg.getZkHost());assertEquals("zk ACL provider", "DefaultZkACLProvider", ccfg.getZkACLProviderClass());diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.javaindex 5e17ca9cf8e..302089305b2 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java@@ -277,8 +277,8 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {assertEquals(1, values.size());assertNotNull(values.get("solr.node"));values = (NamedList<?>) values.get("solr.node");- assertEquals(15, values.size());- assertNotNull(values.get("CONTAINER.cores.lazy")); // this is a gauge node+ assertEquals(14, values.size());+ assertNotNull(values.get("CONTAINER.cores.loaded")); // this is a gauge nodeassertNotNull(values.get("CONTAINER.threadPool.coreLoadExecutor.completed"));resp = new SolrQueryResponse();@@ -300,7 +300,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {values = (NamedList<?>) values.get("metrics");assertNotNull(values.get("solr.node"));values = (NamedList<?>) values.get("solr.node");- assertEquals(5, values.size());+ assertEquals(4, values.size());assertNotNull(values.get("CONTAINER.threadPool.coreLoadExecutor.completed"));resp = new SolrQueryResponse();@@ -861,8 +861,8 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {actualSnapshot = getMetricSnapshot(actualSnapshots, "solr_metrics_node_cores");actualGaugeDataPoint =getGaugeDatapointSnapshot(- actualSnapshot, Labels.of("category", "CONTAINER", "item", "lazy"));- assertEquals(0, actualGaugeDataPoint.getValue(), 0);+ actualSnapshot, Labels.of("category", "CONTAINER", "item", "loaded"));+ assertEquals(1, actualGaugeDataPoint.getValue(), 0);handler.close();}diff --git a/solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.javaindex b65373c49da..aa5b4a9722d 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.java@@ -59,7 +59,6 @@ public class V2CoresAPIMappingTest extends V2ApiMappingTest<CoreAdminHandler> {v1Params.add("configSet", "someConfigset");v1Params.add("shard", "shard1");v1Params.add("loadOnStartup", "true");- v1Params.add("transient", "true");v1Params.add("coreNodeName", "someNodeName");v1Params.add("newCollection", "true");v1Params.add("async", "someAsyncId");@@ -81,7 +80,6 @@ public class V2CoresAPIMappingTest extends V2ApiMappingTest<CoreAdminHandler> {assertEquals("someCollection", createRequestBody.collection);assertEquals("shard1", createRequestBody.shard);assertEquals(Boolean.TRUE, createRequestBody.loadOnStartup);- assertEquals(Boolean.TRUE, createRequestBody.isTransient);assertEquals(Boolean.TRUE, createRequestBody.newCollection);assertEquals("someNodeName", createRequestBody.coreNodeName);assertNotNull(createRequestBody.properties);diff --git a/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java b/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.javaindex e1e178e0ae3..18f3bb39217 100644--- a/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java+++ b/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java@@ -211,7 +211,6 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {MetricRegistry registry = cc.getMetricManager().registry(registryName);Map<String, Metric> metrics = registry.getMetrics();assertTrue(metrics.containsKey("CONTAINER.cores.loaded"));- assertTrue(metrics.containsKey("CONTAINER.cores.lazy"));assertTrue(metrics.containsKey("CONTAINER.cores.unloaded"));assertTrue(metrics.containsKey("CONTAINER.fs.totalSpace"));assertTrue(metrics.containsKey("CONTAINER.fs.usableSpace"));diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adocindex 1b1225b57f1..8d9d338d5ce 100644--- a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc@@ -308,16 +308,6 @@ This attribute, when set to `true`, ensures that the multiple cores pointing toSharing the IndexSchema Object makes loading the core faster.If you use this feature, make sure that no core-specific property is used in your Schema file.-`transientCacheSize`::-+-[%autowidth,frame=none]-|===-|Optional |Default: none-|===-+-*Deprecated as of 9.2.*-Defines how many Solr cores with `transient=true` that can be loaded before unloading an unused core for one that is needed.-`configSetBaseDir`::+[%autowidth,frame=none]diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/core-discovery.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/core-discovery.adocindex 779c0812c3b..04ce53ad47e 100644--- a/solr/solr-ref-guide/modules/configuration-guide/pages/core-discovery.adoc+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/core-discovery.adoc@@ -146,17 +146,6 @@ The name of a defined configset, if desired, to use to configure the core (see tThe name of the properties file for this core.The value can be an absolute pathname or a path relative to the value of `instanceDir`.-`transient`::-+-[%autowidth,frame=none]-|===-|Optional |Default: `false`-|===-+-When `true`, the core can be unloaded if Solr reaches the `transientCacheSize`.-Cores are unloaded in order of least recently used first.-_Setting this to `true` is not recommended in SolrCloud mode._-`loadOnStartup`::+[%autowidth,frame=none]diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/property-substitution.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/property-substitution.adocindex 3f756da1470..451decca0f8 100644--- a/solr/solr-ref-guide/modules/configuration-guide/pages/property-substitution.adoc+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/property-substitution.adoc@@ -141,5 +141,4 @@ All implicit properties use the `solr.core.` name prefix, and reflect the runtim* `solr.core.config`* `solr.core.schema`* `solr.core.dataDir`-* `solr.core.transient`* `solr.core.loadOnStartup`diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adocindex ef02fcd5042..dfbb9acf900 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc@@ -312,7 +312,7 @@ complex objects:----=== Caching Threads Metrics ===-The threads metrics in the JVM group can be expensive to compute, as it requires traversing all threads.+The threads metrics in the JVM group can be expensive to compute, as it requires traversing all threads.This can be avoided for every call to the metrics API (group=jvm) by setting a high caching expiration interval(in seconds). For example, to cache the thread metrics for 5 seconds:@@ -639,7 +639,6 @@ For example:[source,plain]-----example.solr.node.cores.lazy 0 1482932097example.solr.node.cores.loaded 1 1482932097example.solr.jetty.org.eclipse.jetty.server.handler.DefaultHandler.2xx-responses.count 21 1482932097example.solr.jetty.org.eclipse.jetty.server.handler.DefaultHandler.2xx-responses.m1_rate 2.5474287707930614 1482932097diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adocindex 1821dadbf8e..9df9dc71a7a 100644--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc@@ -168,6 +168,8 @@ Nowadays, the HTTP request is available via internal APIs: `SolrQueryRequest.get* BlobHandler and the `.system` collection have been removed in favour of FileStore API. (SOLR-17851).+* The deprecated transient Solr cores capability has been removed. (SOLR-17932)+=== Securitydiff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/NodeValueFetcher.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/NodeValueFetcher.javaindex b2843c6dec5..fc703dadddc 100644--- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/NodeValueFetcher.java+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/NodeValueFetcher.java@@ -61,7 +61,7 @@ public class NodeValueFetcher {public Object extractResult(Object root) {NamedList<?> node = (NamedList<?>) Utils.getObjectByPath(root, false, "solr.node");int count = 0;- for (String leafCoreMetricName : new String[] {"lazy", "loaded", "unloaded"}) {+ for (String leafCoreMetricName : new String[] {"loaded", "unloaded"}) {Number n = (Number) node.get("CONTAINER.cores." + leafCoreMetricName);if (n != null) count += n.intValue();}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.javaindex 88fe9e2e11e..3c4b5dae0a1 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@@ -59,7 +59,6 @@ public class CoreAdminRequest extends SolrRequest<CoreAdminResponse> {private String shardId;private String coreNodeName;private Boolean loadOnStartup;- private Boolean isTransient;private String collectionConfigName;public Create() {@@ -106,10 +105,6 @@ public class CoreAdminRequest extends SolrRequest<CoreAdminResponse> {this.coreNodeName = coreNodeName;}- public void setIsTransient(Boolean isTransient) {- this.isTransient = isTransient;- }-public void setIsLoadOnStartup(Boolean loadOnStartup) {this.loadOnStartup = loadOnStartup;}@@ -159,10 +154,6 @@ public class CoreAdminRequest extends SolrRequest<CoreAdminResponse> {return loadOnStartup;}- public Boolean getIsTransient() {- return isTransient;- }-public String getCollectionConfigName() {return collectionConfigName;}@@ -221,10 +212,6 @@ public class CoreAdminRequest extends SolrRequest<CoreAdminResponse> {params.set(CoreAdminParams.CORE_NODE_NAME, coreNodeName);}- if (isTransient != null) {- params.set(CoreAdminParams.TRANSIENT, isTransient);- }-if (loadOnStartup != null) {params.set(CoreAdminParams.LOAD_ON_STARTUP, loadOnStartup);}diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java b/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.javaindex a3d048bab35..ea220642124 100644--- a/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java+++ b/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java@@ -107,8 +107,6 @@ public abstract class CoreAdminParams {public static final String LOAD_ON_STARTUP = "loadOnStartup";- public static final String TRANSIENT = "transient";-// Node to create a replica on for ADDREPLICA at least.public static final String NODE = "node";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.javaindex d0a52e9322b..ea974cddc65 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@@ -90,7 +90,6 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {// These should be the inverse of defaults.req.setIsLoadOnStartup(false);- req.setIsTransient(true);req.process(client);// Show that the newly-created core has values for load on startup and transient that differ@@ -99,9 +98,6 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {try (SolrCore coreProveIt = cores.getCore("collection1");SolrCore core = cores.getCore("newcore")) {- assertTrue(core.getCoreDescriptor().isTransient());- assertFalse(coreProveIt.getCoreDescriptor().isTransient());-assertFalse(core.getCoreDescriptor().isLoadOnStartup());assertTrue(coreProveIt.getCoreDescriptor().isLoadOnStartup());