Class LossDetector

java.lang.Object
io.aeron.driver.LossDetector
All Implemented Interfaces:
TermGapScanner.GapHandler

public class LossDetector extends Object implements TermGapScanner.GapHandler
Detecting and handling of gaps in a message stream.

Each detector only notifies a single run of a gap in a message stream.

  • Constructor Summary

    Constructors
    Constructor
    Description
    LossDetector(FeedbackDelayGenerator delayGenerator, LossHandler lossHandler)
    Create a loss detector for a channel.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    lossFound(long scanOutcome)
    Has loss been found in the scan?
    void
    onGap(int termId, int offset, int length)
    Gap detected in log buffer that is being rebuilt.
    static long
    pack(int rebuildOffset, boolean lossFound)
    Pack the values for workCount and rebuildOffset into a long for returning on the stack.
    static int
    rebuildOffset(long scanOutcome)
    The offset up to which the log has been rebuilt.
    long
    scan(UnsafeBuffer termBuffer, long rebuildPosition, long hwmPosition, long nowNs, int termLengthMask, int positionBitsToShift, int initialTermId)
    Scan for gaps and handle received data.

    Methods inherited from class java.lang.Object

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

    • LossDetector

      public LossDetector(FeedbackDelayGenerator delayGenerator, LossHandler lossHandler)
      Create a loss detector for a channel.
      Parameters:
      delayGenerator - to use for delay determination
      lossHandler - to call when signalling a gap
  • Method Details

    • scan

      public long scan(UnsafeBuffer termBuffer, long rebuildPosition, long hwmPosition, long nowNs, int termLengthMask, int positionBitsToShift, int initialTermId)
      Scan for gaps and handle received data.

      The handler keeps track from scan to scan what is a gap and what must have been repaired.

      Parameters:
      termBuffer - to scan
      rebuildPosition - to start scanning from
      hwmPosition - to scan up to
      nowNs - time in nanoseconds
      termLengthMask - used for offset calculation
      positionBitsToShift - used for position calculation
      initialTermId - used by the scanner
      Returns:
      packed outcome of the scan.
    • onGap

      public void onGap(int termId, int offset, int length)
      Gap detected in log buffer that is being rebuilt.
      Specified by:
      onGap in interface TermGapScanner.GapHandler
      Parameters:
      termId - active term being scanned.
      offset - at which the gap begins.
      length - of the gap in bytes.
    • pack

      public static long pack(int rebuildOffset, boolean lossFound)
      Pack the values for workCount and rebuildOffset into a long for returning on the stack.
      Parameters:
      rebuildOffset - value to be packed.
      lossFound - value to be packed.
      Returns:
      a long with rebuildOffset and lossFound packed into it.
    • lossFound

      public static boolean lossFound(long scanOutcome)
      Has loss been found in the scan?
      Parameters:
      scanOutcome - into which the fragments read value has been packed.
      Returns:
      if loss has been found or not.
    • rebuildOffset

      public static int rebuildOffset(long scanOutcome)
      The offset up to which the log has been rebuilt.
      Parameters:
      scanOutcome - into which the offset value has been packed.
      Returns:
      the offset up to which the log has been rebuilt.