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/managesSolrCore
s withinCoreContainer
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Object
modifyLock
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addCoreDescriptor(CoreDescriptor p)
protected void
close()
List<String>
getAllCoreNames()
Gets a collection of all cores names, loaded and unloaded.CoreDescriptor
getCoreDescriptor(String coreName)
Return the CoreDescriptor corresponding to a given core name.List<CoreDescriptor>
getCoreDescriptors()
Get the CoreDescriptors for everySolrCore
managed here (permanent and transient, loaded and unloaded).SolrCore
getCoreFromAnyList(String name, boolean incRefCount)
SolrCore
getCoreFromAnyList(String name, boolean incRefCount, UUID coreId)
List<SolrCore>
getCores()
Deprecated.SolrCore
getCoreToClose()
List<String>
getLoadedCoreNames()
Gets the cores that are currently loaded, i.e.protected SolrCore
getLoadedCoreWithoutIncrement(String name)
(internal) Return a core that is already loaded, if it is.Object
getModifyLock()
int
getNumAllCores()
Gets the total number of cores, including permanent and transient cores, loaded and unloaded cores.int
getNumLoadedPermanentCores()
Gets the number of currently loaded permanent (non transient) cores.int
getNumLoadedTransientCores()
Gets the number of currently loaded transient cores.int
getNumUnloadedCores()
Gets the number of unloaded cores, including permanent and transient cores.protected boolean
hasPendingCoreOps(String name)
The core is currently loading, unloading, or reloading.boolean
isCoreLoading(String name)
boolean
isLoaded(String name)
boolean
isLoadedNotPendingClose(String name)
void
markCoreAsLoading(CoreDescriptor cd)
void
markCoreAsNotLoading(CoreDescriptor cd)
static SolrCores
newSolrCores(CoreContainer coreContainer)
SolrCore
putCore(CoreDescriptor cd, SolrCore core)
void
queueCoreToClose(SolrCore coreToClose)
SolrCore
remove(String name)
void
removeCoreDescriptor(CoreDescriptor p)
void
removeFromPendingOps(String name)
void
swap(String n0, String n1)
SolrCore
waitAddPendingCoreOps(String name)
void
waitForLoadingCoresToFinish(long timeoutMs)
void
waitForLoadingCoreToFinish(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 everySolrCore
managed 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)
-
-