Package org.elasticsearch.index.engine
Class CombinedDeletionPolicy
java.lang.Object
org.apache.lucene.index.IndexDeletionPolicy
org.elasticsearch.index.engine.CombinedDeletionPolicy
public class CombinedDeletionPolicy
extends org.apache.lucene.index.IndexDeletionPolicy
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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
commitDescription(org.apache.lucene.index.IndexCommit commit)
Returns a description for a givenIndexCommit
.static org.apache.lucene.index.IndexCommit
findSafeCommitPoint(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 int
getDocCountOfCommit(org.apache.lucene.index.IndexCommit indexCommit)
void
void
-
Method Details
-
onInit
- Specified by:
onInit
in classorg.apache.lucene.index.IndexDeletionPolicy
- Throws:
IOException
-
onCommit
public void onCommit(List<? extends org.apache.lucene.index.IndexCommit> commits) throws IOException- Specified by:
onCommit
in classorg.apache.lucene.index.IndexDeletionPolicy
- Throws:
IOException
-
getDocCountOfCommit
protected int getDocCountOfCommit(org.apache.lucene.index.IndexCommit indexCommit) throws IOException- Throws:
IOException
-
findSafeCommitPoint
public static org.apache.lucene.index.IndexCommit findSafeCommitPoint(List<org.apache.lucene.index.IndexCommit> commits, long globalCheckpoint) throws IOExceptionFind 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
-
commitDescription
public static String commitDescription(org.apache.lucene.index.IndexCommit commit) throws IOExceptionReturns a description for a givenIndexCommit
. This should be only used for logging and debugging.- Throws:
IOException
-