Documentation ¶
Index ¶
- func LatestIndex(dir string) (uint64, error)
- func RemoveAllTmpSnapshotData(dir string) error
- func ResetStats()
- func Upgrade(old, new string, logger *log.Logger) (retErr error)
- type LockingSink
- type LockingSnapshot
- type Sink
- type Snapshot
- type Store
- func (s *Store) Create(version raft.SnapshotVersion, index, term uint64, ...) (retSink raft.SnapshotSink, retErr error)
- func (s *Store) Dir() string
- func (s *Store) FullNeeded() (bool, error)
- func (s *Store) List() ([]*raft.SnapshotMeta, error)
- func (s *Store) Open(id string) (_ *raft.SnapshotMeta, _ io.ReadCloser, retErr error)
- func (s *Store) Reap() (retN int, retErr error)
- func (s *Store) SetFullNeeded() error
- func (s *Store) Stats() (map[string]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LatestIndex ¶ added in v8.16.5
LatestIndex returns the index of the latest snapshot in the given directory.
func RemoveAllTmpSnapshotData ¶
RemoveAllTmpSnapshotData removes all temporary Snapshot data from the directory. This process is defined as follows: for every directory in dir, if the directory is a temporary directory, remove the directory. Then remove all other files that contain the name of a temporary directory, minus the temporary suffix, as prefix.
func ResetStats ¶
func ResetStats()
ResetStats resets the expvar stats for this module. Mostly for test purposes.
Types ¶
type LockingSink ¶
type LockingSink struct { raft.SnapshotSink // contains filtered or unexported fields }
LockingSink is a wrapper around a SnapshotSink holds the CAS lock while the Sink is in use.
func NewLockingSink ¶ added in v8.24.1
func NewLockingSink(sink raft.SnapshotSink, str *Store) *LockingSink
NewLockingSink returns a new LockingSink.
func (*LockingSink) Cancel ¶
func (s *LockingSink) Cancel() error
Cancel cancels the sink, unlocking the Store for creation of a new sink.
func (*LockingSink) Close ¶
func (s *LockingSink) Close() error
Close closes the sink, unlocking the Store for creation of a new sink.
type LockingSnapshot ¶ added in v8.24.1
LockingSnapshot is a snapshot which holds the Snapshot Store CAS while open.
func NewLockingSnapshot ¶ added in v8.24.1
func NewLockingSnapshot(fd *os.File, str *Store) *LockingSnapshot
NewLockingSink returns a new LockingSink.
func (*LockingSnapshot) Close ¶ added in v8.24.1
func (l *LockingSnapshot) Close() error
Close closes the Snapshot and releases the Snapshot Store lock.
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink is a sink for writing snapshot data to a Snapshot store.
func NewSink ¶
func NewSink(str *Store, meta *raft.SnapshotMeta) *Sink
NewSink creates a new Sink object.
func (*Sink) Cancel ¶
Cancel cancels the snapshot. Cancel must be called if the snapshot is not going to be closed.
func (*Sink) Close ¶
Close closes the sink, and finalizes creation of the snapshot. It is critical that Close is called, or the snapshot will not be in place. It is OK to call Close without every calling Write. In that case the Snapshot will be finalized as usual, but will effectively be the same as the previously created snapshot.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot represents a snapshot of the database state.
type Store ¶
type Store struct { LogReaping bool // contains filtered or unexported fields }
Store stores Snapshots.
func (*Store) Create ¶
func (s *Store) Create(version raft.SnapshotVersion, index, term uint64, configuration raft.Configuration, configurationIndex uint64, trans raft.Transport) (retSink raft.SnapshotSink, retErr error)
Create creates a new Sink object, ready for writing a snapshot. Sinks make certain assumptions about the state of the store, and if those assumptions were changed by another Sink writing to the store it could cause failures. Therefore we only allow 1 Sink to be in existence at a time. This shouldn't be a problem, since snapshots are taken infrequently in one at a time.
func (*Store) FullNeeded ¶
FullNeeded returns true if a full snapshot is needed.
func (*Store) List ¶
func (s *Store) List() ([]*raft.SnapshotMeta, error)
List returns a list of all the snapshots in the Store. In practice, this will at most be a list of 1, and that will be the newest snapshot available.
func (*Store) Open ¶
func (s *Store) Open(id string) (_ *raft.SnapshotMeta, _ io.ReadCloser, retErr error)
Open opens the snapshot with the given ID. Close() must be called on the snapshot when finished with it.
func (*Store) Reap ¶
Reap reaps all snapshots, except the most recent one. Returns the number of snapshots reaped. This function does not take the Store CAS lock, and so it is up to the caller to ensure no other operations are happening on the Store.
func (*Store) SetFullNeeded ¶
SetFullNeeded sets the flag that indicates a full snapshot is needed. This flag will be cleared when a snapshot is successfully persisted.