Class 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 Type Method Description
    static java.lang.String commitDescription​(org.apache.lucene.index.IndexCommit commit)
    Returns a description for a given IndexCommit.
    static org.apache.lucene.index.IndexCommit findSafeCommitPoint​(java.util.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 onCommit​(java.util.List<? extends org.apache.lucene.index.IndexCommit> commits)  
    void onInit​(java.util.List<? extends org.apache.lucene.index.IndexCommit> commits)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • onInit

      public void onInit​(java.util.List<? extends org.apache.lucene.index.IndexCommit> commits) throws
      Specified by:
      onInit in class org.apache.lucene.index.IndexDeletionPolicy
    • onCommit

      public void onCommit​(java.util.List<? extends org.apache.lucene.index.IndexCommit> commits) throws
      Specified by:
      onCommit in class org.apache.lucene.index.IndexDeletionPolicy
    • getDocCountOfCommit

      protected int getDocCountOfCommit​(org.apache.lucene.index.IndexCommit indexCommit) throws
    • findSafeCommitPoint

      public static org.apache.lucene.index.IndexCommit findSafeCommitPoint​(java.util.List<org.apache.lucene.index.IndexCommit> commits, long globalCheckpoint) throws
      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.
      commits - a list of existing commit points
      globalCheckpoint - the persisted global checkpoint from the translog, see Translog.readGlobalCheckpoint(Path, String)
      a safe commit or the oldest commit if a safe commit is not found
    • commitDescription

      public static java.lang.String commitDescription​(org.apache.lucene.index.IndexCommit commit) throws
      Returns a description for a given IndexCommit. This should be only used for logging and debugging.