mirror of
https://github.com/talent-plan/tinykv.git
synced 2025-03-15 20:31:03 +08:00
add snapshot data unmarshal
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
This commit is contained in:
parent
499098da90
commit
c303272f5d
@ -311,6 +311,12 @@ func (ps *PeerStorage) Append(entries []eraftpb.Entry, raftWB *engine_util.Write
|
||||
|
||||
// Apply the peer with given snapshot
|
||||
func (ps *PeerStorage) ApplySnapshot(snapshot *eraftpb.Snapshot, kvWB *engine_util.WriteBatch, raftWB *engine_util.WriteBatch) (*ApplySnapResult, error) {
|
||||
log.Infof("%v begin to apply snapshot", ps.Tag)
|
||||
snapData := new(rspb.RaftSnapshotData)
|
||||
if err := snapData.Unmarshal(snapshot.Data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Hint: things need to do here including: update peer storage state like raftState and applyState, etc,
|
||||
// and send RegionTaskApply task to region worker through ps.regionSched, also remember call ps.clearMeta
|
||||
// and ps.clearExtraData to delete stale data
|
||||
@ -322,7 +328,7 @@ func (ps *PeerStorage) ApplySnapshot(snapshot *eraftpb.Snapshot, kvWB *engine_ut
|
||||
// Do not modify ready in this function, this is a requirement to advance the ready object properly later.
|
||||
func (ps *PeerStorage) SaveReadyState(ready *raft.Ready) (*ApplySnapResult, error) {
|
||||
// Hint: you may call `Append()` and `ApplySnapshot()` in this function
|
||||
// Your Code Here (2B).
|
||||
// Your Code Here (2B/2C).
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user