Class ConfigSetService

    • Field Detail

      • UPLOAD_FILENAME_EXCLUDE_PATTERN

        public static final Pattern UPLOAD_FILENAME_EXCLUDE_PATTERN
    • Constructor Detail

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

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

        public static Path getConfigsetPath​(String confDir,
                                            String configSetDir)
      • 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 CoreDescriptor
        loader - the core's resource loader
        isTrusted - 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 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
      • 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

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