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.
  • Field Details

    • UPLOAD_FILENAME_EXCLUDE_REGEX

      public static final String UPLOAD_FILENAME_EXCLUDE_REGEX
      See Also:
    • UPLOAD_FILENAME_EXCLUDE_PATTERN

      public static final Pattern UPLOAD_FILENAME_EXCLUDE_PATTERN
    • parentLoader

      protected final SolrResourceLoader parentLoader
  • Constructor Details

    • ConfigSetService

      public ConfigSetService(SolrResourceLoader loader, boolean shareSchema)
      Create a new ConfigSetService
      Parameters:
      loader - the CoreContainer's resource loader
      shareSchema - should we share the IndexSchema among cores of same config?
  • Method Details

    • 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.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

      public static Path getConfigsetPath(String confDir, String configSetDir)
    • 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) throws IOException
      Create a SolrConfig object for a core
      Parameters:
      cd - the core's CoreDescriptor
      loader - 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 CoreDescriptor
      solrConfig - 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 CoreDescriptor
      loader - 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

      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 name
      dir - 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 config
      fileName - the name of the file with '/' used as the file path separator
      data - the content of the file
      overwriteOnExists - if true then file will be overwritten
      Throws:
      org.apache.solr.common.SolrException - if file exists and overwriteOnExists == false
      IOException
    • 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 download
      dir - the Path 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 config
      filePath - 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 from
      toConfig - 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 config
      filesToDelete - 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 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 name
      data - 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