Struct raftstore::store::util::Lease [−][src]
Lease records an expired time, for examining the current moment is in lease or not. It’s dedicated to the Raft leader lease mechanism, contains either state of
- Suspect Timestamp A suspicious leader lease timestamp, which marks the leader may still hold or lose its lease until the clock time goes over this timestamp.
- Valid Timestamp A valid leader lease timestamp, which marks the leader holds the lease for now. The lease is valid until the clock time goes over this timestamp.
Time
|---------------------------------->
^ ^
Now Suspect TS
State: | Suspect | Suspect
|---------------------------------->
^ ^
Now Valid TS
State: | Valid | Expired
Note:
- Valid timestamp would increase when raft log entries are applied in current term.
- Suspect timestamp would be set after the message
MsgTimeoutNow
is sent by current peer. The messageMsgTimeoutNow
starts a leader transfer procedure. During this procedure, current peer as an old leader may still hold its lease or lose it. It’s possible there is a new leader elected and current peer as an old leader doesn’t step down due to network partition from the new leader. In that case, current peer lose its leader lease. Within this suspect leader lease expire time, read requests could not be performed locally. - The valid leader lease should be
lease = max_lease - (commit_ts - send_ts)
And the expired timestamp for that leader lease iscommit_ts + lease
, which issend_ts + max_lease
in short.
Fields
bound: Option<Either<Timespec, Timespec>>
max_lease: Duration
max_drift: Duration
last_update: Timespec
remote: Option<RemoteLease>
Implementations
impl Lease
[src]
pub fn new(max_lease: Duration) -> Lease
[src]
fn next_expired_time(&self, send_ts: Timespec) -> Timespec
[src]
The valid leader lease should be lease = max_lease - (commit_ts - send_ts)
And the expired timestamp for that leader lease is commit_ts + lease
,
which is send_ts + max_lease
in short.
pub fn renew(&mut self, send_ts: Timespec)
[src]
Renew the lease to the bound.
pub fn suspect(&mut self, send_ts: Timespec)
[src]
Suspect the lease to the bound.
pub fn inspect(&self, ts: Option<Timespec>) -> LeaseState
[src]
Inspect the lease state for the ts or now.
pub fn expire(&mut self)
[src]
pub fn expire_remote_lease(&mut self)
[src]
pub fn maybe_new_remote_lease(&mut self, term: u64) -> Option<RemoteLease>
[src]
Return a new RemoteLease
if there is none.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Lease
impl Send for Lease
impl Sync for Lease
impl Unpin for Lease
impl UnwindSafe for Lease
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<V, W> ConvertFrom<W> for V where
W: ConvertTo<V>,
[src]
W: ConvertTo<V>,
pub fn convert_from(ctx: &mut EvalContext, from: W) -> Result<V, Error>
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,