Skip to content

Commit

Permalink
change: rename SnapshotPointer to PurgedMarker
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Aug 24, 2021
1 parent a18b98f commit 5d0c0b2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion async-raft/src/core/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
}
EntryPayload::Blank => {}
EntryPayload::Normal(_) => {}
EntryPayload::SnapshotPointer => {}
EntryPayload::PurgedMarker => {}
}
}

Expand Down
12 changes: 6 additions & 6 deletions async-raft/src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,10 @@ pub struct Entry<D: AppData> {

impl<D: AppData> Entry<D> {
/// Create a new snapshot pointer from the given snapshot meta.
pub fn new_snapshot_pointer(meta: &SnapshotMeta) -> Self {
pub fn new_purged_marker(log_id: LogId) -> Self {
Entry {
log_id: meta.last_log_id,
payload: EntryPayload::SnapshotPointer,
log_id,
payload: EntryPayload::PurgedMarker,
}
}
}
Expand All @@ -530,8 +530,8 @@ pub enum EntryPayload<D: AppData> {
Normal(EntryNormal<D>),
/// A config change log entry.
ConfigChange(EntryConfigChange),
/// An entry which points to a snapshot.
SnapshotPointer,
/// An entry before which all logs are removed.
PurgedMarker,
}

impl<D: AppData> MessageSummary for EntryPayload<D> {
Expand All @@ -542,7 +542,7 @@ impl<D: AppData> MessageSummary for EntryPayload<D> {
EntryPayload::ConfigChange(c) => {
format!("config-change: {:?}", c.membership)
}
EntryPayload::SnapshotPointer => "snapshot-pointer".to_string(),
EntryPayload::PurgedMarker => "purged-marker".to_string(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions async-raft/src/replication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
};

for entry in entries.iter() {
if let EntryPayload::SnapshotPointer = entry.payload {
if let EntryPayload::PurgedMarker = entry.payload {
self.replication_core.target_state = TargetReplState::Snapshotting;
return;
}
Expand Down Expand Up @@ -799,7 +799,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
};

for entry in entries.iter() {
if let EntryPayload::SnapshotPointer = entry.payload {
if let EntryPayload::PurgedMarker = entry.payload {
self.replication_core.target_state = TargetReplState::Snapshotting;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions memstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl RaftStorage<ClientRequest, ClientResponse> for MemStore {

match entry.payload {
EntryPayload::Blank => res.push(ClientResponse(None)),
EntryPayload::SnapshotPointer => res.push(ClientResponse(None)),
EntryPayload::PurgedMarker => res.push(ClientResponse(None)),
EntryPayload::Normal(ref norm) => {
let data = &norm.data;
if let Some((serial, r)) = sm.client_serial_responses.get(&data.client) {
Expand Down Expand Up @@ -406,7 +406,7 @@ impl RaftStorage<ClientRequest, ClientResponse> for MemStore {
*log = log.split_off(&meta.last_log_id.index);

// In case there are no log at all, a marker log need to be added to indicate the last log.
log.insert(meta.last_log_id.index, Entry::new_snapshot_pointer(&meta));
log.insert(meta.last_log_id.index, Entry::new_purged_marker(meta.last_log_id));
}

// Update the state machine.
Expand Down

0 comments on commit 5d0c0b2

Please sign in to comment.