Class IndexDeletionPolicyWrapper
- java.lang.Object
-
- org.apache.lucene.index.IndexDeletionPolicy
-
- org.apache.solr.core.IndexDeletionPolicyWrapper
-
public final class IndexDeletionPolicyWrapper extends org.apache.lucene.index.IndexDeletionPolicy
A wrapper for an IndexDeletionPolicy instance.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 snapshooting directly out of a live index directory.
NOTE: The
Object.clone()
method returnsthis
in order to make thisIndexDeletionPolicy
instance trackable acrossIndexWriter
instantiations. This is correct because each core has its ownIndexDeletionPolicy
and never has more than one openIndexWriter
.- See Also:
IndexDeletionPolicy
-
-
Constructor Summary
Constructors Constructor Description IndexDeletionPolicyWrapper(org.apache.lucene.index.IndexDeletionPolicy deletionPolicy, SolrSnapshotMetaDataManager snapshotMgr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.apache.lucene.index.IndexCommit
getAndSaveCommitPoint(Long generation)
Atomically Saves (via reference counting) & Returns the specified commit if available.org.apache.lucene.index.IndexCommit
getAndSaveLatestCommit()
Atomically Saves (via reference counting) & Returns the most recent commit point.org.apache.lucene.index.IndexCommit
getCommitPoint(Long gen)
Deprecated.usegetAndSaveCommitPoint(java.lang.Long)
insteadMap<Long,org.apache.lucene.index.IndexCommit>
getCommits()
Returns a Map of all currently known commits, keyed by their generation.static long
getCommitTimestamp(org.apache.lucene.index.IndexCommit commit)
Helper method for unpacking the timestamp infor from the user dataorg.apache.lucene.index.IndexCommit
getLatestCommit()
Returns the most recent commit point.org.apache.lucene.index.IndexDeletionPolicy
getWrappedDeletionPolicy()
void
onCommit(List<? extends org.apache.lucene.index.IndexCommit> list)
Internal use for Lucene...void
onInit(List<? extends org.apache.lucene.index.IndexCommit> list)
Internal use for Lucene...void
releaseCommitPoint(Long generation)
Release a previously saved commit point.void
releaseCommitPoint(org.apache.lucene.index.IndexCommit commit)
Release a previously saved commit point.void
saveCommitPoint(Long generation)
Permanently prevent this commit point from being deleted (if it has not already) using a refrence count.void
setReserveDuration(Long indexGen, long reserveTime)
Set the duration for which commit point is to be reserved by the deletion policy.
-
-
-
Constructor Detail
-
IndexDeletionPolicyWrapper
public IndexDeletionPolicyWrapper(org.apache.lucene.index.IndexDeletionPolicy deletionPolicy, SolrSnapshotMetaDataManager snapshotMgr)
-
-
Method Detail
-
getLatestCommit
public org.apache.lucene.index.IndexCommit getLatestCommit()
Returns the most recent commit point.NOTE: This method makes no garuntee 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()
-
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:
saveCommitPoint(java.lang.Long)
,releaseCommitPoint(org.apache.lucene.index.IndexCommit)
-
getAndSaveCommitPoint
public org.apache.lucene.index.IndexCommit getAndSaveCommitPoint(Long generation)
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:
saveCommitPoint(java.lang.Long)
,releaseCommitPoint(org.apache.lucene.index.IndexCommit)
-
getWrappedDeletionPolicy
public org.apache.lucene.index.IndexDeletionPolicy getWrappedDeletionPolicy()
-
setReserveDuration
public void setReserveDuration(Long indexGen, long reserveTime)
Set the duration for which commit point is to be reserved by the deletion policy.NOTE: This method does not make any garuntees that the specified index generation exists, or that the specified generation has not already ben deleted. The only garuntee is that if the specified generation exists now, or is created at some point in the future, then it will be resered for at least the specified
reserveTime
.- Parameters:
indexGen
- gen of the commit point to be reservedreserveTime
- durration in milliseconds (relative to 'now') for which the commit point is to be reserved
-
saveCommitPoint
public void saveCommitPoint(Long generation)
Permanently prevent this commit point from being deleted (if it has not already) using a refrence 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 IndexComit to save until released- Throws:
IllegalStateException
- if generation is already too old to be saved- See Also:
getAndSaveLatestCommit()
,getAndSaveCommitPoint(java.lang.Long)
,releaseCommitPoint(org.apache.lucene.index.IndexCommit)
-
releaseCommitPoint
public void releaseCommitPoint(org.apache.lucene.index.IndexCommit commit)
Release a previously saved commit point.This is a convinience wrapper around
releaseCommitPoint(Long)
that will ignore null input.
-
releaseCommitPoint
public void releaseCommitPoint(Long generation)
Release a previously saved commit point.This method does not enforce that 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
public void onInit(List<? extends org.apache.lucene.index.IndexCommit> list) throws IOException
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:
onInit
in classorg.apache.lucene.index.IndexDeletionPolicy
- Throws:
IOException
-
onCommit
public void onCommit(List<? extends org.apache.lucene.index.IndexCommit> list) throws IOException
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:
onCommit
in classorg.apache.lucene.index.IndexDeletionPolicy
- Throws:
IOException
-
getCommitPoint
@Deprecated public org.apache.lucene.index.IndexCommit getCommitPoint(Long gen)
Deprecated.usegetAndSaveCommitPoint(java.lang.Long)
insteadReturns the commit with the specified generation if it is known.NOTE: This method makes no garuntee that the commit returned still exists as the moment this method completes. Callers are encouraged to use
getAndSaveLatestCommit()
instead.- Parameters:
gen
- the generation of the commit point requested- Returns:
- a commit point corresponding to the given version if available, or null if not yet created or already deleted
-
getCommits
public Map<Long,org.apache.lucene.index.IndexCommit> 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 synchornization 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 infor from the user data- Throws:
IOException
- See Also:
SolrIndexWriter.COMMIT_TIME_MSEC_KEY
,IndexCommit.getUserData()
-
-