@@ -239,7 +239,6 @@ public JerseyAppHandlerCache getJerseyAppHandlerCache() {
239239
240240 protected volatile LogWatcher <?> logging = null ;
241241
242- private volatile CloserThread backgroundCloser = null ;
243242 protected final NodeConfig cfg ;
244243 protected final SolrResourceLoader loader ;
245244
@@ -894,12 +893,6 @@ private void loadInternal() {
894893 "loaded" ,
895894 SolrInfoBean .Category .CONTAINER .toString (),
896895 "cores" );
897- solrMetricsContext .gauge (
898- solrCores ::getNumLoadedTransientCores ,
899- true ,
900- "lazy" ,
901- SolrInfoBean .Category .CONTAINER .toString (),
902- "cores" );
903896 solrMetricsContext .gauge (
904897 solrCores ::getNumUnloadedCores ,
905898 true ,
@@ -1028,7 +1021,7 @@ private void loadInternal() {
10281021 status |= CORE_DISCOVERY_COMPLETE ;
10291022
10301023 for (final CoreDescriptor cd : cds ) {
1031- if (cd . isTransient () || !cd .isLoadOnStartup ()) {
1024+ if (!cd .isLoadOnStartup ()) {
10321025 solrCores .addCoreDescriptor (cd );
10331026 } else if (asyncSolrCoreLoad ) {
10341027 solrCores .markCoreAsLoading (cd );
@@ -1069,10 +1062,6 @@ private void loadInternal() {
10691062 }
10701063 }
10711064
1072- // Start the background thread
1073- backgroundCloser = new CloserThread (this , solrCores , cfg );
1074- backgroundCloser .start ();
1075-
10761065 } finally {
10771066 coreLoadExecutor .shutdown (); // doesn't block
10781067 if (!asyncSolrCoreLoad ) {
@@ -1259,31 +1248,6 @@ public void shutdown() {
12591248
12601249 ExecutorUtil .shutdownAndAwaitTermination (coreLoadExecutor ); // actually already shutdown
12611250
1262- // First wake up the closer thread, it'll terminate almost immediately since it checks
1263- // isShutDown.
1264- synchronized (solrCores .getModifyLock ()) {
1265- solrCores .getModifyLock ().notifyAll (); // wake up anyone waiting
1266- }
1267- if (backgroundCloser
1268- != null ) { // Doesn't seem right, but tests get in here without initializing the core.
1269- try {
1270- while (true ) {
1271- backgroundCloser .join (15000 );
1272- if (backgroundCloser .isAlive ()) {
1273- synchronized (solrCores .getModifyLock ()) {
1274- solrCores .getModifyLock ().notifyAll (); // there is a race we have to protect against
1275- }
1276- } else {
1277- break ;
1278- }
1279- }
1280- } catch (InterruptedException e ) {
1281- Thread .currentThread ().interrupt ();
1282- if (log .isDebugEnabled ()) {
1283- log .debug ("backgroundCloser thread was interrupted before finishing" );
1284- }
1285- }
1286- }
12871251 // Now clear all the cores that are being operated upon.
12881252 solrCores .close ();
12891253
@@ -1877,13 +1841,8 @@ public List<SolrCore> getCores() {
18771841 }
18781842
18791843 /**
1880- * Gets the permanent and transient cores that are currently loaded, i.e. cores that have 1:
1881- * loadOnStartup=true and are either not-transient or, if transient, have been loaded and have not
1882- * been aged out 2: loadOnStartup=false and have been loaded but are either non-transient or have
1883- * not been aged out.
1884- *
1885- * <p>Put another way, this will not return any names of cores that are lazily loaded but have not
1886- * been called for yet or are transient and either not loaded or have been swapped out.
1844+ * Gets the cores that are currently loaded, i.e. cores that have 1: loadOnStartup=true and have
1845+ * been loaded and 2: loadOnStartup=false and have been subsequently loaded.
18871846 *
18881847 * <p>For efficiency, prefer to check {@link #isLoaded(String)} instead of {@link
18891848 * #getLoadedCoreNames()}.contains(coreName).
@@ -1896,8 +1855,7 @@ public List<String> getLoadedCoreNames() {
18961855 }
18971856
18981857 /**
1899- * Gets a collection of all the cores, permanent and transient, that are currently known, whether
1900- * they are loaded or not.
1858+ * Gets a collection of all the cores that are currently known, whether they are loaded or not.
19011859 *
19021860 * <p>For efficiency, prefer to check {@link #getCoreDescriptor(String)} != null instead of {@link
19031861 * #getAllCoreNames()}.contains(coreName).
@@ -1910,8 +1868,8 @@ public List<String> getAllCoreNames() {
19101868 }
19111869
19121870 /**
1913- * Gets the total number of cores, including permanent and transient cores, loaded and unloaded
1914- * cores. Faster equivalent for {@link #getAllCoreNames()}.size().
1871+ * Gets the total number of cores, including both loaded and unloaded cores. Faster equivalent to
1872+ * {@link #getAllCoreNames()}.size().
19151873 */
19161874 public int getNumAllCores () {
19171875 return solrCores .getNumAllCores ();
@@ -2143,16 +2101,11 @@ private void unloadWithoutCoreOp(
21432101 ErrorCode .BAD_REQUEST , "Cannot unload non-existent core [" + name + "]" );
21442102 }
21452103
2146- boolean close = solrCores .isLoadedNotPendingClose (name );
2104+ boolean close = solrCores .isLoaded (name );
21472105 SolrCore core = solrCores .remove (name );
21482106
21492107 solrCores .removeCoreDescriptor (cd );
21502108 coresLocator .delete (this , cd );
2151- if (core == null ) {
2152- // transient core
2153- SolrCore .deleteUnloadedCore (cd , deleteDataDir , deleteInstanceDir );
2154- return ;
2155- }
21562109
21572110 // delete metrics specific to this core
21582111 metricManager .removeRegistry (core .getCoreMetricManager ().getRegistryName ());
@@ -2264,16 +2217,13 @@ public SolrCore getCore(String name, UUID id) {
22642217 // if there was an error initializing this core, throw a 500
22652218 // error with the details for clients attempting to access it.
22662219 CoreLoadFailure loadFailure = getCoreInitFailures ().get (name );
2267- if (null != loadFailure ) {
2220+ if (loadFailure != null ) {
22682221 throw new SolrCoreInitializationException (name , loadFailure .exception );
22692222 }
2270- // This is a bit of awkwardness where SolrCloud and transient cores don't play nice together.
2271- // For transient cores, we have to allow them to be created at any time there hasn't been a core
2272- // load failure (use reload to cure that). But for
2273- // TestConfigSetsAPI.testUploadWithScriptUpdateProcessor, this needs to _not_ try to load the
2274- // core if the core is null and there was an error. If you change this, be sure to run both
2275- // TestConfigSetsAPI and TestLazyCores
2276- if (desc == null || zkSys .getZkController () != null ) return null ;
2223+
2224+ if (desc == null || zkSys .getZkController () != null ) {
2225+ return null ;
2226+ }
22772227
22782228 // This will put an entry in pending core ops if the core isn't loaded. Here's where moving the
22792229 // waitAddPendingCoreOps to createFromDescriptor would introduce a race condition.
@@ -2574,45 +2524,3 @@ public void addKeyVal(Object map, Object key, Object val) throws IOException {
25742524 });
25752525 }
25762526}
2577-
2578- class CloserThread extends Thread {
2579- CoreContainer container ;
2580- SolrCores solrCores ;
2581- NodeConfig cfg ;
2582-
2583- CloserThread (CoreContainer container , SolrCores solrCores , NodeConfig cfg ) {
2584- super ("CloserThread" );
2585- this .container = container ;
2586- this .solrCores = solrCores ;
2587- this .cfg = cfg ;
2588- }
2589-
2590- // It's important that this be the _only_ thread removing things from pendingDynamicCloses!
2591- // This is single-threaded, but I tried a multithreaded approach and didn't see any performance
2592- // gains, so there's no good justification for the complexity. I suspect that the locking on
2593- // things like DefaultSolrCoreState essentially create a single-threaded process anyway.
2594- @ Override
2595- public void run () {
2596- while (!container .isShutDown ()) {
2597- synchronized (solrCores .getModifyLock ()) { // need this so we can wait and be awoken.
2598- try {
2599- solrCores .getModifyLock ().wait ();
2600- } catch (InterruptedException e ) {
2601- // Well, if we've been told to stop, we will. Otherwise, continue on and check to see if
2602- // there are any cores to close.
2603- }
2604- }
2605-
2606- SolrCore core ;
2607- while (!container .isShutDown () && (core = solrCores .getCoreToClose ()) != null ) {
2608- assert core .getOpenCount () == 1 ;
2609- try {
2610- MDCLoggingContext .setCore (core );
2611- core .close (); // will clear MDC
2612- } finally {
2613- solrCores .removeFromPendingOps (core .getName ());
2614- }
2615- }
2616- }
2617- }
2618- }
0 commit comments