public final class IndexDeletionPolicyWrapper extends IndexDeletionPolicy
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 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
.
IndexDeletionPolicy
Constructor and Description |
---|
IndexDeletionPolicyWrapper(IndexDeletionPolicy deletionPolicy,
SolrSnapshotMetaDataManager snapshotMgr) |
Modifier and Type | Method and Description |
---|---|
IndexCommit |
getAndSaveCommitPoint(Long generation)
Atomically Saves (via reference counting) & Returns the specified commit if available.
|
IndexCommit |
getAndSaveLatestCommit()
Atomically Saves (via reference counting) & Returns the most recent commit point.
|
IndexCommit |
getCommitPoint(Long gen)
Deprecated.
use
getAndSaveCommitPoint(java.lang.Long) instead |
Map<Long,IndexCommit> |
getCommits()
Returns a Map of all currently known commits, keyed by their generation.
|
static long |
getCommitTimestamp(IndexCommit commit)
Helper method for unpacking the timestamp infor from the user data
|
IndexCommit |
getLatestCommit()
Returns the most recent commit point.
|
IndexDeletionPolicy |
getWrappedDeletionPolicy() |
void |
onCommit(List<? extends IndexCommit> list)
Internal use for Lucene...
|
void |
onInit(List<? extends IndexCommit> list)
Internal use for Lucene...
|
void |
releaseCommitPoint(IndexCommit commit)
Release a previously saved commit point.
|
void |
releaseCommitPoint(Long generation)
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.
|
public IndexDeletionPolicyWrapper(IndexDeletionPolicy deletionPolicy, SolrSnapshotMetaDataManager snapshotMgr)
public IndexCommit getLatestCommit()
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.
getAndSaveLatestCommit()
public IndexCommit getAndSaveLatestCommit()
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.
saveCommitPoint(java.lang.Long)
,
releaseCommitPoint(org.apache.lucene.index.IndexCommit)
public IndexCommit getAndSaveCommitPoint(Long generation)
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.
saveCommitPoint(java.lang.Long)
,
releaseCommitPoint(org.apache.lucene.index.IndexCommit)
public IndexDeletionPolicy getWrappedDeletionPolicy()
public void setReserveDuration(Long indexGen, long reserveTime)
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
.
indexGen
- gen of the commit point to be reservedreserveTime
- durration in milliseconds (relative to 'now') for which the commit point is to be reservedpublic void saveCommitPoint(Long generation)
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.
generation
- the generation of the IndexComit to save until releasedIllegalStateException
- if generation is already too old to be savedgetAndSaveLatestCommit()
,
getAndSaveCommitPoint(java.lang.Long)
,
releaseCommitPoint(org.apache.lucene.index.IndexCommit)
public void releaseCommitPoint(IndexCommit commit)
This is a convinience wrapper around releaseCommitPoint(Long)
that will ignore null input.
public void releaseCommitPoint(Long generation)
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.
public void onInit(List<? extends IndexCommit> list) throws IOException
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.
onInit
in class IndexDeletionPolicy
IOException
public void onCommit(List<? extends IndexCommit> list) throws IOException
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.
onCommit
in class IndexDeletionPolicy
IOException
@Deprecated public IndexCommit getCommitPoint(Long gen)
getAndSaveCommitPoint(java.lang.Long)
instead
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.
gen
- the generation of the commit point requestedpublic Map<Long,IndexCommit> getCommits()
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.
public static long getCommitTimestamp(IndexCommit commit) throws IOException
IOException
SolrIndexWriter.COMMIT_TIME_MSEC_KEY
,
IndexCommit.getUserData()
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.