wal

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileCacheCapacity = 2
	DefaultFileSize          = 32 * util.MB
	DefaultSync              = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// FileCacheCapacity  缓存多少个打开的日志文件(包括index等)
	FileCacheCapacity int

	// FileSize 日志文件的大小
	FileSize int

	Sync bool

	// TruncateFirstDummy  初始化时添加一条日志然后截断
	TruncateFirstDummy bool
}

Config wal config

func (*Config) GetFileCacheCapacity

func (c *Config) GetFileCacheCapacity() int

func (*Config) GetFileSize

func (c *Config) GetFileSize() int

func (*Config) GetSync

func (c *Config) GetSync() bool

func (*Config) GetTruncateFirstDummy

func (c *Config) GetTruncateFirstDummy() bool

type ErrCorrupt

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

ErrCorrupt error

func NewCorruptError

func NewCorruptError(filename string, offset int64, reason string) *ErrCorrupt

NewCorruptError new

func (*ErrCorrupt) Error

func (e *ErrCorrupt) Error() string

type Storage

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

Storage the storage

func NewStorage

func NewStorage(id uint64, dir string, c *Config) (*Storage, error)

NewStorage new

func (*Storage) ApplySnapshot

func (s *Storage) ApplySnapshot(meta proto.SnapshotMeta) error

ApplySnapshot Sync snapshot status.

func (*Storage) Close

func (s *Storage) Close()

Close the storage.

func (*Storage) Entries

func (s *Storage) Entries(lo, hi uint64, maxSize uint64) (entries []*proto.Entry, isCompact bool, err error)

Entries returns a slice of log entries in the range [lo,hi), the hi is not inclusive. MaxSize limits the total size of the log entries returned, but Entries returns at least one entry if any. If lo <= CompactIndex,then return isCompact true. If no entries,then return entries nil. Note: math.MaxUint32 is no limit.

func (*Storage) FirstIndex

func (s *Storage) FirstIndex() (index uint64, err error)

FirstIndex returns the index of the first log entry that is possibly available via Entries (older entries have been incorporated into the latest Snapshot; if storage only contains the dummy entry the first log entry is not available).

func (*Storage) InitialState

func (s *Storage) InitialState() (proto.HardState, error)

InitialState returns the saved HardState information to init the repl state.

func (*Storage) LastIndex

func (s *Storage) LastIndex() (index uint64, err error)

LastIndex returns the index of the last entry in the log.

func (*Storage) StoreEntries

func (s *Storage) StoreEntries(entries []*proto.Entry) error

StoreEntries store the log entries to the repository. If first index of entries > LastIndex,then append all entries, Else write entries at first index and truncate the redundant log entries.

func (*Storage) StoreHardState

func (s *Storage) StoreHardState(st proto.HardState) error

StoreHardState store the raft state to the repository.

func (*Storage) Term

func (s *Storage) Term(index uint64) (term uint64, isCompact bool, err error)

Term returns the term of entry i, which must be in the range [FirstIndex()-1, LastIndex()]. The term of the entry before FirstIndex is retained for matching purposes even though the rest of that entry may not be available. If lo <= CompactIndex,then return isCompact true.

func (*Storage) Truncate

func (s *Storage) Truncate(index uint64) error

Truncate the log to index, The index is inclusive.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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