org.apache.solr.core.snapshots

## Class SolrSnapshotMetaDataManager

- java.lang.Object
- - org.apache.solr.core.snapshots.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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SolrSnapshotMetaDataManager.SnapshotMetaData` A class defining the meta-data for a specific snapshot.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,SolrSnapshotMetaDataManager.SnapshotMetaData>` | `nameToDetailsMapping` Used to map snapshot name to snapshot meta-data.
    `static String` | `SNAPSHOT_METADATA_DIR`
    `static String` | `SNAPSHOTS_PREFIX` Prefix used for the save file.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SolrSnapshotMetaDataManager(SolrCore solrCore, Directory dir)` A constructor.
    `SolrSnapshotMetaDataManager(SolrCore solrCore, Directory dir, IndexWriterConfig.OpenMode mode)` A constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Optional<IndexCommit>` | `getIndexCommitByName(String commitName)` This method returns the IndexCommit associated with the specified `commitName`.
    `Optional<SolrSnapshotMetaDataManager.SnapshotMetaData>` | `getSnapshotMetaData(String name)` This method returns the snapshot meta-data for the specified name (if it exists).
    `Directory` | `getSnapshotsDir()`
    `boolean` | `isSnapshotted(long genNumber)` This method returns if snapshot is created for the specified generation number in the *current* index directory.
    `boolean` | `isSnapshotted(String indexDirPath, long genNumber)` This method returns if snapshot is created for the specified generation number in the specified index directory.
    `List<String>` | `listSnapshots()`
    `Collection<SolrSnapshotMetaDataManager.SnapshotMetaData>` | `listSnapshotsInIndexDir(String indexDirPath)` This method returns a list of snapshots created in a specified index directory.
    `Optional<SolrSnapshotMetaDataManager.SnapshotMetaData>` | `release(String name)` This method deletes a previously created snapshot (if any).
    `void` | `snapshot(String name, String indexDirPath, long gen)` This method creates a new snapshot meta-data entry.

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

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

- - ### Field Detail

    - #### SNAPSHOT_METADATA_DIR

          public static final String SNAPSHOT_METADATA_DIR

      See Also:
        Constant Field Values

    - #### SNAPSHOTS_PREFIX

          public static final String SNAPSHOTS_PREFIX

      Prefix used for the save file.
      See Also:
        Constant Field Values

    - #### nameToDetailsMapping

          protected final Map<String,SolrSnapshotMetaDataManager.SnapshotMetaData> nameToDetailsMapping

      Used to map snapshot name to snapshot meta-data.

  - ### Constructor Detail

    - #### SolrSnapshotMetaDataManager

          public SolrSnapshotMetaDataManager(SolrCore solrCore,
                                             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,
                                             Directory dir,
                                             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 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.

    - #### release

          public Optional<SolrSnapshotMetaDataManager.SnapshotMetaData> release(String name)
                                                                         throws IOException

      This method deletes a previously created snapshot (if any).
      Parameters:
        `name` - The name of the snapshot to be deleted.
      Returns:
        The snapshot meta-data if the snapshot with the snapshot name exists.
      Throws:
        `IOException` - in case of I/O error

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

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