Struct jopemachine_raft::Progress
source · pub struct Progress {
pub matched: u64,
pub next_idx: u64,
pub state: ProgressState,
pub paused: bool,
pub pending_snapshot: u64,
pub pending_request_snapshot: u64,
pub recent_active: bool,
pub ins: Inflights,
pub commit_group_id: u64,
pub committed_index: u64,
}
Expand description
The progress of catching up from a restart.
Fields§
§matched: u64
How much state is matched.
next_idx: u64
The next index to apply
state: ProgressState
When in ProgressStateProbe, leader sends at most one replication message per heartbeat interval. It also probes actual progress of the follower.
When in ProgressStateReplicate, leader optimistically increases next to the latest entry sent after sending replication message. This is an optimized state for fast replicating log entries to the follower.
When in ProgressStateSnapshot, leader should have sent out snapshot before and stop sending any replication message.
paused: bool
Paused is used in ProgressStateProbe. When Paused is true, raft should pause sending replication message to this peer.
pending_snapshot: u64
This field is used in ProgressStateSnapshot. If there is a pending snapshot, the pendingSnapshot will be set to the index of the snapshot. If pendingSnapshot is set, the replication process of this Progress will be paused. raft will not resend snapshot until the pending one is reported to be failed.
pending_request_snapshot: u64
This field is used in request snapshot. If there is a pending request snapshot, this will be set to the request index of the snapshot.
recent_active: bool
This is true if the progress is recently active. Receiving any messages from the corresponding follower indicates the progress is active. RecentActive can be reset to false after an election timeout.
ins: Inflights
Inflights is a sliding window for the inflight messages. When inflights is full, no more message should be sent. When a leader sends out a message, the index of the last entry should be added to inflights. The index MUST be added into inflights in order. When a leader receives a reply, the previous inflights should be freed by calling inflights.freeTo.
commit_group_id: u64
Only logs replicated to different group will be committed if any group is configured.
committed_index: u64
Committed index in raft_log
Implementations§
source§impl Progress
impl Progress
sourcepub fn new(next_idx: u64, ins_size: usize) -> Self
pub fn new(next_idx: u64, ins_size: usize) -> Self
Creates a new progress with the given settings.
sourcepub fn become_probe(&mut self)
pub fn become_probe(&mut self)
Changes the progress to a probe.
sourcepub fn become_replicate(&mut self)
pub fn become_replicate(&mut self)
Changes the progress to a Replicate.
sourcepub fn become_snapshot(&mut self, snapshot_idx: u64)
pub fn become_snapshot(&mut self, snapshot_idx: u64)
Changes the progress to a snapshot.
sourcepub fn snapshot_failure(&mut self)
pub fn snapshot_failure(&mut self)
Sets the snapshot to failure.
sourcepub fn is_snapshot_caught_up(&self) -> bool
pub fn is_snapshot_caught_up(&self) -> bool
Returns true if Match is equal or higher than the pendingSnapshot.
sourcepub fn maybe_update(&mut self, n: u64) -> bool
pub fn maybe_update(&mut self, n: u64) -> bool
Returns false if the given n index comes from an outdated message. Otherwise it updates the progress and returns true.
sourcepub fn update_committed(&mut self, committed_index: u64)
pub fn update_committed(&mut self, committed_index: u64)
update committed_index.
sourcepub fn optimistic_update(&mut self, n: u64)
pub fn optimistic_update(&mut self, n: u64)
Optimistically advance the index
sourcepub fn maybe_decr_to(
&mut self,
rejected: u64,
match_hint: u64,
request_snapshot: u64
) -> bool
pub fn maybe_decr_to( &mut self, rejected: u64, match_hint: u64, request_snapshot: u64 ) -> bool
Returns false if the given index comes from an out of order message. Otherwise it decreases the progress next index to min(rejected, last) and returns true.
sourcepub fn update_state(&mut self, last: u64)
pub fn update_state(&mut self, last: u64)
Update inflight msgs and next_idx