java.lang.Object
org.apache.lucene.index.IndexDeletionPolicy
org.elasticsearch.index.engine.ElasticsearchIndexDeletionPolicy
org.elasticsearch.index.engine.CombinedDeletionPolicy
An
IndexDeletionPolicy that coordinates between Lucene's commits and the retention of translog generation files,
making sure that all translog files that are needed to recover from the Lucene commit are not deleted.
In particular, this policy will delete index commits whose max sequence number is at most the current global checkpoint except the index commit which has the highest max sequence number among those.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.index.engine.ElasticsearchIndexDeletionPolicy
ElasticsearchIndexDeletionPolicy.CommitsListener -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.index.IndexCommitacquireIndexCommit(boolean acquiringSafeCommit) Captures the most recent commit pointlastCommitor the most recent safe commit pointsafeCommit.static StringcommitDescription(org.apache.lucene.index.IndexCommit commit) Returns a description for a givenIndexCommit.static org.apache.lucene.index.IndexCommitfindSafeCommitPoint(List<org.apache.lucene.index.IndexCommit> commits, long globalCheckpoint) Find a safe commit point from a list of existing commits based on the supplied global checkpoint.protected intgetDocCountOfCommit(org.apache.lucene.index.IndexCommit indexCommit) booleanChecks whether the deletion policy is holding on to externally acquired index commitsbooleanChecks if the deletion policy can delete some index commits with the latest global checkpoint.voidvoidbooleanreleaseIndexCommit(org.apache.lucene.index.IndexCommit acquiredCommit) Releases an index commit that acquired byacquireIndexCommit(boolean).protected org.apache.lucene.index.IndexCommitwrapCommit(org.apache.lucene.index.IndexCommit indexCommit) protected org.apache.lucene.index.IndexCommitwrapCommit(org.apache.lucene.index.IndexCommit indexCommit, boolean acquiredInternally)
-
Method Details
-
onInit
- Specified by:
onInitin classorg.apache.lucene.index.IndexDeletionPolicy- Throws:
IOException
-
onCommit
public void onCommit(List<? extends org.apache.lucene.index.IndexCommit> commits) throws IOException - Specified by:
onCommitin classorg.apache.lucene.index.IndexDeletionPolicy- Throws:
IOException
-
getDocCountOfCommit
protected int getDocCountOfCommit(org.apache.lucene.index.IndexCommit indexCommit) throws IOException - Throws:
IOException
-
getSafeCommitInfo
- Specified by:
getSafeCommitInfoin classElasticsearchIndexDeletionPolicy- Returns:
- information about the safe commit
-
acquireIndexCommit
public org.apache.lucene.index.IndexCommit acquireIndexCommit(boolean acquiringSafeCommit) Captures the most recent commit pointlastCommitor the most recent safe commit pointsafeCommit. Index files of the capturing commit point won't be released until the commit reference is closed.- Specified by:
acquireIndexCommitin classElasticsearchIndexDeletionPolicy- Parameters:
acquiringSafeCommit- captures the most recent safe commit point if true; otherwise captures the most recent commit point.
-
wrapCommit
protected org.apache.lucene.index.IndexCommit wrapCommit(org.apache.lucene.index.IndexCommit indexCommit) -
wrapCommit
protected org.apache.lucene.index.IndexCommit wrapCommit(org.apache.lucene.index.IndexCommit indexCommit, boolean acquiredInternally) -
releaseIndexCommit
public boolean releaseIndexCommit(org.apache.lucene.index.IndexCommit acquiredCommit) Releases an index commit that acquired byacquireIndexCommit(boolean).- Specified by:
releaseIndexCommitin classElasticsearchIndexDeletionPolicy- Returns:
- true if the acquired commit can be clean up.
-
findSafeCommitPoint
public static org.apache.lucene.index.IndexCommit findSafeCommitPoint(List<org.apache.lucene.index.IndexCommit> commits, long globalCheckpoint) throws IOException Find a safe commit point from a list of existing commits based on the supplied global checkpoint. The max sequence number of a safe commit point should be at most the global checkpoint. If an index was created before 6.2 or recovered from remote, we might not have a safe commit. In this case, this method will return the oldest index commit.- Parameters:
commits- a list of existing commit pointsglobalCheckpoint- the persisted global checkpoint from the translog, seeTranslog.readGlobalCheckpoint(Path, String)- Returns:
- a safe commit or the oldest commit if a safe commit is not found
- Throws:
IOException
-
hasAcquiredIndexCommitsForTesting
public boolean hasAcquiredIndexCommitsForTesting()Checks whether the deletion policy is holding on to externally acquired index commits- Specified by:
hasAcquiredIndexCommitsForTestingin classElasticsearchIndexDeletionPolicy
-
hasUnreferencedCommits
public boolean hasUnreferencedCommits()Checks if the deletion policy can delete some index commits with the latest global checkpoint.- Specified by:
hasUnreferencedCommitsin classElasticsearchIndexDeletionPolicy
-
commitDescription
public static String commitDescription(org.apache.lucene.index.IndexCommit commit) throws IOException Returns a description for a givenIndexCommit. This should be only used for logging and debugging.- Throws:
IOException
-