Package org.apache.solr.core.snapshots
Class SolrSnapshotMetaDataManager
java.lang.Object
org.apache.solr.core.snapshots.SolrSnapshotMetaDataManager
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 ClassesModifier and TypeClassDescriptionstatic classA class defining the meta-data for a specific snapshot. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String, SolrSnapshotMetaDataManager.SnapshotMetaData> Used to map snapshot name to snapshot meta-data.static final Stringstatic final StringPrefix used for the save file. -
Constructor Summary
ConstructorsConstructorDescriptionSolrSnapshotMetaDataManager(SolrCore solrCore, org.apache.lucene.store.Directory dir) A constructor.SolrSnapshotMetaDataManager(SolrCore solrCore, org.apache.lucene.store.Directory dir, org.apache.lucene.index.IndexWriterConfig.OpenMode mode) A constructor. -
Method Summary
Modifier and TypeMethodDescriptionOptional<org.apache.lucene.index.IndexCommit> getIndexCommitByName(String commitName) This method returns the IndexCommit associated with the specifiedcommitName.getSnapshotMetaData(String name) This method returns the snapshot meta-data for the specified name (if it exists).org.apache.lucene.store.DirectorybooleanisSnapshotted(long genNumber) This method returns if snapshot is created for the specified generation number in the *current* index directory.booleanisSnapshotted(String indexDirPath, long genNumber) This method returns if snapshot is created for the specified generation number in the specified index directory.listSnapshotsInIndexDir(String indexDirPath) This method returns a list of snapshots created in a specified index directory.This method deletes a previously created snapshot (if any).voidThis method creates a new snapshot meta-data entry.
-
Field Details
-
SNAPSHOT_METADATA_DIR
- See Also:
-
SNAPSHOTS_PREFIX
Prefix used for the save file.- See Also:
-
nameToDetailsMapping
Used to map snapshot name to snapshot meta-data.
-
-
Constructor Details
-
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 Details
-
getSnapshotsDir
public org.apache.lucene.store.Directory getSnapshotsDir()- Returns:
- The snapshot meta-data directory
-
snapshot
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
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
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
- 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 specifiedcommitName. A snapshot with specifiedcommitNamemust be created before invoking this method.- Parameters:
commitName- The name of persisted commit- Returns:
- the IndexCommit
- Throws:
IOException- in case of I/O error.
-