Struct raft::Raft
[−]
[src]
pub struct Raft<T: Storage> { pub term: u64, pub vote: u64, pub id: u64, pub read_states: Vec<ReadState>, pub raft_log: RaftLog<T>, pub max_inflight: usize, pub max_msg_size: u64, pub state: StateRole, pub is_learner: bool, pub votes: FlatMap<u64, bool>, pub msgs: Vec<Message>, pub leader_id: u64, pub lead_transferee: Option<u64>, pub pending_conf_index: u64, pub read_only: ReadOnly, pub election_elapsed: usize, pub check_quorum: bool, pub before_step_state: Option<Box<FnMut(&Message) -> bool>>, // some fields omitted }
Fields
term: u64
vote: u64
id: u64
read_states: Vec<ReadState>
raft_log: RaftLog<T>
the log
max_inflight: usize
max_msg_size: u64
state: StateRole
is_learner: bool
votes: FlatMap<u64, bool>
msgs: Vec<Message>
leader_id: u64
the leader id
lead_transferee: Option<u64>
lead_transferee is id of the leader transfer target when its value is not None. Follow the procedure defined in raft thesis 3.10.
pending_conf_index: u64
Only one conf change may be pending (in the log, but not yet applied) at a time. This is enforced via pending_conf_index, which is set to a value >= the log index of the latest pending configuration change (if any). Config changes are only allowed to be proposed if the leader's applied index is greater than this value.
read_only: ReadOnly
election_elapsed: usize
number of ticks since it reached last electionTimeout when it is leader or candidate. number of ticks since it reached last electionTimeout or received a valid message from current leader when it is a follower.
check_quorum: bool
before_step_state: Option<Box<FnMut(&Message) -> bool>>
Will be called when step** is about to be called. return false will skip step**.
Methods
impl<T: Storage> Raft<T>
[src]
fn new(c: &Config, store: T) -> Raft<T>
[src]
fn get_store(&self) -> &T
[src]
fn mut_store(&mut self) -> &mut T
[src]
fn get_snap(&self) -> Option<&Snapshot>
[src]
fn pending_read_count(&self) -> usize
[src]
fn ready_read_count(&self) -> usize
[src]
fn soft_state(&self) -> SoftState
[src]
fn hard_state(&self) -> HardState
[src]
fn in_lease(&self) -> bool
[src]
fn set_randomized_election_timeout(&mut self, t: usize)
[src]
fn get_election_timeout(&self) -> usize
[src]
fn get_heartbeat_timeout(&self) -> usize
[src]
fn get_randomized_election_timeout(&self) -> usize
[src]
fn send_append(&mut self, to: u64, pr: &mut Progress)
[src]
fn bcast_append(&mut self)
[src]
fn bcast_heartbeat(&mut self)
[src]
fn bcast_heartbeat_with_ctx(&mut self, ctx: Option<Vec<u8>>)
[src]
fn maybe_commit(&mut self) -> bool
[src]
fn reset(&mut self, term: u64)
[src]
fn append_entry(&mut self, es: &mut [Entry])
[src]
fn tick(&mut self) -> bool
[src]
Returns true to indicate that there will probably be some readiness need to be handled.
fn tick_election(&mut self) -> bool
[src]
fn become_follower(&mut self, term: u64, leader_id: u64)
[src]
fn become_candidate(&mut self)
[src]
fn become_pre_candidate(&mut self)
[src]
fn become_leader(&mut self)
[src]
fn step(&mut self, m: Message) -> Result<()>
[src]
fn handle_append_entries(&mut self, m: Message)
[src]
fn handle_heartbeat(&mut self, m: Message)
[src]
fn restore(&mut self, snap: Snapshot) -> bool
[src]
fn should_bcast_commit(&self) -> bool
[src]
fn promotable(&self) -> bool
[src]
fn add_node(&mut self, id: u64)
[src]
fn add_learner(&mut self, id: u64)
[src]
fn remove_node(&mut self, id: u64)
[src]
fn set_progress(
&mut self,
id: u64,
matched: u64,
next_idx: u64,
is_learner: bool
)
[src]
&mut self,
id: u64,
matched: u64,
next_idx: u64,
is_learner: bool
)
fn take_prs(&mut self) -> ProgressSet
[src]
fn set_prs(&mut self, prs: ProgressSet)
[src]
fn prs(&self) -> &ProgressSet
[src]
fn mut_prs(&mut self) -> &mut ProgressSet
[src]
fn load_state(&mut self, hs: HardState)
[src]
fn pass_election_timeout(&self) -> bool
[src]
pass_election_timeout
returns true iff election_elapsed
is greater
than or equal to the randomized election timeout in
[election_timeout
, 2 * election_timeout
- 1].