Class 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 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.

    See Also:
    IndexDeletionPolicy
    • 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()
      • 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 reserved
        reserveTime - durration in milliseconds (relative to 'now') for which the commit point is to be reserved
      • 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 class org.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 class org.apache.lucene.index.IndexDeletionPolicy
        Throws:
        IOException
      • getCommitPoint

        @Deprecated
        public org.apache.lucene.index.IndexCommit getCommitPoint​(Long gen)
        Deprecated.
        Returns 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