Class SolrSnapshotMetaDataManager


  • public class SolrSnapshotMetaDataManager
    extends Object
    This class is responsible to manage the persistent snapshots meta-data for the Solr indexes. The persistent snapshots are implemented by relying on Lucene IndexDeletionPolicy abstraction to configure a specific IndexCommit to be retained. The IndexDeletionPolicyWrapper in Solr uses this class to create/delete the Solr index snapshots.
    • Constructor Detail

      • SolrSnapshotMetaDataManager

        public SolrSnapshotMetaDataManager​(SolrCore solrCore,
                                           org.apache.lucene.store.Directory dir)
                                    throws IOException
        A constructor.
        Parameters:
        dir - The directory where the snapshot meta-data should be stored. Enables updating the existing meta-data.
        Throws:
        IOException - in case of errors.
      • SolrSnapshotMetaDataManager

        public SolrSnapshotMetaDataManager​(SolrCore solrCore,
                                           org.apache.lucene.store.Directory dir,
                                           org.apache.lucene.index.IndexWriterConfig.OpenMode mode)
                                    throws IOException
        A constructor.
        Parameters:
        dir - The directory where the snapshot meta-data is stored.
        mode - CREATE If previous meta-data should be erased. APPEND If previous meta-data should be read and updated. CREATE_OR_APPEND Creates a new meta-data structure if one does not exist Updates the existing structure if one exists.
        Throws:
        IOException - in case of errors.
    • Method Detail

      • getSnapshotsDir

        public org.apache.lucene.store.Directory getSnapshotsDir()
        Returns:
        The snapshot meta-data directory
      • snapshot

        public void snapshot​(String name,
                             String indexDirPath,
                             long gen)
                      throws IOException
        This method creates a new snapshot meta-data entry.
        Parameters:
        name - The name of the snapshot.
        indexDirPath - The directory path where the index files are stored.
        gen - The generation number for the IndexCommit being snapshotted.
        Throws:
        IOException - in case of I/O errors.
      • isSnapshotted

        public boolean isSnapshotted​(long genNumber)
        This method returns if snapshot is created for the specified generation number in the *current* index directory.
        Parameters:
        genNumber - The generation number for the IndexCommit to be checked.
        Returns:
        true if the snapshot is created. false otherwise.
      • isSnapshotted

        public boolean isSnapshotted​(String indexDirPath,
                                     long genNumber)
        This method returns if snapshot is created for the specified generation number in the specified index directory.
        Parameters:
        genNumber - The generation number for the IndexCommit to be checked.
        Returns:
        true if the snapshot is created. false otherwise.
      • getSnapshotMetaData

        public Optional<SolrSnapshotMetaDataManager.SnapshotMetaData> getSnapshotMetaData​(String name)
        This method returns the snapshot meta-data for the specified name (if it exists).
        Parameters:
        name - The name of the snapshot
        Returns:
        The snapshot meta-data if exists.
      • listSnapshots

        public List<String> listSnapshots()
        Returns:
        A list of snapshots created so far.
      • listSnapshotsInIndexDir

        public Collection<SolrSnapshotMetaDataManager.SnapshotMetaData> listSnapshotsInIndexDir​(String indexDirPath)
        This method returns a list of snapshots created in a specified index directory.
        Parameters:
        indexDirPath - The index directory path.
        Returns:
        a list snapshots stored in the specified directory.
      • getIndexCommitByName

        public Optional<org.apache.lucene.index.IndexCommit> getIndexCommitByName​(String commitName)
                                                                           throws IOException
        This method returns the IndexCommit associated with the specified commitName . A snapshot with specified commitName must be created before invoking this method.
        Parameters:
        commitName - The name of persisted commit
        Returns:
        the IndexCommit
        Throws:
        IOException - in case of I/O error.