Class CommitTracker

  • All Implemented Interfaces:
    Runnable

    public final class CommitTracker
    extends Object
    implements Runnable
    Helper class for tracking autoCommit state. Note: This is purely an implementation detail of autoCommit and will definitely change in the future, so the interface should not be relied-upon Note: all access must be synchronized. Public for tests.
    • Constructor Detail

      • CommitTracker

        public CommitTracker​(String name,
                             SolrCore core,
                             int docsUpperBound,
                             int timeUpperBound,
                             long tLogFileSizeUpperBound,
                             boolean openSearcher,
                             boolean softCommit)
    • Method Detail

      • getOpenSearcher

        public boolean getOpenSearcher()
      • close

        public void close()
      • scheduleCommitWithin

        public void scheduleCommitWithin​(long commitMaxTime)
        schedule individual commits
      • cancelPendingCommit

        public void cancelPendingCommit()
      • addedDocument

        public void addedDocument​(int commitWithin)
        Indicate that documents have been added
        Parameters:
        commitWithin - amount of time (in ms) within which a commit should be scheduled
      • addedDocument

        public void addedDocument​(int commitWithin,
                                  long currentTlogSize)
        Indicate that documents have been added
        Parameters:
        commitWithin - amount of time (in ms) within which a commit should be scheduled
        currentTlogSize - current tlog size (in bytes). Use -1 if we don't want to check for a max size triggered commit
      • deletedDocument

        public void deletedDocument​(int commitWithin)
        Indicate that documents have been deleted
      • scheduleMaxSizeTriggeredCommitIfNeeded

        public void scheduleMaxSizeTriggeredCommitIfNeeded​(long currentTlogSize)
        If the given current tlog size is greater than the file size upper bound, then schedule a commit
        Parameters:
        currentTlogSize - current tlog size (in bytes)
      • didCommit

        public void didCommit()
        Inform tracker that a commit has occurred
      • didRollback

        public void didRollback()
        Inform tracker that a rollback has occurred, cancel any pending commits
      • run

        public void run()
        This is the worker part for the ScheduledFuture
        Specified by:
        run in interface Runnable
      • getCommitCount

        public int getCommitCount()
      • getTimeUpperBound

        public long getTimeUpperBound()
      • setTimeUpperBound

        public void setTimeUpperBound​(long timeUpperBound)
      • setTLogFileSizeUpperBound

        public void setTLogFileSizeUpperBound​(int sizeUpperBound)
      • setOpenSearcher

        public void setOpenSearcher​(boolean openSearcher)
      • hasPending

        public boolean hasPending()