Package io.aeron.driver
Class LossDetector
java.lang.Object
io.aeron.driver.LossDetector
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionLossDetector
(FeedbackDelayGenerator delayGenerator, LossHandler lossHandler) Create a loss detector for a channel. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Constructor Details
-
LossDetector
Create a loss detector for a channel.- Parameters:
delayGenerator
- to use for delay determinationlossHandler
- 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 scanrebuildPosition
- to start scanning fromhwmPosition
- to scan up tonowNs
- time in nanosecondstermLengthMask
- used for offset calculationpositionBitsToShift
- used for position calculationinitialTermId
- 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 interfaceTermGapScanner.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.
-