Package org.apache.solr.core.snapshots
Class SolrSnapshotManager
java.lang.Object
org.apache.solr.core.snapshots.SolrSnapshotManager
This class provides functionality required to handle the data files corresponding to Solr
snapshots.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcleanupCollectionLevelSnapshots(org.apache.solr.common.cloud.SolrZkClient zkClient, String collectionName) This method deletes all snapshots for the specified collection in Zookeeper.static voidcreateCollectionLevelSnapshot(org.apache.solr.common.cloud.SolrZkClient zkClient, String collectionName, CollectionSnapshotMetaData meta) This method creates an entry for the named snapshot for the specified collection in Zookeeper.static voiddeleteCollectionLevelSnapshot(org.apache.solr.common.cloud.SolrZkClient zkClient, String collectionName, String commitName) This method deletes an entry for the named snapshot for the specified collection in Zookeeper.static voiddeleteNonSnapshotIndexFiles(SolrCore core, org.apache.lucene.store.Directory dir, Collection<SolrSnapshotMetaDataManager.SnapshotMetaData> snapshots) This method deletes index files not associated with the specifiedsnapshots.static voiddeleteSnapshotIndexFiles(SolrCore core, org.apache.lucene.store.Directory dir, long gen) This method deletes index files of the IndexCommit for the specified generation number.static Optional<CollectionSnapshotMetaData> getCollectionLevelSnapshot(org.apache.solr.common.cloud.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(org.apache.solr.common.cloud.SolrZkClient zkClient, String collectionName) This method returns the CollectionSnapshotMetaData for each named snapshot for the specified collection in Zookeeper.static booleansnapshotExists(org.apache.solr.common.cloud.SolrZkClient zkClient, String collectionName, String commitName) This method returns if a named snapshot exists for the specified collection.static voidupdateCollectionLevelSnapshot(org.apache.solr.common.cloud.SolrZkClient zkClient, String collectionName, CollectionSnapshotMetaData meta) This method updates an entry for the named snapshot for the specified collection in Zookeeper.
-
Field Details
-
INDEX_DIR_PATH
- See Also:
-
GENERATION_NUM
- See Also:
-
SNAPSHOT_STATUS
- See Also:
-
CREATION_DATE
- See Also:
-
SNAPSHOT_REPLICAS
- See Also:
-
SNAPSHOTS_INFO
- See Also:
-
LEADER
- See Also:
-
SHARD_ID
- See Also:
-
FILE_LIST
- See Also:
-
-
Constructor Details
-
SolrSnapshotManager
public SolrSnapshotManager()
-
-
Method Details
-
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 clientcollectionName- The name of the collectioncommitName- The name of the snapshot- Returns:
- true if the named snapshot exists false Otherwise
- Throws:
org.apache.zookeeper.KeeperException- In case of Zookeeper errorInterruptedException- 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 clientcollectionName- The name of the collectionmeta- The CollectionSnapshotMetaData corresponding to named snapshot- Throws:
org.apache.zookeeper.KeeperException- In case of Zookeeper errorInterruptedException- 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 clientcollectionName- The name of the collectionmeta- The CollectionSnapshotMetaData corresponding to named snapshot- Throws:
org.apache.zookeeper.KeeperException- In case of Zookeeper errorInterruptedException- 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 clientcollectionName- The name of the collectioncommitName- 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 clientcollectionName- 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 clientcollectionName- The name of the collectioncommitName- 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(org.apache.solr.common.cloud.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 clientcollectionName- 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, 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 coredir- 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 specifiedsnapshots.- Parameters:
core- The Solr coredir- The index directory storing the snapshot.snapshots- The snapshots to be preserved.- Throws:
IOException- in case of I/O errors.
-