Class SolrSnapshotManager


  • public class SolrSnapshotManager
    extends Object
    This class provides functionality required to handle the data files corresponding to Solr snapshots.
    • Constructor Detail

      • SolrSnapshotManager

        public SolrSnapshotManager()
    • Method Detail

      • snapshotExists

        public static boolean snapshotExists​(org.apache.solr.common.cloud.SolrZkClient zkClient,
                                             String collectionName,
                                             String commitName)
                                      throws org.apache.zookeeper.KeeperException,
                                             InterruptedException
        This method returns if a named snapshot exists for the specified collection.
        Parameters:
        zkClient - Zookeeper client
        collectionName - The name of the collection
        commitName - The name of the snapshot
        Returns:
        true if the named snapshot exists false Otherwise
        Throws:
        org.apache.zookeeper.KeeperException - In case of Zookeeper error
        InterruptedException - In case of thread interruption.
      • createCollectionLevelSnapshot

        public static void createCollectionLevelSnapshot​(org.apache.solr.common.cloud.SolrZkClient zkClient,
                                                         String collectionName,
                                                         CollectionSnapshotMetaData meta)
                                                  throws org.apache.zookeeper.KeeperException,
                                                         InterruptedException
        This method creates an entry for the named snapshot for the specified collection in Zookeeper.
        Parameters:
        zkClient - Zookeeper client
        collectionName - The name of the collection
        meta - The CollectionSnapshotMetaData corresponding to named snapshot
        Throws:
        org.apache.zookeeper.KeeperException - In case of Zookeeper error
        InterruptedException - In case of thread interruption.
      • updateCollectionLevelSnapshot

        public static void updateCollectionLevelSnapshot​(org.apache.solr.common.cloud.SolrZkClient zkClient,
                                                         String collectionName,
                                                         CollectionSnapshotMetaData meta)
                                                  throws org.apache.zookeeper.KeeperException,
                                                         InterruptedException
        This method updates an entry for the named snapshot for the specified collection in Zookeeper.
        Parameters:
        zkClient - Zookeeper client
        collectionName - The name of the collection
        meta - The CollectionSnapshotMetaData corresponding to named snapshot
        Throws:
        org.apache.zookeeper.KeeperException - In case of Zookeeper error
        InterruptedException - In case of thread interruption.
      • deleteCollectionLevelSnapshot

        public static void deleteCollectionLevelSnapshot​(org.apache.solr.common.cloud.SolrZkClient zkClient,
                                                         String collectionName,
                                                         String commitName)
                                                  throws InterruptedException,
                                                         org.apache.zookeeper.KeeperException
        This method deletes an entry for the named snapshot for the specified collection in Zookeeper.
        Parameters:
        zkClient - Zookeeper client
        collectionName - The name of the collection
        commitName - The name of the snapshot
        Throws:
        InterruptedException - In case of thread interruption.
        org.apache.zookeeper.KeeperException - In case of Zookeeper error
      • cleanupCollectionLevelSnapshots

        public static void cleanupCollectionLevelSnapshots​(org.apache.solr.common.cloud.SolrZkClient zkClient,
                                                           String collectionName)
                                                    throws InterruptedException,
                                                           org.apache.zookeeper.KeeperException
        This method deletes all snapshots for the specified collection in Zookeeper.
        Parameters:
        zkClient - Zookeeper client
        collectionName - The name of the collection
        Throws:
        InterruptedException - In case of thread interruption.
        org.apache.zookeeper.KeeperException - In case of Zookeeper error
      • getCollectionLevelSnapshot

        public static Optional<CollectionSnapshotMetaData> getCollectionLevelSnapshot​(org.apache.solr.common.cloud.SolrZkClient zkClient,
                                                                                      String collectionName,
                                                                                      String commitName)
                                                                               throws InterruptedException,
                                                                                      org.apache.zookeeper.KeeperException
        This method returns the CollectionSnapshotMetaData for the named snapshot for the specified collection in Zookeeper.
        Parameters:
        zkClient - Zookeeper client
        collectionName - The name of the collection
        commitName - The name of the snapshot
        Returns:
        (Optional) the CollectionSnapshotMetaData
        Throws:
        InterruptedException - In case of thread interruption.
        org.apache.zookeeper.KeeperException - In case of Zookeeper error
      • deleteSnapshotIndexFiles

        public static void deleteSnapshotIndexFiles​(SolrCore core,
                                                    org.apache.lucene.store.Directory dir,
                                                    long gen)
                                             throws IOException
        This method deletes index files of the IndexCommit for the specified generation number.
        Parameters:
        core - The Solr core
        dir - The index directory storing the snapshot.
        gen - The generation number of the IndexCommit to be deleted.
        Throws:
        IOException - in case of I/O errors.
      • deleteNonSnapshotIndexFiles

        public static void deleteNonSnapshotIndexFiles​(SolrCore core,
                                                       org.apache.lucene.store.Directory dir,
                                                       Collection<SolrSnapshotMetaDataManager.SnapshotMetaData> snapshots)
                                                throws IOException
        This method deletes index files not associated with the specified snapshots.
        Parameters:
        core - The Solr core
        dir - The index directory storing the snapshot.
        snapshots - The snapshots to be preserved.
        Throws:
        IOException - in case of I/O errors.