Skip to content

Commit

Permalink
change: InitialState: rename last_applied_log to last_applied
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Sep 14, 2021
1 parent f383db7 commit ac4bf4b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion async-raft/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> Ra
self.current_term = state.hard_state.current_term;
self.voted_for = state.hard_state.voted_for;
self.membership = state.membership;
self.last_applied = state.last_applied_log;
self.last_applied = state.last_applied;
// NOTE: this is repeated here for clarity. It is unsafe to initialize the node's commit
// index to any other value. The commit index must be determined by a leader after
// successfully committing a new log to the cluster.
Expand Down
6 changes: 4 additions & 2 deletions async-raft/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ pub struct InitialState {
pub last_log_id: LogId,

/// The LogId of the last log applied to the state machine.
pub last_applied_log: LogId,
pub last_applied: LogId,

/// The saved hard state of the node.
pub hard_state: HardState,

/// The latest cluster membership configuration found in the log, else a new initial
/// membership config consisting only of this node's ID.
pub membership: MembershipConfig,
Expand All @@ -79,7 +81,7 @@ impl InitialState {
pub fn new_initial(id: NodeId) -> Self {
Self {
last_log_id: LogId { term: 0, index: 0 },
last_applied_log: LogId { term: 0, index: 0 },
last_applied: LogId { term: 0, index: 0 },
hard_state: HardState {
current_term: 0,
voted_for: None,
Expand Down
2 changes: 1 addition & 1 deletion memstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ impl RaftStorage<ClientRequest, ClientResponse> for MemStore {

Ok(InitialState {
last_log_id,
last_applied_log,
last_applied: last_applied_log,
hard_state: inner.clone(),
membership,
})
Expand Down
4 changes: 2 additions & 2 deletions memstore/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ where
"unexpected default value for last log"
);
assert_eq!(
initial.last_applied_log,
initial.last_applied,
LogId { term: 0, index: 0 },
"unexpected value for last applied log"
);
Expand Down Expand Up @@ -290,7 +290,7 @@ where
"state machine has higher log"
);
assert_eq!(
initial.last_applied_log,
initial.last_applied,
LogId { term: 3, index: 1 },
"unexpected value for last applied log"
);
Expand Down

0 comments on commit ac4bf4b

Please sign in to comment.