package snap
import "go.etcd.io/etcd/server/v3/etcdserver/api/snap"
Package snap handles Raft nodes' states with snapshots. The snapshot logic is internal to etcd server and raft package.
Index ¶
- Variables
- func Read(lg *zap.Logger, snapname string) (*raftpb.Snapshot, error)
- type Message
- func NewMessage(rs raftpb.Message, rc io.ReadCloser, rcSize int64) *Message
- func (m Message) CloseNotify() <-chan bool
- func (m Message) CloseWithError(err error)
- type Snapshotter
- func New(lg *zap.Logger, dir string) *Snapshotter
- func (s *Snapshotter) DBFilePath(id uint64) (string, error)
- func (s *Snapshotter) Load() (*raftpb.Snapshot, error)
- func (s *Snapshotter) LoadNewestAvailable(walSnaps []walpb.Snapshot) (*raftpb.Snapshot, error)
- func (s *Snapshotter) ReleaseSnapDBs(snap raftpb.Snapshot) error
- func (s *Snapshotter) SaveDBFrom(r io.Reader, id uint64) (int64, error)
- func (s *Snapshotter) SaveSnap(snapshot raftpb.Snapshot) error
Variables ¶
var ( ErrNoSnapshot = errors.New("snap: no available snapshot") ErrEmptySnapshot = errors.New("snap: empty snapshot") ErrCRCMismatch = errors.New("snap: crc mismatch") )
Functions ¶
func Read ¶
Read reads the snapshot named by snapname and returns the snapshot.
Types ¶
type Message ¶
type Message struct { raftpb.Message ReadCloser io.ReadCloser TotalSize int64 // contains filtered or unexported fields }
Message is a struct that contains a raft Message and a ReadCloser. The type of raft message MUST be MsgSnap, which contains the raft meta-data and an additional data []byte field that contains the snapshot of the actual state machine. Message contains the ReadCloser field for handling large snapshot. This avoid copying the entire snapshot into a byte array, which consumes a lot of memory.
User of Message should close the Message after sending it.
func NewMessage ¶
func (Message) CloseNotify ¶
CloseNotify returns a channel that receives a single value when the message sent is finished. true indicates the sent is successful.
func (Message) CloseWithError ¶
type Snapshotter ¶
type Snapshotter struct {
// contains filtered or unexported fields
}
func New ¶
func New(lg *zap.Logger, dir string) *Snapshotter
func (*Snapshotter) DBFilePath ¶
func (s *Snapshotter) DBFilePath(id uint64) (string, error)
DBFilePath returns the file path for the snapshot of the database with given id. If the snapshot does not exist, it returns error.
func (*Snapshotter) Load ¶
func (s *Snapshotter) Load() (*raftpb.Snapshot, error)
Load returns the newest snapshot.
func (*Snapshotter) LoadNewestAvailable ¶
LoadNewestAvailable loads the newest snapshot available that is in walSnaps.
func (*Snapshotter) ReleaseSnapDBs ¶
func (s *Snapshotter) ReleaseSnapDBs(snap raftpb.Snapshot) error
func (*Snapshotter) SaveDBFrom ¶
SaveDBFrom saves snapshot of the database from the given reader. It guarantees the save operation is atomic.
func (*Snapshotter) SaveSnap ¶
func (s *Snapshotter) SaveSnap(snapshot raftpb.Snapshot) error
Source Files ¶
db.go doc.go message.go metrics.go snapshotter.go
Directories ¶
Path | Synopsis |
---|---|
etcdserver/api/snap/snappb |
- Version
- v3.5.18 (latest)
- Published
- Jan 24, 2025
- Platform
- linux/amd64
- Imports
- 21 packages
- Last checked
- 5 days ago –
Tools for package owners.