Package org.apache.solr.core
Class SolrCores
- java.lang.Object
-
- org.apache.solr.core.SolrCores
-
- Direct Known Subclasses:
TransientSolrCores
public class SolrCores extends Object
AKA CoreManager: Holds/managesSolrCores withinCoreContainer.
-
-
Field Summary
Fields Modifier and Type Field Description protected ObjectmodifyLock
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCoreDescriptor(CoreDescriptor p)protected voidclose()List<String>getAllCoreNames()Gets a collection of all cores names, loaded and unloaded.CoreDescriptorgetCoreDescriptor(String coreName)Return the CoreDescriptor corresponding to a given core name.List<CoreDescriptor>getCoreDescriptors()Get the CoreDescriptors for everySolrCoremanaged here (permanent and transient, loaded and unloaded).SolrCoregetCoreFromAnyList(String name, boolean incRefCount)SolrCoregetCoreFromAnyList(String name, boolean incRefCount, UUID coreId)List<SolrCore>getCores()Deprecated.SolrCoregetCoreToClose()List<String>getLoadedCoreNames()Gets the cores that are currently loaded, i.e.protected SolrCoregetLoadedCoreWithoutIncrement(String name)(internal) Return a core that is already loaded, if it is.ObjectgetModifyLock()intgetNumAllCores()Gets the total number of cores, including permanent and transient cores, loaded and unloaded cores.intgetNumLoadedPermanentCores()Gets the number of currently loaded permanent (non transient) cores.intgetNumLoadedTransientCores()Gets the number of currently loaded transient cores.intgetNumUnloadedCores()Gets the number of unloaded cores, including permanent and transient cores.protected booleanhasPendingCoreOps(String name)The core is currently loading, unloading, or reloading.booleanisCoreLoading(String name)booleanisLoaded(String name)booleanisLoadedNotPendingClose(String name)voidmarkCoreAsLoading(CoreDescriptor cd)voidmarkCoreAsNotLoading(CoreDescriptor cd)static SolrCoresnewSolrCores(CoreContainer coreContainer)SolrCoreputCore(CoreDescriptor cd, SolrCore core)voidqueueCoreToClose(SolrCore coreToClose)SolrCoreremove(String name)voidremoveCoreDescriptor(CoreDescriptor p)voidremoveFromPendingOps(String name)voidswap(String n0, String n1)SolrCorewaitAddPendingCoreOps(String name)voidwaitForLoadingCoresToFinish(long timeoutMs)voidwaitForLoadingCoreToFinish(String core, long timeoutMs)
-
-
-
Field Detail
-
modifyLock
protected final Object modifyLock
-
-
Method Detail
-
newSolrCores
public static SolrCores newSolrCores(CoreContainer coreContainer)
-
addCoreDescriptor
public void addCoreDescriptor(CoreDescriptor p)
-
removeCoreDescriptor
public void removeCoreDescriptor(CoreDescriptor p)
-
close
protected void close()
-
putCore
public SolrCore putCore(CoreDescriptor cd, SolrCore core)
-
getCores
@Deprecated public List<SolrCore> getCores()
Deprecated.- Returns:
- A list of "permanent" cores, i.e. cores that may not be swapped out and are currently
loaded.
A core may be non-transient but still lazily loaded. If it is "permanent" and lazy-load _and_ not yet loaded it will _not_ be returned by this call.
This list is a new copy, it can be modified by the caller (e.g. it can be sorted).
Note: This is one of the places where SolrCloud is incompatible with Transient Cores. This call is used in cancelRecoveries, transient cores don't participate.
-
getLoadedCoreNames
public List<String> getLoadedCoreNames()
Gets the 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 either non-transient or have not been aged out.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.
- Returns:
- An unsorted list. This list is a new copy, it can be modified by the caller (e.g. it can be sorted).
-
getAllCoreNames
public List<String> getAllCoreNames()
Gets a collection of all cores names, loaded and unloaded. For efficiency, prefer to checkgetCoreDescriptor(String)!= null instead ofgetAllCoreNames().contains(String)- Returns:
- An unsorted list. This list is a new copy, it can be modified by the caller (e.g. it can be sorted).
-
getNumLoadedPermanentCores
public int getNumLoadedPermanentCores()
Gets the number of currently loaded permanent (non transient) cores. Faster equivalent forgetCores().size().
-
getNumLoadedTransientCores
public int getNumLoadedTransientCores()
Gets the number of currently loaded transient cores.
-
getNumUnloadedCores
public int getNumUnloadedCores()
Gets the number of unloaded cores, including permanent and transient cores.
-
getNumAllCores
public int getNumAllCores()
Gets the total number of cores, including permanent and transient cores, loaded and unloaded cores. Faster equivalent forgetAllCoreNames().size().
-
getCoreFromAnyList
public SolrCore getCoreFromAnyList(String name, boolean incRefCount, UUID coreId)
-
getLoadedCoreWithoutIncrement
protected SolrCore getLoadedCoreWithoutIncrement(String name)
(internal) Return a core that is already loaded, if it is. NOT incremented!
-
isLoadedNotPendingClose
public boolean isLoadedNotPendingClose(String name)
-
isLoaded
public boolean isLoaded(String name)
-
hasPendingCoreOps
protected boolean hasPendingCoreOps(String name)
The core is currently loading, unloading, or reloading.
-
removeFromPendingOps
public void removeFromPendingOps(String name)
-
getModifyLock
public Object getModifyLock()
-
getCoreToClose
public SolrCore getCoreToClose()
-
getCoreDescriptor
public CoreDescriptor getCoreDescriptor(String coreName)
Return the CoreDescriptor corresponding to a given core name. Blocks if the SolrCore is still loading until it is ready.- Parameters:
coreName- the name of the core- Returns:
- the CoreDescriptor
-
getCoreDescriptors
public List<CoreDescriptor> getCoreDescriptors()
Get the CoreDescriptors for everySolrCoremanaged here (permanent and transient, loaded and unloaded).- Returns:
- An unordered list copy. This list can be modified by the caller (e.g. sorted).
-
markCoreAsLoading
public void markCoreAsLoading(CoreDescriptor cd)
-
markCoreAsNotLoading
public void markCoreAsNotLoading(CoreDescriptor cd)
-
waitForLoadingCoresToFinish
public void waitForLoadingCoresToFinish(long timeoutMs)
-
waitForLoadingCoreToFinish
public void waitForLoadingCoreToFinish(String core, long timeoutMs)
-
isCoreLoading
public boolean isCoreLoading(String name)
-
queueCoreToClose
public void queueCoreToClose(SolrCore coreToClose)
-
-