snapshot

package
v0.0.0-...-867e715 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrLoaderDone indicates that no more value left in the snapshot to restore.
	ErrLoaderDone = errors.New("loader done")

	// ErrFirstRun indicates that there is no key in the snapshot to restore. Run for the first time.
	ErrFirstRun = errors.New("first run")
)
View Source
var (
	// PrimaryDMapKey is the key on Badger for registered DMap names on partitions.
	PrimaryDMapKey = []byte("primary-dmap-key")

	// BackupDMapKey is the key on Badger for registered DMap names on backups.
	BackupDMapKey = []byte("backup-dmap-key")
)

Functions

This section is empty.

Types

type DMap

type DMap struct {
	PartID  uint64
	Name    string
	Storage *storage.Storage
}

DMap represents a DMap object which's restored from snapshot.

type Loader

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

Loader implements an iterator like mechanism to restore dmaps from snapshot.

func (*Loader) Next

func (l *Loader) Next() (*DMap, error)

Next creates and returns a new DMap from snapshot. It returns ErrLoaderDone when all the DMaps are restored from the snapshot.

type OpLog

type OpLog struct {
	sync.Mutex
	// contains filtered or unexported fields
}

OpLog defines operation log.

func (*OpLog) Delete

func (o *OpLog) Delete(hkey uint64)

Delete logs 'Delete' operation for given hkey.

func (*OpLog) Put

func (o *OpLog) Put(hkey uint64)

Put logs 'Put' operation for given hkey.

type Snapshot

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

Snapshot implements a low-latency snapshot engine with BadgerDB.

func New

func New(opt *badger.Options, snapshotInterval, gcInterval time.Duration,
	gcDiscardRatio float64, logger *log.Logger) (*Snapshot, error)

New creates and returns a new Snapshot.

func (*Snapshot) DestroyDMap

func (s *Snapshot) DestroyDMap(dkey []byte, partID uint64, name string) error

DestroyDMap destroys a dmap's hkeys and releated data on the snapshot.

func (*Snapshot) NewLoader

func (s *Snapshot) NewLoader(dkey []byte) (*Loader, error)

NewLoader creates and returns a new Loader.

func (*Snapshot) RegisterDMap

func (s *Snapshot) RegisterDMap(dkey []byte, partID uint64, name string, str *storage.Storage) (*OpLog, error)

RegisterDMap registers given DMap to the snapshot instance, creates a new worker for its partition if needed and returns an OpLog.

func (*Snapshot) Shutdown

func (s *Snapshot) Shutdown() error

Shutdown closes a DB. It's crucial to call it to ensure all the pending updates make their way to disk.

func (*Snapshot) UnregisterDMap

func (s *Snapshot) UnregisterDMap(dkey []byte, partID uint64, name string) error

UnregisterDMap unregisters a dmap from synchronization list.

Jump to

Keyboard shortcuts

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