Package org.apache.solr.core
Class ConfigSetService
- java.lang.Object
-
- org.apache.solr.core.ConfigSetService
-
- Direct Known Subclasses:
FileSystemConfigSetService
,ZkConfigSetService
public abstract class ConfigSetService extends Object
Service class used by the CoreContainer to load ConfigSets for use in SolrCore creation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ConfigSetService.ConfigResource
-
Field Summary
Fields Modifier and Type Field Description protected SolrResourceLoader
parentLoader
static Pattern
UPLOAD_FILENAME_EXCLUDE_PATTERN
static String
UPLOAD_FILENAME_EXCLUDE_REGEX
-
Constructor Summary
Constructors Constructor Description ConfigSetService(SolrResourceLoader loader, boolean shareSchema)
Create a new ConfigSetService
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static void
bootstrapConf(CoreContainer cc)
If in SolrCloud mode, upload configSets for each SolrCore in solr.xml.abstract boolean
checkConfigExists(String configName)
Check whether a config existsabstract String
configSetName(CoreDescriptor cd)
Return a name for the ConfigSet for a core to be used for printing/diagnostic purposes.abstract void
copyConfig(String fromConfig, String toConfig)
Copy a configstatic ConfigSetService
createConfigSetService(CoreContainer coreContainer)
protected abstract SolrResourceLoader
createCoreResourceLoader(CoreDescriptor cd)
Create a SolrResourceLoader for a coreprotected IndexSchema
createIndexSchema(CoreDescriptor cd, SolrConfig solrConfig, boolean forceFetch)
Create an IndexSchema object for a core.protected SolrConfig
createSolrConfig(CoreDescriptor cd, SolrResourceLoader loader, boolean isTrusted)
Create a SolrConfig object for a coreabstract void
deleteConfig(String configName)
Delete a config (recursively deletes its files if not empty)abstract void
deleteFilesFromConfig(String configName, List<String> filesToDelete)
Delete files in configabstract void
downloadConfig(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 nullabstract List<String>
getAllConfigFiles(String configName)
Get the names of the files in config including dirs (mutable, non-null) sorted lexicographically e.g.abstract Map<String,Object>
getConfigMetadata(String configName)
Get the config metadata (mutable, non-null)static Path
getConfigsetPath(String confDir, String configSetDir)
protected abstract Long
getCurrentSchemaModificationVersion(String configSet, SolrConfig solrConfig, String schemaFile)
Returns a modification version for the schema file.static Path
getDefaultConfigDirPath()
Gets the absolute filesystem path of the _default configset to bootstrap from.boolean
isConfigSetTrusted(String name)
Return whether the given configSet is trusted.boolean
isConfigSetTrusted(SolrResourceLoader coreLoader)
Return whether the configSet used for the given resourceLoader is trusted.abstract List<String>
listConfigs()
List the names of configs (non-null)ConfigSet
loadConfigSet(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.abstract void
setConfigMetadata(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 void
uploadConfig(String configName, Path dir)
Upload files from a given path to configabstract void
uploadFileToConfig(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 Detail
-
UPLOAD_FILENAME_EXCLUDE_REGEX
public static final String UPLOAD_FILENAME_EXCLUDE_REGEX
- See Also:
- Constant Field Values
-
UPLOAD_FILENAME_EXCLUDE_PATTERN
public static final Pattern UPLOAD_FILENAME_EXCLUDE_PATTERN
-
parentLoader
protected final SolrResourceLoader parentLoader
-
-
Constructor Detail
-
ConfigSetService
public ConfigSetService(SolrResourceLoader loader, boolean shareSchema)
Create a new ConfigSetService- Parameters:
loader
- the CoreContainer's resource loadershareSchema
- should we share the IndexSchema among cores of same config?
-
-
Method Detail
-
createConfigSetService
public static ConfigSetService createConfigSetService(CoreContainer coreContainer)
-
getDefaultConfigDirPath
public static Path getDefaultConfigDirPath()
Gets the absolute filesystem path of the _default configset to bootstrap from. First tries the sysprop "solr.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:
SolrDispatchFilter.SOLR_DEFAULT_CONFDIR_ATTRIBUTE
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
bootstrapConf
public static void bootstrapConf(CoreContainer cc) throws IOException
If in SolrCloud mode, upload configSets for each SolrCore in solr.xml.- Throws:
IOException
-
isConfigSetTrusted
public boolean isConfigSetTrusted(String name) throws IOException
Return whether the given configSet is trusted.- Parameters:
name
- name of the configSet- Throws:
IOException
-
isConfigSetTrusted
public boolean isConfigSetTrusted(SolrResourceLoader coreLoader) throws IOException
Return whether the configSet used for the given resourceLoader is trusted.- Parameters:
coreLoader
- resourceLoader for a core- Throws:
IOException
-
loadConfigSet
public final ConfigSet loadConfigSet(CoreDescriptor dcore)
Load the ConfigSet for a core- Parameters:
dcore
- the core's CoreDescriptor- Returns:
- a ConfigSet
-
createSolrConfig
protected SolrConfig createSolrConfig(CoreDescriptor cd, SolrResourceLoader loader, boolean isTrusted) throws IOException
Create a SolrConfig object for a core- Parameters:
cd
- the core's CoreDescriptorloader
- the core's resource loaderisTrusted
- is the configset trusted?- 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:
ConfigSetProperties
-
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
protected abstract SolrResourceLoader createCoreResourceLoader(CoreDescriptor cd)
Create a SolrResourceLoader for a core- Parameters:
cd
- the core's CoreDescriptor- Returns:
- a SolrResourceLoader
-
configSetName
public abstract String configSetName(CoreDescriptor cd)
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
public abstract void uploadConfig(String configName, Path dir) throws IOException
Upload files from a given path to config- Parameters:
configName
- the config namedir
-Path
to 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
public abstract void downloadConfig(String configName, Path dir) throws IOException
Download all files from this config to the filesystem at dir- Parameters:
configName
- the config to downloaddir
- thePath
to 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
public abstract void copyConfig(String fromConfig, String toConfig) throws IOException
Copy a config- Parameters:
fromConfig
- the config to copy fromtoConfig
- the config to copy to- Throws:
IOException
-
checkConfigExists
public abstract boolean checkConfigExists(String configName) throws IOException
Check whether a config exists- Parameters:
configName
- the config to check if it exists- Returns:
- whether the config exists or not
- Throws:
IOException
-
deleteConfig
public abstract void deleteConfig(String configName) throws IOException
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
public abstract void setConfigMetadata(String configName, Map<String,Object> data) throws IOException
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 metadata- Parameters:
configName
- the config namedata
- the metadata to be set on config- Throws:
IOException
-
getConfigMetadata
public abstract Map<String,Object> getConfigMetadata(String configName) throws IOException
Get the config metadata (mutable, non-null)- Parameters:
configName
- the config name- Returns:
- the config metadata
- Throws:
IOException
-
listConfigs
public abstract List<String> listConfigs() throws IOException
List the names of configs (non-null)- Returns:
- list of config names
- Throws:
IOException
-
getAllConfigFiles
public abstract List<String> getAllConfigFiles(String configName) throws IOException
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
-
-