mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: rename "snap" to "raftsnap" package
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
60d5ab5485
commit
6a70a931d3
@ -23,7 +23,7 @@ import (
|
||||
"github.com/coreos/etcd/mvcc"
|
||||
"github.com/coreos/etcd/mvcc/backend"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/snap"
|
||||
"github.com/coreos/etcd/raftsnap"
|
||||
)
|
||||
|
||||
func newBackend(cfg ServerConfig) backend.Backend {
|
||||
@ -37,7 +37,7 @@ func newBackend(cfg ServerConfig) backend.Backend {
|
||||
}
|
||||
|
||||
// openSnapshotBackend renames a snapshot db to the current etcd db and opens it.
|
||||
func openSnapshotBackend(cfg ServerConfig, ss *snap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) {
|
||||
func openSnapshotBackend(cfg ServerConfig, ss *raftsnap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) {
|
||||
snapPath, err := ss.DBFilePath(snapshot.Metadata.Index)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("database snapshot file path error: %v", err)
|
||||
@ -77,5 +77,5 @@ func recoverSnapshotBackend(cfg ServerConfig, oldbe backend.Backend, snapshot ra
|
||||
return oldbe, nil
|
||||
}
|
||||
oldbe.Close()
|
||||
return openSnapshotBackend(cfg, snap.New(cfg.SnapDir()), snapshot)
|
||||
return openSnapshotBackend(cfg, raftsnap.New(cfg.SnapDir()), snapshot)
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ import (
|
||||
"github.com/coreos/etcd/raft"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/rafthttp"
|
||||
"github.com/coreos/etcd/snap"
|
||||
"github.com/coreos/etcd/raftsnap"
|
||||
"github.com/coreos/etcd/store"
|
||||
"github.com/coreos/etcd/version"
|
||||
"github.com/coreos/etcd/wal"
|
||||
@ -206,7 +206,7 @@ type EtcdServer struct {
|
||||
cluster *membership.RaftCluster
|
||||
|
||||
store store.Store
|
||||
snapshotter *snap.Snapshotter
|
||||
snapshotter *raftsnap.Snapshotter
|
||||
|
||||
applyV2 ApplierV2
|
||||
|
||||
@ -279,7 +279,7 @@ func NewServer(cfg ServerConfig) (srv *EtcdServer, err error) {
|
||||
if err = fileutil.TouchDirAll(cfg.SnapDir()); err != nil {
|
||||
plog.Fatalf("create snapshot directory error: %v", err)
|
||||
}
|
||||
ss := snap.New(cfg.SnapDir())
|
||||
ss := raftsnap.New(cfg.SnapDir())
|
||||
|
||||
bepath := cfg.backendPath()
|
||||
beExist := fileutil.Exist(bepath)
|
||||
@ -373,7 +373,7 @@ func NewServer(cfg ServerConfig) (srv *EtcdServer, err error) {
|
||||
plog.Warningf("discovery token ignored since a cluster has already been initialized. Valid log found at %q", cfg.WALDir())
|
||||
}
|
||||
snapshot, err = ss.Load()
|
||||
if err != nil && err != snap.ErrNoSnapshot {
|
||||
if err != nil && err != raftsnap.ErrNoSnapshot {
|
||||
return nil, err
|
||||
}
|
||||
if snapshot != nil {
|
||||
@ -1266,7 +1266,7 @@ func (s *EtcdServer) publish(timeout time.Duration) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EtcdServer) sendMergedSnap(merged snap.Message) {
|
||||
func (s *EtcdServer) sendMergedSnap(merged raftsnap.Message) {
|
||||
atomic.AddInt64(&s.inflightSnapshots, 1)
|
||||
|
||||
s.r.transport.SendSnapshot(merged)
|
||||
|
@ -43,7 +43,7 @@ import (
|
||||
"github.com/coreos/etcd/raft"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/rafthttp"
|
||||
"github.com/coreos/etcd/snap"
|
||||
"github.com/coreos/etcd/raftsnap"
|
||||
"github.com/coreos/etcd/store"
|
||||
)
|
||||
|
||||
@ -986,7 +986,7 @@ func TestSnapshotOrdering(t *testing.T) {
|
||||
Cfg: ServerConfig{DataDir: testdir},
|
||||
r: *r,
|
||||
store: st,
|
||||
snapshotter: snap.New(snapdir),
|
||||
snapshotter: raftsnap.New(snapdir),
|
||||
cluster: cl,
|
||||
SyncTicker: &time.Ticker{},
|
||||
}
|
||||
@ -1111,7 +1111,7 @@ func TestConcurrentApplyAndSnapshotV3(t *testing.T) {
|
||||
Cfg: ServerConfig{DataDir: testdir},
|
||||
r: *r,
|
||||
store: st,
|
||||
snapshotter: snap.New(testdir),
|
||||
snapshotter: raftsnap.New(testdir),
|
||||
cluster: cl,
|
||||
SyncTicker: &time.Ticker{},
|
||||
}
|
||||
|
@ -19,13 +19,13 @@ import (
|
||||
|
||||
"github.com/coreos/etcd/mvcc/backend"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/snap"
|
||||
"github.com/coreos/etcd/raftsnap"
|
||||
)
|
||||
|
||||
// createMergedSnapshotMessage creates a snapshot message that contains: raft status (term, conf),
|
||||
// a snapshot of v2 store inside raft.Snapshot as []byte, a snapshot of v3 KV in the top level message
|
||||
// as ReadCloser.
|
||||
func (s *EtcdServer) createMergedSnapshotMessage(m raftpb.Message, snapt, snapi uint64, confState raftpb.ConfState) snap.Message {
|
||||
func (s *EtcdServer) createMergedSnapshotMessage(m raftpb.Message, snapt, snapi uint64, confState raftpb.ConfState) raftsnap.Message {
|
||||
// get a snapshot of v2 store as []byte
|
||||
clone := s.store.Clone()
|
||||
d, err := clone.SaveNoCopy()
|
||||
@ -51,7 +51,7 @@ func (s *EtcdServer) createMergedSnapshotMessage(m raftpb.Message, snapt, snapi
|
||||
}
|
||||
m.Snapshot = snapshot
|
||||
|
||||
return *snap.NewMessage(m, rc, dbsnap.Size())
|
||||
return *raftsnap.NewMessage(m, rc, dbsnap.Size())
|
||||
}
|
||||
|
||||
func newSnapshotReaderCloser(snapshot backend.Snapshot) io.ReadCloser {
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"github.com/coreos/etcd/pkg/pbutil"
|
||||
"github.com/coreos/etcd/pkg/types"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/snap"
|
||||
"github.com/coreos/etcd/raftsnap"
|
||||
"github.com/coreos/etcd/wal"
|
||||
"github.com/coreos/etcd/wal/walpb"
|
||||
)
|
||||
@ -38,10 +38,10 @@ type Storage interface {
|
||||
|
||||
type storage struct {
|
||||
*wal.WAL
|
||||
*snap.Snapshotter
|
||||
*raftsnap.Snapshotter
|
||||
}
|
||||
|
||||
func NewStorage(w *wal.WAL, s *snap.Snapshotter) Storage {
|
||||
func NewStorage(w *wal.WAL, s *raftsnap.Snapshotter) Storage {
|
||||
return &storage{w, s}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/coreos/etcd/pkg/types"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/rafthttp"
|
||||
"github.com/coreos/etcd/snap"
|
||||
"github.com/coreos/etcd/raftsnap"
|
||||
)
|
||||
|
||||
func TestLongestConnected(t *testing.T) {
|
||||
@ -76,7 +76,7 @@ func newNopTransporterWithActiveTime(memberIDs []types.ID) rafthttp.Transporter
|
||||
func (s *nopTransporterWithActiveTime) Start() error { return nil }
|
||||
func (s *nopTransporterWithActiveTime) Handler() http.Handler { return nil }
|
||||
func (s *nopTransporterWithActiveTime) Send(m []raftpb.Message) {}
|
||||
func (s *nopTransporterWithActiveTime) SendSnapshot(m snap.Message) {}
|
||||
func (s *nopTransporterWithActiveTime) SendSnapshot(m raftsnap.Message) {}
|
||||
func (s *nopTransporterWithActiveTime) AddRemote(id types.ID, us []string) {}
|
||||
func (s *nopTransporterWithActiveTime) AddPeer(id types.ID, us []string) {}
|
||||
func (s *nopTransporterWithActiveTime) RemovePeer(id types.ID) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user