Class CoreContainer
- Since:
- solr 1.3
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected final NodeConfigprotected CollectionsHandlerprotected ConfigSetsHandlerprotected Propertiesstatic final longprotected CoreAdminHandlerprotected final Map<String, CoreContainer.CoreLoadFailure> protected final CoresLocatorprotected HealthCheckHandlerstatic final longstatic final longprotected final SolrResourceLoaderprotected LogWatcher<?> protected SolrMetricManagerprotected MetricsHandlerprotected Stringprotected final SolrNodeKeyPairfinal NodeRolesprotected SecurityConfHandlerprotected ShardHandlerFactoryprotected final Pathprotected SolrMetricsContextprotected io.opentelemetry.api.trace.Tracerfinal Supplier<org.apache.solr.common.cloud.SolrZkClient> Minimize exposure to CoreContainer.protected final ZkContainer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCoreContainer(Object testConstructor) This method allows subclasses to construct a CoreContainer without any default init behavior.CoreContainer(Path solrHome, Properties properties) Create a new CoreContainer using the given solr home directory.CoreContainer(NodeConfig config) Create a new CoreContainer using the given configuration.CoreContainer(NodeConfig config, boolean asyncSolrCoreLoad) CoreContainer(NodeConfig config, CoresLocator locator) Create a new CoreContainer using the given configuration and locator.CoreContainer(NodeConfig config, CoresLocator locator, boolean asyncSolrCoreLoad) -
Method Summary
Modifier and TypeMethodDescriptionvoidassertPathAllowed(Path pathToAssert) Checks that the given path is relative to SOLR_HOME, SOLR_DATA_HOME, coreRootDirectory or one of the paths specified in solr.xml's allowPaths element.voidbooleancheckTragicException(SolrCore solrCore) Checks whether a tragic exception was thrown during update (including update log).Creates a new core in a specified instance directory, publishing the core state to the clusterCreates a new core, publishing the core state to the clusterstatic CoreContainercreateAndLoad(Path solrHome) static CoreContainercreateAndLoad(Path solrHome, Path configFile) Create a new CoreContainer and load its coresprotected <T> TcreateHandler(String path, String handlerClass, Class<T> clazz) org.apache.solr.common.cloud.AliasesRetrieve the aliases from zookeeper.Gets a collection of all the cores that are currently known, whether they are loaded or not.Gets the URLs checker based on theallowUrlsconfiguration of solr.xml.Return the file system paths that should be allowed for various API requests.SolrCache<?, ?> Gets a core by name and increase its refcount.getCoreDescriptor(String coreName) Get the CoreDescriptors for all cores managed by this containerReturns an immutable Map of Exceptions that occurred when initializing SolrCores (either at startup, or do to runtime requests to create cores) keyed off of the name (String) of the SolrCore that had the Exception during initialization.Where cores are created (absolute).getCores()Deprecated.A general-purpose HTTP/2 Solr client.org.glassfish.jersey.server.ApplicationHandlerGets the cores that are currently loaded, i.e.LogWatcher<?> intGets the total number of cores, including both loaded and unloaded cores.org.apache.solr.common.util.ObjectCachePlacementPluginFactory<? extends PlacementPluginConfig> OrderedExecutor<org.apache.lucene.util.BytesRef> getRequestHandler(String path) The default ShardHandlerFactory used to communicate with other solr instancesDeprecated.likely to simply be moved to the ObjectCache so as to not be usedThe primary path of a Solr server's config, cores, and misc things.longio.opentelemetry.api.trace.TracerNever nullA path where Solr users can retrieve arbitrary files from.booleanbooleanisCoreLoading(String name) booleanDetermines whether the core is already loaded or not but does NOT load the corebooleanbooleanbooleanbooleanvoidload()Load the cores defined for this CoreContainernewBackupRepository(String repositoryName) This method instantiates a new instance of BackupRepository.protected SolrCoreregisterCore(CoreDescriptor cd, SolrCore core, boolean registerInZk, boolean skipRecovery) voidreloads a core referreload(String, UUID)for detailsvoidRecreates a SolrCore.voidvoidRun an arbitrary task in its own thread.voidvoidsetCoreConfigService(ConfigSetService configSetService) static voidvoidshutdown()Close / shut down.voidSwaps two SolrCore descriptors.voidUnload a core from this container, leaving all files on diskvoidUnload a core from this container, optionally removing the core's data and configurationvoidwaitForLoadingCore(String name, long timeoutMs) voidwaitForLoadingCoresToFinish(long timeoutMs) If using asyncSolrCoreLoad=true, calling this afterload()will not return until all cores have finished loading.
-
Field Details
-
zkClientSupplier
Minimize exposure to CoreContainer. Mostly only ZK interface is required -
coreInitFailures
-
coreAdminHandler
-
collectionsHandler
-
healthCheckHandler
-
configSetsHandler
-
containerProperties
-
zkSys
-
shardHandlerFactory
-
logging
-
cfg
-
loader
-
solrHome
-
nodeKeyPair
-
coresLocator
-
securityConfHandler
-
metricManager
-
metricTag
-
solrMetricsContext
-
tracer
protected volatile io.opentelemetry.api.trace.Tracer tracer -
metricsHandler
-
nodeRoles
-
LOAD_COMPLETE
public static final long LOAD_COMPLETE- See Also:
-
CORE_DISCOVERY_COMPLETE
public static final long CORE_DISCOVERY_COMPLETE- See Also:
-
INITIAL_CORE_LOAD_COMPLETE
public static final long INITIAL_CORE_LOAD_COMPLETE- See Also:
-
ALLOW_PATHS_SYSPROP
- See Also:
-
-
Constructor Details
-
CoreContainer
Create a new CoreContainer using the given solr home directory. The container's cores are not loaded.- Parameters:
solrHome- a String containing the path to the solr home directoryproperties- substitutable properties (alternative to Sys props)- See Also:
-
CoreContainer
Create a new CoreContainer using the given configuration. The container's cores are not loaded.- Parameters:
config- a ConfigSolr representation of this container's configuration- See Also:
-
CoreContainer
-
CoreContainer
Create a new CoreContainer using the given configuration and locator.The container's cores are not loaded. This constructor should be used only in tests, as it overrides
CoresLocator's instantiation process.- Parameters:
config- a ConfigSolr representation of this container's configurationlocator- a CoresLocator- See Also:
-
CoreContainer
-
CoreContainer
This method allows subclasses to construct a CoreContainer without any default init behavior.- Parameters:
testConstructor- pass (Object)null.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Method Details
-
getIndexSearcherExecutor
-
getIndexFingerprintExecutor
-
getJerseyApplicationHandler
public org.glassfish.jersey.server.ApplicationHandler getJerseyApplicationHandler() -
getJerseyAppHandlerCache
-
newBackupRepository
This method instantiates a new instance of BackupRepository.- Parameters:
repositoryName- The name of the backup repository (Optional). If not specified, a default implementation is used.- Returns:
- a new instance of BackupRepository.
-
getCoreZkRegisterExecutorService
-
getRequestHandler
-
getRequestHandlers
-
createAndLoad
-
createAndLoad
Create a new CoreContainer and load its cores- Parameters:
solrHome- the solr home directoryconfigFile- the file containing this container's configuration- Returns:
- a loaded CoreContainer
-
getContainerProperties
-
getPkiAuthenticationSecurityBuilder
-
getMetricManager
-
getMetricsHandler
-
getTracer
public io.opentelemetry.api.trace.Tracer getTracer()Never null -
getReplayUpdatesExecutor
-
getPackageLoader
-
getFileStore
-
getCache
-
getSolrClientCache
Deprecated.likely to simply be moved to the ObjectCache so as to not be usedTheSolrClientCacheis mostly for streaming expressions. Prefer other clients for other use-cases.- See Also:
-
getObjectCache
public org.apache.solr.common.util.ObjectCache getObjectCache() -
load
public void load()Load the cores defined for this CoreContainer -
securityNodeChanged
public void securityNodeChanged() -
getGpuMetricsProvider
-
isShutDown
public boolean isShutDown() -
shutdown
public void shutdown()Close / shut down. Only called byCoreContainerProvider. -
cancelCoreRecoveries
public void cancelCoreRecoveries() -
getCoresLocator
-
getCoreSorter
-
registerCore
protected SolrCore registerCore(CoreDescriptor cd, SolrCore core, boolean registerInZk, boolean skipRecovery) -
create
Creates a new core, publishing the core state to the cluster- Parameters:
coreName- the core nameparameters- the core parameters- Returns:
- the newly created core
-
create
public SolrCore create(String coreName, Path instancePath, Map<String, String> parameters, boolean newCollection) Creates a new core in a specified instance directory, publishing the core state to the cluster- Parameters:
coreName- the core nameinstancePath- the instance directoryparameters- the core parameters- Returns:
- the newly created core
-
assertPathAllowed
Checks that the given path is relative to SOLR_HOME, SOLR_DATA_HOME, coreRootDirectory or one of the paths specified in solr.xml's allowPaths element. Delegates toSolrPaths.assertPathAllowed(Path, Set)- Parameters:
pathToAssert- path to check- Throws:
org.apache.solr.common.SolrException- if path is outside allowed paths
-
getAllowPaths
Return the file system paths that should be allowed for various API requests. This list is compiled at startup from SOLR_HOME, SOLR_DATA_HOME and theallowPathsconfiguration of solr.xml. These paths are used by theassertPathAllowed(Path)method call.NOTE: This method is currently only in use in tests in order to modify the mutable Set directly. Please treat this as a private method.
-
getAllowListUrlChecker
Gets the URLs checker based on theallowUrlsconfiguration of solr.xml. -
getCores
Deprecated.Gets all loaded cores, consistent withgetLoadedCoreNames(). Caller doesn't need to close.NOTE: rather dangerous API because each core is not reserved (could in theory be closed). Prefer
getLoadedCoreNames()and then callgetCore(String)then close it.- Returns:
- An unsorted list. This list is a new copy, it can be modified by the caller (e.g. it can be sorted). Don't need to close them.
-
getLoadedCoreNames
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.For efficiency, prefer to check
isLoaded(String)instead ofgetLoadedCoreNames().contains(coreName).- Returns:
- An unsorted list. This list is a new copy, it can be modified by the caller (e.g. it can be sorted).
-
getAllCoreNames
Gets a collection of all the cores that are currently known, whether they are loaded or not.For efficiency, prefer to check
getCoreDescriptor(String)!= null instead ofgetAllCoreNames().contains(coreName).- Returns:
- An unsorted list. This list is a new copy, it can be modified by the caller (e.g. it can be sorted).
-
getNumAllCores
public int getNumAllCores()Gets the total number of cores, including both loaded and unloaded cores. Faster equivalent togetAllCoreNames().size(). -
getCoreInitFailures
Returns an immutable Map of Exceptions that occurred when initializing SolrCores (either at startup, or do to runtime requests to create cores) keyed off of the name (String) of the SolrCore that had the Exception during initialization.While the Map returned by this method is immutable and will not change once returned to the client, the source data used to generate this Map can be changed as various SolrCore operations are performed:
- Failed attempts to create new SolrCores will add new Exceptions.
- Failed attempts to re-create a SolrCore using a name already contained in this Map will replace the Exception.
- Failed attempts to reload a SolrCore will cause an Exception to be added to this list -- even though the existing SolrCore with that name will continue to be available.
- Successful attempts to re-created a SolrCore using a name already contained in this Map will remove the Exception.
- Registering an existing SolrCore with a name already contained in this Map (ie: ALIAS or SWAP) will remove the Exception.
-
reload
reloads a core referreload(String, UUID)for details -
reload
Recreates a SolrCore. While the new core is loading, requests will continue to be dispatched to and processed by the old core- Parameters:
name- the name of the SolrCore to reloadcoreId- The unique Id of the coreSolrCore.uniqueId. If this is null, it's reloaded anyway. If the current core has a different id, this is a no-op
-
swap
Swaps two SolrCore descriptors. -
unload
Unload a core from this container, leaving all files on disk- Parameters:
name- the name of the core to unload
-
unload
public void unload(String name, boolean deleteIndexDir, boolean deleteDataDir, boolean deleteInstanceDir) Unload a core from this container, optionally removing the core's data and configuration- Parameters:
name- the name of the core to unloaddeleteIndexDir- if true, delete the core's index on closedeleteDataDir- if true, delete the core's data directory on closedeleteInstanceDir- if true, delete the core's instance directory on close
-
rename
-
getCoreDescriptors
Get the CoreDescriptors for all cores managed by this container- Returns:
- a List of CoreDescriptors
-
getCoreDescriptor
-
getCoreRootDirectory
Where cores are created (absolute). -
getCore
-
getCore
Gets a core by name and increase its refcount.- Parameters:
name- the core name- Returns:
- the core if found, null if a SolrCore by this name does not exist
- Throws:
SolrCoreInitializationException- if a SolrCore with this name failed to be initialized- See Also:
-
waitForLoadingCoresToFinish
public void waitForLoadingCoresToFinish(long timeoutMs) If using asyncSolrCoreLoad=true, calling this afterload()will not return until all cores have finished loading.- Parameters:
timeoutMs- timeout, upon which method simply returns
-
waitForLoadingCore
-
createHandler
-
getMultiCoreHandler
-
getCollectionsHandler
-
getHealthCheckHandler
-
getInfoHandler
-
getConfigSetsHandler
-
getConfigSetService
-
setCoreConfigService
-
getHostName
-
getLogging
-
isLoaded
Determines whether the core is already loaded or not but does NOT load the core -
getSolrHome
The primary path of a Solr server's config, cores, and misc things. Absolute. -
getUserFilesPath
A path where Solr users can retrieve arbitrary files from. Absolute.Files located in this directory can be manipulated using select Solr features (e.g. streaming expressions).
-
isZooKeeperAware
public boolean isZooKeeperAware() -
getZkController
-
getConfig
-
getShardHandlerFactory
The default ShardHandlerFactory used to communicate with other solr instances -
getUpdateShardHandler
-
getResourceLoader
-
isCoreLoading
-
getAuthorizationPlugin
-
getAuthenticationPlugin
-
getAuditLoggerPlugin
-
getNodeConfig
-
getStatus
public long getStatus() -
isStatusLoadComplete
public boolean isStatusLoadComplete() -
hideStackTrace
public boolean hideStackTrace() -
getAliases
public org.apache.solr.common.cloud.Aliases getAliases()Retrieve the aliases from zookeeper. This is typically cached and does not hit zookeeper after the first use.- Returns:
- an immutable instance of
Aliasesaccurate as of at the time this method is invoked, less any zookeeper update lag. - Throws:
RuntimeException- if invoked on aCoreContainerwhereisZooKeeperAware()returns false
-
checkTragicException
Checks whether a tragic exception was thrown during update (including update log).- Parameters:
solrCore- the core against which we check if there has been a tragic exception- Returns:
- whether this Solr core has tragic exception
- See Also:
-
getContainerPluginsRegistry
-
getClusterSingletons
-
getClusterEventProducer
-
getPlacementPluginFactory
-
getDefaultHttpSolrClient
A general-purpose HTTP/2 Solr client.The caller does not need to close the client.
- Returns:
- the existing
HttpJettySolrClient - See Also:
-
runAsync
Run an arbitrary task in its own thread. This is an expert option and is a method you should use with great care. It would be bad to run something that never stopped or run something that took a very long time. Typically this is intended for actions that take a few seconds, and therefore would be bad to wait for within a request, or actions that need to happen when a core has zero references, but would not pose a significant hindrance to server shut down times. It is not intended for long-running tasks and if you are using a Runnable with a loop in it, you are almost certainly doing it wrong.
WARNING: Solr wil not be able to shut down gracefully until this task completes!
A significant upside of using this method vs creating your own ExecutorService is that your code does not have to properly shutdown executors which typically is risky from a unit testing perspective since the test framework will complain if you don't carefully ensure the executor shuts down before the end of the test. Also the threads running this task are sure to have a proper MDC for logging.
Normally, one usesSolrCore.runAsync(Runnable)if possible, but in some cases you might need to execute a task asynchronously when you could be running on a node with no cores, and then use of this method is indicated.- Parameters:
r- the task to run
-
setWeakStringInterner
public static void setWeakStringInterner()
-