Class IndexDeletionPolicyWrapper
Provides features for looking up IndexCommit given a version. Allows reserving index commit points for certain amounts of time to support features such as index replication or snapshotting directly out of a live index directory.
NOTE: The Object.clone() method returns this in order to make this
IndexDeletionPolicy instance trackable across IndexWriter instantiations. This is
correct because each core has its own IndexDeletionPolicy and never has more than one
open IndexWriter.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIndexDeletionPolicyWrapper(org.apache.lucene.index.IndexDeletionPolicy deletionPolicy, SolrSnapshotMetaDataManager snapshotMgr) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.index.IndexCommitgetAndSaveCommitPoint(Long generation) Atomically Saves (via reference counting) & Returns the specified commit if available.org.apache.lucene.index.IndexCommitAtomically Saves (via reference counting) & Returns the most recent commit point.Returns a Map of all currently known commits, keyed by their generation.static longgetCommitTimestamp(org.apache.lucene.index.IndexCommit commit) Helper method for unpacking the timestamp info from the user dataorg.apache.lucene.index.IndexCommitReturns the most recent commit point.org.apache.lucene.index.IndexDeletionPolicyvoidInternal use for Lucene...voidInternal use for Lucene...voidreleaseCommitPoint(Long generation) Release a previously saved commit point.voidreleaseCommitPoint(org.apache.lucene.index.IndexCommit commit) Release a previously saved commit point.voidsaveCommitPoint(Long generation) Permanently prevent this commit point from being deleted (if it has not already) using a reference count.voidsetReserveDuration(Long indexGen, long reserveTime) Set the duration for which commit point is to be reserved by the deletion policy.
-
Constructor Details
-
IndexDeletionPolicyWrapper
public IndexDeletionPolicyWrapper(org.apache.lucene.index.IndexDeletionPolicy deletionPolicy, SolrSnapshotMetaDataManager snapshotMgr)
-
-
Method Details
-
getLatestCommit
public org.apache.lucene.index.IndexCommit getLatestCommit()Returns the most recent commit point.NOTE: This method makes no guarantee that the commit returned still exists as the moment this method completes. Callers are encouraged to use
getAndSaveLatestCommit()instead.- Returns:
- the most recent commit point, or null if there have not been any commits
- See Also:
-
getAndSaveLatestCommit
public org.apache.lucene.index.IndexCommit getAndSaveLatestCommit()Atomically Saves (via reference counting) & Returns the most recent commit point.If the return value is non-null, then the caller MUST call
releaseCommitPoint(org.apache.lucene.index.IndexCommit)when finished using it in order to decrement the reference count, or the commit will be preserved in the Directory forever.- Returns:
- the most recent commit point, or null if there have not been any commits
- See Also:
-
getAndSaveCommitPoint
Atomically Saves (via reference counting) & Returns the specified commit if available.If the return value is non-null, then the caller MUST call
releaseCommitPoint(org.apache.lucene.index.IndexCommit)when finished using it in order to decrement the reference count, or the commit will be preserved in the Directory forever.- Returns:
- the commit point with the specified generation, or null if not available
- See Also:
-
getWrappedDeletionPolicy
public org.apache.lucene.index.IndexDeletionPolicy getWrappedDeletionPolicy() -
setReserveDuration
Set the duration for which commit point is to be reserved by the deletion policy.NOTE: This method does not make any guarantees that the specified index generation exists, or that the specified generation has not already ben deleted. The only guarantee is that if the specified generation exists now, or is created at some point in the future, then it will be reserved for at least the specified
reserveTime.- Parameters:
indexGen- gen of the commit point to be reservedreserveTime- duration in milliseconds (relative to 'now') for which the commit point is to be reserved
-
saveCommitPoint
Permanently prevent this commit point from being deleted (if it has not already) using a reference count.NOTE: Callers MUST call
releaseCommitPoint(org.apache.lucene.index.IndexCommit)when finished using it in order to decrement the reference count, or the commit will be preserved in the Directory forever.- Parameters:
generation- the generation of the IndexCommit to save until released- Throws:
IllegalStateException- if generation is already too old to be saved- See Also:
-
releaseCommitPoint
public void releaseCommitPoint(org.apache.lucene.index.IndexCommit commit) Release a previously saved commit point.This is a convenience wrapper around
releaseCommitPoint(Long)that will ignore null input. -
releaseCommitPoint
Release a previously saved commit point.This method does not enforce that the specified generation has previously been saved, or even that it's 'non-null'. But if both are true then it will decrement the reference count for the specified generation.
-
onInit
Internal use for Lucene... do not explicitly call.This Impl passes the list of commits to the delegate Policy AFTER wrapping each commit in a proxy class that only proxies
IndexCommit.delete()if they are not already saved.- Specified by:
onInitin classorg.apache.lucene.index.IndexDeletionPolicy- Throws:
IOException
-
onCommit
Internal use for Lucene... do not explicitly call.This Impl passes the list of commits to the delegate Policy AFTER wrapping each commit in a proxy class that only proxies
IndexCommit.delete()if they are not already saved.- Specified by:
onCommitin classorg.apache.lucene.index.IndexDeletionPolicy- Throws:
IOException
-
getCommits
Returns a Map of all currently known commits, keyed by their generation.NOTE: This map instance may change between commits and commit points may be deleted. This API is intended for "informational purposes" only, to provide an "at the moment" view of the current list of known commits. Callers that need to ensure commits exist for an extended period must wrap this call and all subsequent usage of the results in a synchronization block.
- Returns:
- a Map of generation to commit points
-
getCommitTimestamp
public static long getCommitTimestamp(org.apache.lucene.index.IndexCommit commit) throws IOException Helper method for unpacking the timestamp info from the user data- Throws:
IOException- See Also:
-