mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #2164 from barakmich/2160redux
migrate: convert 0.4 terms to start at 1
This commit is contained in:
commit
62b0fe50eb
@ -29,6 +29,9 @@ import (
|
|||||||
"github.com/coreos/etcd/wal/walpb"
|
"github.com/coreos/etcd/wal/walpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// We need an offset in leader election terms, because term 0 is special in 2.0.
|
||||||
|
const termOffset4to2 = 1
|
||||||
|
|
||||||
func snapDir4(dataDir string) string {
|
func snapDir4(dataDir string) string {
|
||||||
return path.Join(dataDir, "snapshot")
|
return path.Join(dataDir, "snapshot")
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ func toEntry2(ent4 *etcd4pb.LogEntry, raftMap map[string]uint64) (*raftpb.Entry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ent2 := raftpb.Entry{
|
ent2 := raftpb.Entry{
|
||||||
Term: ent4.GetTerm(),
|
Term: ent4.GetTerm() + termOffset4to2,
|
||||||
Index: ent4.GetIndex(),
|
Index: ent4.GetIndex(),
|
||||||
Type: cmd4.Type2(),
|
Type: cmd4.Type2(),
|
||||||
Data: data,
|
Data: data,
|
||||||
|
@ -195,7 +195,7 @@ func (s *Snapshot4) Snapshot2() *raftpb.Snapshot {
|
|||||||
Data: newState,
|
Data: newState,
|
||||||
Metadata: raftpb.SnapshotMetadata{
|
Metadata: raftpb.SnapshotMetadata{
|
||||||
Index: s.LastIndex,
|
Index: s.LastIndex,
|
||||||
Term: s.LastTerm,
|
Term: s.LastTerm + termOffset4to2,
|
||||||
ConfState: raftpb.ConfState{
|
ConfState: raftpb.ConfState{
|
||||||
Nodes: nodeList,
|
Nodes: nodeList,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user