|
@@ -30,7 +30,7 @@ import (
|
|
|
"github.com/coreos/etcd/raft"
|
|
"github.com/coreos/etcd/raft"
|
|
|
"github.com/coreos/etcd/raft/raftpb"
|
|
"github.com/coreos/etcd/raft/raftpb"
|
|
|
"github.com/coreos/etcd/rafthttp"
|
|
"github.com/coreos/etcd/rafthttp"
|
|
|
- "github.com/coreos/etcd/snap"
|
|
|
|
|
|
|
+ "github.com/coreos/etcd/raftsnap"
|
|
|
"github.com/coreos/etcd/wal"
|
|
"github.com/coreos/etcd/wal"
|
|
|
"github.com/coreos/etcd/wal/walpb"
|
|
"github.com/coreos/etcd/wal/walpb"
|
|
|
)
|
|
)
|
|
@@ -59,8 +59,8 @@ type raftNode struct {
|
|
|
raftStorage *raft.MemoryStorage
|
|
raftStorage *raft.MemoryStorage
|
|
|
wal *wal.WAL
|
|
wal *wal.WAL
|
|
|
|
|
|
|
|
- snapshotter *snap.Snapshotter
|
|
|
|
|
- snapshotterReady chan *snap.Snapshotter // signals when snapshotter is ready
|
|
|
|
|
|
|
+ snapshotter *raftsnap.Snapshotter
|
|
|
|
|
+ snapshotterReady chan *raftsnap.Snapshotter // signals when snapshotter is ready
|
|
|
|
|
|
|
|
snapCount uint64
|
|
snapCount uint64
|
|
|
transport *rafthttp.Transport
|
|
transport *rafthttp.Transport
|
|
@@ -77,7 +77,7 @@ var defaultSnapCount uint64 = 10000
|
|
|
// commit channel, followed by a nil message (to indicate the channel is
|
|
// commit channel, followed by a nil message (to indicate the channel is
|
|
|
// current), then new log entries. To shutdown, close proposeC and read errorC.
|
|
// current), then new log entries. To shutdown, close proposeC and read errorC.
|
|
|
func newRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte, error), proposeC <-chan string,
|
|
func newRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte, error), proposeC <-chan string,
|
|
|
- confChangeC <-chan raftpb.ConfChange) (<-chan *string, <-chan error, <-chan *snap.Snapshotter) {
|
|
|
|
|
|
|
+ confChangeC <-chan raftpb.ConfChange) (<-chan *string, <-chan error, <-chan *raftsnap.Snapshotter) {
|
|
|
|
|
|
|
|
commitC := make(chan *string)
|
|
commitC := make(chan *string)
|
|
|
errorC := make(chan error)
|
|
errorC := make(chan error)
|
|
@@ -98,7 +98,7 @@ func newRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte,
|
|
|
httpstopc: make(chan struct{}),
|
|
httpstopc: make(chan struct{}),
|
|
|
httpdonec: make(chan struct{}),
|
|
httpdonec: make(chan struct{}),
|
|
|
|
|
|
|
|
- snapshotterReady: make(chan *snap.Snapshotter, 1),
|
|
|
|
|
|
|
+ snapshotterReady: make(chan *raftsnap.Snapshotter, 1),
|
|
|
// rest of structure populated after WAL replay
|
|
// rest of structure populated after WAL replay
|
|
|
}
|
|
}
|
|
|
go rc.startRaft()
|
|
go rc.startRaft()
|
|
@@ -188,7 +188,7 @@ func (rc *raftNode) publishEntries(ents []raftpb.Entry) bool {
|
|
|
|
|
|
|
|
func (rc *raftNode) loadSnapshot() *raftpb.Snapshot {
|
|
func (rc *raftNode) loadSnapshot() *raftpb.Snapshot {
|
|
|
snapshot, err := rc.snapshotter.Load()
|
|
snapshot, err := rc.snapshotter.Load()
|
|
|
- if err != nil && err != snap.ErrNoSnapshot {
|
|
|
|
|
|
|
+ if err != nil && err != raftsnap.ErrNoSnapshot {
|
|
|
log.Fatalf("raftexample: error loading snapshot (%v)", err)
|
|
log.Fatalf("raftexample: error loading snapshot (%v)", err)
|
|
|
}
|
|
}
|
|
|
return snapshot
|
|
return snapshot
|
|
@@ -261,7 +261,7 @@ func (rc *raftNode) startRaft() {
|
|
|
log.Fatalf("raftexample: cannot create dir for snapshot (%v)", err)
|
|
log.Fatalf("raftexample: cannot create dir for snapshot (%v)", err)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- rc.snapshotter = snap.New(rc.snapdir)
|
|
|
|
|
|
|
+ rc.snapshotter = raftsnap.New(rc.snapdir)
|
|
|
rc.snapshotterReady <- rc.snapshotter
|
|
rc.snapshotterReady <- rc.snapshotter
|
|
|
|
|
|
|
|
oldwal := wal.Exist(rc.waldir)
|
|
oldwal := wal.Exist(rc.waldir)
|