org.apache.solr.core.snapshots

## Class SolrSnapshotManager

- java.lang.Object
- - org.apache.solr.core.snapshots.SolrSnapshotManager

-     public class SolrSnapshotManager
      extends Object

  This class provides functionality required to handle the data files corresponding to Solr snapshots.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CREATION_DATE`
    `static String` | `FILE_LIST`
    `static String` | `GENERATION_NUM`
    `static String` | `INDEX_DIR_PATH`
    `static String` | `LEADER`
    `static String` | `SHARD_ID`
    `static String` | `SNAPSHOT_REPLICAS`
    `static String` | `SNAPSHOT_STATUS`
    `static String` | `SNAPSHOTS_INFO`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SolrSnapshotManager()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `cleanupCollectionLevelSnapshots(SolrZkClient zkClient, String collectionName)` This method deletes all snapshots for the specified collection in Zookeeper.
    `static void` | `createCollectionLevelSnapshot(SolrZkClient zkClient, String collectionName, CollectionSnapshotMetaData meta)` This method creates an entry for the named snapshot for the specified collection in Zookeeper.
    `static void` | `deleteCollectionLevelSnapshot(SolrZkClient zkClient, String collectionName, String commitName)` This method deletes an entry for the named snapshot for the specified collection in Zookeeper.
    `static void` | `deleteNonSnapshotIndexFiles(SolrCore core, Directory dir, Collection<SolrSnapshotMetaDataManager.SnapshotMetaData> snapshots)` This method deletes index files not associated with the specified `snapshots`.
    `static void` | `deleteSnapshotIndexFiles(SolrCore core, Directory dir, long gen)` This method deletes index files of the IndexCommit for the specified generation number.
    `static Optional<CollectionSnapshotMetaData>` | `getCollectionLevelSnapshot(SolrZkClient zkClient, String collectionName, String commitName)` This method returns the CollectionSnapshotMetaData for the named snapshot for the specified collection in Zookeeper.
    `static Collection<CollectionSnapshotMetaData>` | `listSnapshots(SolrZkClient zkClient, String collectionName)` This method returns the CollectionSnapshotMetaData for each named snapshot for the specified collection in Zookeeper.
    `static boolean` | `snapshotExists(SolrZkClient zkClient, String collectionName, String commitName)` This method returns if a named snapshot exists for the specified collection.
    `static void` | `updateCollectionLevelSnapshot(SolrZkClient zkClient, String collectionName, CollectionSnapshotMetaData meta)` This method updates an entry for the named snapshot for the specified collection in Zookeeper.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INDEX_DIR_PATH

          public static final String INDEX_DIR_PATH

      See Also:
        Constant Field Values

    - #### GENERATION_NUM

          public static final String GENERATION_NUM

      See Also:
        Constant Field Values

    - #### SNAPSHOT_STATUS

          public static final String SNAPSHOT_STATUS

      See Also:
        Constant Field Values

    - #### CREATION_DATE

          public static final String CREATION_DATE

      See Also:
        Constant Field Values

    - #### SNAPSHOT_REPLICAS

          public static final String SNAPSHOT_REPLICAS

      See Also:
        Constant Field Values

    - #### SNAPSHOTS_INFO

          public static final String SNAPSHOTS_INFO

      See Also:
        Constant Field Values

    - #### LEADER

          public static final String LEADER

      See Also:
        Constant Field Values

    - #### SHARD_ID

          public static final String SHARD_ID

      See Also:
        Constant Field Values

    - #### FILE_LIST

          public static final String FILE_LIST

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SolrSnapshotManager

          public SolrSnapshotManager()

  - ### Method Detail

    - #### snapshotExists

          public static boolean snapshotExists(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(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(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(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(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(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

    - #### listSnapshots

          public static Collection<CollectionSnapshotMetaData> listSnapshots(SolrZkClient zkClient,
                                                                             String collectionName)
                                                                      throws InterruptedException,
                                                                             org.apache.zookeeper.KeeperException

      This method returns the CollectionSnapshotMetaData for each named snapshot for the specified collection in Zookeeper.
      Parameters:
        `zkClient` - Zookeeper client
        `collectionName` - The name of the collection
      Returns:
        the CollectionSnapshotMetaData for each named snapshot
      Throws:
        `InterruptedException` - In case of thread interruption.
        `org.apache.zookeeper.KeeperException` - In case of Zookeeper error

    - #### deleteSnapshotIndexFiles

          public static void deleteSnapshotIndexFiles(SolrCore core,
                                                      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,
                                                         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.

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.