snapshot

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSnapshotOutOfDate is the error to indicate that snapshot is out of date.
	ErrSnapshotOutOfDate = errors.New("snapshot out of date")
	// SnapshotDirNameRe is the regex of snapshot names.
	SnapshotDirNameRe = regexp.MustCompile(`^snapshot-[0-9A-F]+-[0-9A-F]+$`)
	// SnapshotDirNamePartsRe is used to find the index value from snapshot folder name.
	SnapshotDirNamePartsRe = regexp.MustCompile(`^snapshot-([0-9A-F]+)-[0-9A-F]+$`)
	// GenSnapshotDirNameRe is the regex of temp snapshot directory name used when
	// generating snapshots.
	GenSnapshotDirNameRe = regexp.MustCompile(`^snapshot-[0-9A-F]+-[0-9A-F]+\.generating$`)
	// RecvSnapshotDirNameRe is the regex of temp snapshot directory name used when
	// receiving snapshots from remote NodeHosts.
	RecvSnapshotDirNameRe = regexp.MustCompile(`^snapshot-[0-9A-F]+-[0-9A-F]+\.receiving$`)
)

Functions

func GetSnapshotDirName added in v0.2.0

func GetSnapshotDirName(index uint64, extra uint64) string

GetSnapshotDirName returns the snapshot dir name for the snapshot captured at the specified index.

Types

type Mode added in v0.2.0

type Mode uint64

Mode is the snapshot env mode.

const (
	// CreatingMode is the mode used when taking snapshotting.
	CreatingMode Mode = iota
	// ReceivingMode is the mode used when receiving snapshots from remote nodes.
	ReceivingMode
)

type SSEnv added in v0.2.0

type SSEnv struct {
	// contains filtered or unexported fields
}

SSEnv is the struct used to manage involved directories for taking or receiving snapshots.

func NewSSEnv added in v0.2.0

func NewSSEnv(f SnapshotDirFunc,
	shardID uint64, replicaID uint64, index uint64,
	extra uint64, mode Mode, fs vfs.FS) SSEnv

NewSSEnv creates and returns a new SSEnv instance. extra is the replicaID of the sending replica in ReceivingMode or a random uint64 in CreatingMode. It is caller's responsibility to ensure the randomness of the extra value in CreatingMode.

func (*SSEnv) CreateTempDir added in v0.2.0

func (se *SSEnv) CreateTempDir() error

CreateTempDir creates the temp snapshot directory.

func (*SSEnv) FinalDirExists added in v0.2.0

func (se *SSEnv) FinalDirExists() bool

func (*SSEnv) FinalizeIndex added in v0.2.0

func (se *SSEnv) FinalizeIndex(index uint64)

func (*SSEnv) FinalizeSnapshot added in v0.2.0

func (se *SSEnv) FinalizeSnapshot() error

FinalizeSnapshot finalizes the snapshot.

func (*SSEnv) GetFinalDir added in v0.2.0

func (se *SSEnv) GetFinalDir() string

GetFinalDir returns the final snapshot directory.

func (*SSEnv) GetRootDir added in v0.2.0

func (se *SSEnv) GetRootDir() string

GetRootDir returns the root directory. The temp and final snapshot directories are children of the root directory.

func (*SSEnv) GetTempDir added in v0.2.0

func (se *SSEnv) GetTempDir() string

GetTempDir returns the temp snapshot directory.

func (*SSEnv) MustRemoveTempDir added in v0.2.0

func (se *SSEnv) MustRemoveTempDir()

MustRemoveTempDir removes the temp snapshot directory and panic if there is any error.

func (*SSEnv) RemoveFinalDir added in v0.2.0

func (se *SSEnv) RemoveFinalDir() error

RemoveFinalDir removes the final snapshot directory.

func (*SSEnv) RemoveTempDir added in v0.2.0

func (se *SSEnv) RemoveTempDir() error

RemoveTempDir removes the temp snapshot directory.

type SnapshotDirFunc added in v0.2.0

type SnapshotDirFunc func(shardID uint64, replicaID uint64) string

SnapshotDirFunc is the function type that returns the snapshot dir for the specified replica.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL