Package 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 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 Description SolrSnapshotManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
cleanupCollectionLevelSnapshots(org.apache.solr.common.cloud.SolrZkClient zkClient, String collectionName)
This method deletes all snapshots for the specified collection in Zookeeper.static void
createCollectionLevelSnapshot(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 void
deleteCollectionLevelSnapshot(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 void
deleteNonSnapshotIndexFiles(SolrCore core, org.apache.lucene.store.Directory dir, Collection<SolrSnapshotMetaDataManager.SnapshotMetaData> snapshots)
This method deletes index files not associated with the specifiedsnapshots
.static void
deleteSnapshotIndexFiles(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 boolean
snapshotExists(org.apache.solr.common.cloud.SolrZkClient zkClient, String collectionName, String commitName)
This method returns if a named snapshot exists for the specified collection.static void
updateCollectionLevelSnapshot(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 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
-
-
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 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.
-
-