Class LocalCheckpointTracker

java.lang.Object
org.elasticsearch.index.seqno.LocalCheckpointTracker

public class LocalCheckpointTracker
extends java.lang.Object
This class generates sequences numbers and keeps track of the so-called "local checkpoint" which is the highest number for which all previous sequence numbers have been processed (inclusive).
  • Constructor Summary

    Constructors 
    Constructor Description
    LocalCheckpointTracker​(long maxSeqNo, long localCheckpoint)
    Initialize the local checkpoint service.
  • Method Summary

    Modifier and Type Method Description
    void advanceMaxSeqNo​(long seqNo)
    Marks the provided sequence number as seen and updates the max_seq_no if needed.
    long generateSeqNo()
    Issue the next sequence number.
    long getMaxSeqNo()
    The maximum sequence number issued so far.
    long getPersistedCheckpoint()
    The current persisted checkpoint which can be advanced by markSeqNoAsPersisted(long).
    long getProcessedCheckpoint()
    The current checkpoint which can be advanced by markSeqNoAsProcessed(long).
    SeqNoStats getStats​(long globalCheckpoint)
    constructs a SeqNoStats object, using local state and the supplied global checkpoint This is needed to make sure the persisted local checkpoint and max seq no are consistent
    boolean hasProcessed​(long seqNo)
    Checks if the given sequence number was marked as processed in this tracker.
    void markSeqNoAsPersisted​(long seqNo)
    Marks the provided sequence number as persisted and updates the checkpoint if possible.
    void markSeqNoAsProcessed​(long seqNo)
    Marks the provided sequence number as processed and updates the processed checkpoint if possible.
    void waitForProcessedOpsToComplete​(long seqNo)
    Waits for all operations up to the provided sequence number to complete.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • generateSeqNo

      public long generateSeqNo()
      Issue the next sequence number.
      Returns:
      the next assigned sequence number
    • advanceMaxSeqNo

      public void advanceMaxSeqNo​(long seqNo)
      Marks the provided sequence number as seen and updates the max_seq_no if needed.
    • markSeqNoAsProcessed

      public void markSeqNoAsProcessed​(long seqNo)
      Marks the provided sequence number as processed and updates the processed checkpoint if possible.
      Parameters:
      seqNo - the sequence number to mark as processed
    • markSeqNoAsPersisted

      public void markSeqNoAsPersisted​(long seqNo)
      Marks the provided sequence number as persisted and updates the checkpoint if possible.
      Parameters:
      seqNo - the sequence number to mark as persisted
    • getProcessedCheckpoint

      public long getProcessedCheckpoint()
      The current checkpoint which can be advanced by markSeqNoAsProcessed(long).
      Returns:
      the current checkpoint
    • getPersistedCheckpoint

      public long getPersistedCheckpoint()
      The current persisted checkpoint which can be advanced by markSeqNoAsPersisted(long).
      Returns:
      the current persisted checkpoint
    • getMaxSeqNo

      public long getMaxSeqNo()
      The maximum sequence number issued so far.
      Returns:
      the maximum sequence number
    • getStats

      public SeqNoStats getStats​(long globalCheckpoint)
      constructs a SeqNoStats object, using local state and the supplied global checkpoint This is needed to make sure the persisted local checkpoint and max seq no are consistent
    • waitForProcessedOpsToComplete

      public void waitForProcessedOpsToComplete​(long seqNo) throws java.lang.InterruptedException
      Waits for all operations up to the provided sequence number to complete.
      Parameters:
      seqNo - the sequence number that the checkpoint must advance to before this method returns
      Throws:
      java.lang.InterruptedException - if the thread was interrupted while blocking on the condition
    • hasProcessed

      public boolean hasProcessed​(long seqNo)
      Checks if the given sequence number was marked as processed in this tracker.