pub struct ConsistencyTracker { /* private fields */ }Expand description
Tracks the replica’s applied state and blocks a read until the configured
ConsistencyPolicy is satisfied.
Port of com.sleepycat.je.rep.impl.node.Replica.ConsistencyTracker
(awaitVLSN / lagAwait / await). In JE the tracker holds ordered
CountDownLatches that the replay thread trips as VLSNs are applied; a
reader parks on the latch with the policy timeout and gets a
ReplicaConsistencyException if it expires.
Here the predicate is the REP-7 last_applied_vlsn handle
(ReplicaReplay::last_applied_vlsn_handle) — the SAME Arc<AtomicU64> the
replay driver advances after each committed apply. We do NOT add a
parallel tracker; we read the existing hook. master_vlsn is the
master’s latest known commit VLSN (the feeder stream / heartbeat
high-water), used by the time policy — JE’s masterTxnEndVLSN.
Implementations§
Source§impl ConsistencyTracker
impl ConsistencyTracker
Sourcepub fn new(last_applied_vlsn: Arc<AtomicU64>) -> Self
pub fn new(last_applied_vlsn: Arc<AtomicU64>) -> Self
Build a tracker over the REP-7 last_applied_vlsn handle.
Sourcepub fn last_applied_vlsn(&self) -> u64
pub fn last_applied_vlsn(&self) -> u64
The replica’s last-applied VLSN (the wait predicate).
Sourcepub fn set_master_vlsn(&self, vlsn: u64)
pub fn set_master_vlsn(&self, vlsn: u64)
Record the master’s latest known commit VLSN (feeder / heartbeat).
Port of ConsistencyTracker.trackHeartbeat updating masterTxnEndVLSN.
Monotone.
Sourcepub fn master_vlsn(&self) -> u64
pub fn master_vlsn(&self) -> u64
The master’s latest known commit VLSN.
Sourcepub fn notify_applied(&self)
pub fn notify_applied(&self)
Wake any reader parked in Self::await_consistency.
Called when the replica applies a new entry (the replay thread can
invoke this after advancing last_applied_vlsn). Equivalent to the
latch trip in ConsistencyTracker.trackVLSN. Optional: a waiter also
re-checks every Self::RECHECK_TICK, so a missed notify only delays
(never hangs) the read.
Sourcepub fn await_consistency(&self, policy: &ConsistencyPolicy) -> Result<()>
pub fn await_consistency(&self, policy: &ConsistencyPolicy) -> Result<()>
Block until the replica’s applied state satisfies policy, or the
policy timeout expires.
Port of ReplicaConsistencyPolicy.ensureConsistency →
ConsistencyTracker.awaitVLSN / lagAwait:
ConsistencyPolicy::NoConsistency: returns immediately (JENoConsistencyRequiredPolicy.ensureConsistencyis a no-op).ConsistencyPolicy::CommitPointConsistency: waits untillast_applied_vlsn >= token.vlsn(JEawaitVLSNcomparing againstlastReplayedTxnVLSN).ConsistencyPolicy::TimeConsistency: waits until the estimated lag behind the master is withinmax_lag(JElagAwait).
On timeout returns a clean RepError —
RepError::ConsistencyTimeout for the commit-point policy and
RepError::ReplicaLagExceeded for the time policy — the equivalent
of JE’s ReplicaConsistencyException. NEVER hangs.
Trait Implementations§
Source§impl Clone for ConsistencyTracker
impl Clone for ConsistencyTracker
Source§fn clone(&self) -> ConsistencyTracker
fn clone(&self) -> ConsistencyTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ConsistencyTracker
impl !UnwindSafe for ConsistencyTracker
impl Freeze for ConsistencyTracker
impl Send for ConsistencyTracker
impl Sync for ConsistencyTracker
impl Unpin for ConsistencyTracker
impl UnsafeUnpin for ConsistencyTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more