Package org.apache.solr.core
Class ConfigSetService
java.lang.Object
org.apache.solr.core.ConfigSetService
- Direct Known Subclasses:
FileSystemConfigSetService,ZkConfigSetService
Service class used by the CoreContainer to load ConfigSets for use in SolrCore creation.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SolrResourceLoaderstatic final Patternstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionConfigSetService(SolrResourceLoader loader, boolean shareSchema) Create a new ConfigSetService -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancheckConfigExists(String configName) Check whether a config existsabstract StringReturn a name for the ConfigSet for a core to be used for printing/diagnostic purposes.abstract voidcopyConfig(String fromConfig, String toConfig) Copy a configstatic ConfigSetServicecreateConfigSetService(CoreContainer coreContainer) protected abstract SolrResourceLoaderCreate a SolrResourceLoader for a coreprotected IndexSchemacreateIndexSchema(CoreDescriptor cd, SolrConfig solrConfig, boolean forceFetch) Create an IndexSchema object for a core.protected SolrConfigcreateSolrConfig(CoreDescriptor cd, SolrResourceLoader loader) Create a SolrConfig object for a coreabstract voiddeleteConfig(String configName) Delete a config (recursively deletes its files if not empty)abstract voiddeleteFilesFromConfig(String configName, List<String> filesToDelete) Delete files in configabstract voiddownloadConfig(String configName, Path dir) Download all files from this config to the filesystem at dirabstract byte[]downloadFileFromConfig(String configName, String filePath) Download a file from config If the file does not exist, it returns nullgetAllConfigFiles(String configName) Get the names of the files in config including dirs (mutable, non-null) sorted lexicographically e.g.getConfigMetadata(String configName) Get the config metadata (mutable, non-null)static PathgetConfigsetPath(String confDir, String configSetDir) protected abstract LonggetCurrentSchemaModificationVersion(String configSet, SolrConfig solrConfig, String schemaFile) Returns a modification version for the schema file.static PathGets the absolute filesystem path of the _default configset to bootstrap from.List the names of configs (non-null)final ConfigSetloadConfigSet(CoreDescriptor dcore) Load the ConfigSet for a coreprotected org.apache.solr.common.util.NamedList<Object> loadConfigSetFlags(SolrResourceLoader loader) Return the ConfigSet flags or null if none.protected org.apache.solr.common.util.NamedList<Object> loadConfigSetProperties(CoreDescriptor cd, SolrResourceLoader loader) Return the ConfigSet properties or null if none.protected abstract voidsetConfigMetadata(String configName, Map<String, Object> data) Set the config metadata If config does not exist, it will be created and set metadata on it Else metadata will be replaced with the provided metadataabstract voiduploadConfig(String configName, Path dir) Upload files from a given path to configabstract voiduploadFileToConfig(String configName, String fileName, byte[] data, boolean overwriteOnExists) Upload a file to config If file does not exist, it will be uploaded If overwriteOnExists is set to true then file will be overwritten
-
Field Details
-
UPLOAD_FILENAME_EXCLUDE_REGEX
- See Also:
-
UPLOAD_FILENAME_EXCLUDE_PATTERN
-
parentLoader
-
-
Constructor Details
-
ConfigSetService
Create a new ConfigSetService- Parameters:
loader- the CoreContainer's resource loadershareSchema- should we share the IndexSchema among cores of same config?
-
-
Method Details
-
createConfigSetService
-
getDefaultConfigDirPath
Gets the absolute filesystem path of the _default configset to bootstrap from. First tries the sysprop "solr.configset.default.confdir". If not found, tries to find the _default dir relative to the sysprop "solr.install.dir". Returns null if not found anywhere.- See Also:
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
getConfigsetPath
-
loadConfigSet
Load the ConfigSet for a core- Parameters:
dcore- the core's CoreDescriptor- Returns:
- a ConfigSet
-
createSolrConfig
protected SolrConfig createSolrConfig(CoreDescriptor cd, SolrResourceLoader loader) throws IOException Create a SolrConfig object for a core- Parameters:
cd- the core's CoreDescriptorloader- the core's resource loader- Returns:
- a SolrConfig object
- Throws:
IOException
-
createIndexSchema
protected IndexSchema createIndexSchema(CoreDescriptor cd, SolrConfig solrConfig, boolean forceFetch) throws IOException Create an IndexSchema object for a core. It might be a cached lookup.- Parameters:
cd- the core's CoreDescriptorsolrConfig- the core's SolrConfig- Returns:
- an IndexSchema
- Throws:
IOException
-
getCurrentSchemaModificationVersion
protected abstract Long getCurrentSchemaModificationVersion(String configSet, SolrConfig solrConfig, String schemaFile) throws IOException Returns a modification version for the schema file. Null may be returned if not known, and if so it defeats schema caching.- Throws:
IOException
-
loadConfigSetProperties
protected org.apache.solr.common.util.NamedList<Object> loadConfigSetProperties(CoreDescriptor cd, SolrResourceLoader loader) throws IOException Return the ConfigSet properties or null if none.- Parameters:
cd- the core's CoreDescriptorloader- the core's resource loader- Returns:
- the ConfigSet properties
- Throws:
IOException- See Also:
-
loadConfigSetFlags
protected org.apache.solr.common.util.NamedList<Object> loadConfigSetFlags(SolrResourceLoader loader) throws IOException Return the ConfigSet flags or null if none.- Throws:
IOException
-
createCoreResourceLoader
Create a SolrResourceLoader for a core- Parameters:
cd- the core's CoreDescriptor- Returns:
- a SolrResourceLoader
-
configSetName
Return a name for the ConfigSet for a core to be used for printing/diagnostic purposes.- Parameters:
cd- the core's CoreDescriptor- Returns:
- a name for the core's ConfigSet
-
uploadConfig
Upload files from a given path to config- Parameters:
configName- the config namedir-Pathto the files- Throws:
IOException- if an I/O error occurs or the path does not exist
-
uploadFileToConfig
public abstract void uploadFileToConfig(String configName, String fileName, byte[] data, boolean overwriteOnExists) throws IOException Upload a file to config If file does not exist, it will be uploaded If overwriteOnExists is set to true then file will be overwritten- Parameters:
configName- the name to give the configfileName- the name of the file with '/' used as the file path separatordata- the content of the fileoverwriteOnExists- if true then file will be overwritten- Throws:
org.apache.solr.common.SolrException- if file exists and overwriteOnExists == falseIOException
-
downloadConfig
Download all files from this config to the filesystem at dir- Parameters:
configName- the config to downloaddir- thePathto write files under- Throws:
IOException
-
downloadFileFromConfig
public abstract byte[] downloadFileFromConfig(String configName, String filePath) throws IOException Download a file from config If the file does not exist, it returns null- Parameters:
configName- the name of the configfilePath- the file to download with '/' as the separator- Returns:
- the content of the file
- Throws:
IOException
-
copyConfig
Copy a config- Parameters:
fromConfig- the config to copy fromtoConfig- the config to copy to- Throws:
IOException
-
checkConfigExists
Check whether a config exists- Parameters:
configName- the config to check if it exists- Returns:
- whether the config exists or not
- Throws:
IOException
-
deleteConfig
Delete a config (recursively deletes its files if not empty)- Parameters:
configName- the config to delete- Throws:
IOException
-
deleteFilesFromConfig
public abstract void deleteFilesFromConfig(String configName, List<String> filesToDelete) throws IOException Delete files in config- Parameters:
configName- the name of the configfilesToDelete- a list of file paths to delete using '/' as file path separator- Throws:
IOException
-
setConfigMetadata
protected abstract void setConfigMetadata(String configName, Map<String, Object> data) throws IOExceptionSet the config metadata If config does not exist, it will be created and set metadata on it Else metadata will be replaced with the provided metadata- Parameters:
configName- the config namedata- the metadata to be set on config- Throws:
IOException
-
getConfigMetadata
Get the config metadata (mutable, non-null)- Parameters:
configName- the config name- Returns:
- the config metadata
- Throws:
IOException
-
listConfigs
List the names of configs (non-null)- Returns:
- list of config names
- Throws:
IOException
-
getAllConfigFiles
Get the names of the files in config including dirs (mutable, non-null) sorted lexicographically e.g. solrconfig.xml, lang/, lang/stopwords_en.txt- Parameters:
configName- the config name- Returns:
- list of file name paths in the config with '/' uses as file path separators
- Throws:
IOException
-