raftState and applyState change to pointer (#179)

Co-authored-by: Connor <zbk602423539@gmail.com>
This commit is contained in:
Lin ZiHao 2020-05-22 10:54:54 +08:00 committed by GitHub
parent b4a7a561f8
commit b6d7c442e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -34,9 +34,9 @@ type PeerStorage struct {
// current region information of the peer // current region information of the peer
region *metapb.Region region *metapb.Region
// current raft state of the peer // current raft state of the peer
raftState rspb.RaftLocalState raftState *rspb.RaftLocalState
// current apply state of the peer // current apply state of the peer
applyState rspb.RaftApplyState applyState *rspb.RaftApplyState
// current snapshot state // current snapshot state
snapState snap.SnapState snapState snap.SnapState
@ -69,8 +69,8 @@ func NewPeerStorage(engines *engine_util.Engines, region *metapb.Region, regionS
Engines: engines, Engines: engines,
region: region, region: region,
Tag: tag, Tag: tag,
raftState: *raftState, raftState: raftState,
applyState: *applyState, applyState: applyState,
regionSched: regionSched, regionSched: regionSched,
}, nil }, nil
} }

View File

@ -37,7 +37,7 @@ func newTestPeerStorageFromEnts(t *testing.T, ents []eraftpb.Entry) *PeerStorage
Term: ents[0].Term, Term: ents[0].Term,
} }
applyState.AppliedIndex = ents[len(ents)-1].Index applyState.AppliedIndex = ents[len(ents)-1].Index
kvWB.SetMeta(meta.ApplyStateKey(peerStore.region.GetId()), &applyState) kvWB.SetMeta(meta.ApplyStateKey(peerStore.region.GetId()), applyState)
require.Nil(t, peerStore.Engines.WriteRaft(raftWB)) require.Nil(t, peerStore.Engines.WriteRaft(raftWB))
peerStore.Engines.WriteKV(kvWB) peerStore.Engines.WriteKV(kvWB)
return peerStore return peerStore
@ -86,7 +86,7 @@ func TestPeerStorageTerm(t *testing.T) {
func appendEnts(t *testing.T, peerStore *PeerStorage, ents []eraftpb.Entry) { func appendEnts(t *testing.T, peerStore *PeerStorage, ents []eraftpb.Entry) {
raftWB := new(engine_util.WriteBatch) raftWB := new(engine_util.WriteBatch)
require.Nil(t, peerStore.Append(ents, raftWB)) require.Nil(t, peerStore.Append(ents, raftWB))
raftWB.SetMeta(meta.RaftStateKey(peerStore.region.GetId()), &peerStore.raftState) raftWB.SetMeta(meta.RaftStateKey(peerStore.region.GetId()), peerStore.raftState)
require.Nil(t, peerStore.Engines.WriteRaft(raftWB)) require.Nil(t, peerStore.Engines.WriteRaft(raftWB))
} }