raftstore

package
v0.0.0-...-16dfdc2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLogNotFound indicates a given log entry is not available.
	ErrLogNotFound = errors.New("log not found")
)

Functions

This section is empty.

Types

type InmemStore

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

InmemStore implements the LogStore and StableStore interface. It should NOT EVER be used for production. It is used only for unit tests. Use the MDBStore implementation instead.

func NewInmemStore

func NewInmemStore() *InmemStore

NewInmemStore returns a new in-memory backend. Do not ever use for production. Only for testing.

func (*InmemStore) Close

func (i *InmemStore) Close() error

func (*InmemStore) CreateSnapshotMeta

func (i *InmemStore) CreateSnapshotMeta(applyIndex uint64) ([]*logstream.SegmentFile, error)

func (*InmemStore) DeleteFiles

func (i *InmemStore) DeleteFiles(segmentNames []string) error

func (*InmemStore) DeleteRaftLog

func (i *InmemStore) DeleteRaftLog(rindex uint64) error

func (*InmemStore) DeleteToEnd

func (i *InmemStore) DeleteToEnd(start int64) error

DeleteRange implements the LogStore interface.

func (*InmemStore) Entries

func (i *InmemStore) Entries(lo, hi, maxSize uint64) ([]raftpb.Entry, error)

Entries returns a slice of log entries in the range [lo,hi). MaxSize limits the total size of the log entries returned, but Entries returns at least one entry if any.

func (*InmemStore) FetchLogStreamMessages

func (i *InmemStore) FetchLogStreamMessages(startVindex int64, endRindex uint64, maxBytes int32) ([]logstream.Entry, error, bool)

fetch log stream messages, from startVindex, to raft log index is endRindex maxBytes means max bytes fetch. when there have entry from startVindex, return at least one entry event if the one entry large than maxBytes .

func (*InmemStore) FirstIndex

func (i *InmemStore) FirstIndex() (uint64, error)

FirstIndex implements the LogStore interface.

func (*InmemStore) Get

func (i *InmemStore) Get(key []byte) ([]byte, error)

Get implements the StableStore interface.

func (*InmemStore) GetEntry

func (i *InmemStore) GetEntry(index uint64) (*raftpb.Entry, error)

GetLog implements the LogStore interface.

func (*InmemStore) GetUint64

func (i *InmemStore) GetUint64(key []byte) (uint64, error)

GetUint64 implements the StableStore interface.

func (*InmemStore) GetVindexByRindex

func (i *InmemStore) GetVindexByRindex(rindex uint64) (int64, error)

get vdl index from raft index

func (*InmemStore) IsNewStore

func (i *InmemStore) IsNewStore() bool

func (*InmemStore) LastIndex

func (i *InmemStore) LastIndex() (uint64, error)

LastIndex implements the LogStore interface.

func (*InmemStore) MaxVindex

func (i *InmemStore) MaxVindex(maxRindex uint64) (int64, error)

use to fetch the max offset index (kafka max offset currently) the return value should max log stream offset but <= maxOffset(param)

func (*InmemStore) MinVindex

func (i *InmemStore) MinVindex() (int64, error)

use to fetch the min offset index(kafka min offset currently)

func (*InmemStore) Set

func (i *InmemStore) Set(key []byte, val []byte) error

Set implements the StableStore interface.

func (*InmemStore) SetUint64

func (i *InmemStore) SetUint64(key []byte, val uint64) error

SetUint64 implements the StableStore interface.

func (*InmemStore) Snapshot

func (i *InmemStore) Snapshot() (raftpb.Snapshot, error)

Snapshot returns the most recent snapshot. If snapshot is temporarily unavailable, it should return ErrSnapshotTemporarilyUnavailable, so raft state machine could know that Storage needs some time to prepare snapshot and call Snapshot later.

func (*InmemStore) StoreEntries

func (i *InmemStore) StoreEntries(entries []raftpb.Entry) error

StoreLogs implements the LogStore interface.

func (*InmemStore) Term

func (i *InmemStore) Term(idx uint64) (uint64, 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.

type LogStore

type LogStore interface {
	raft.Storage

	// StoreLogs stores multiple log entries.
	StoreEntries(entries []raftpb.Entry) error

	// Delete log entries from the start index to the end.
	DeleteRaftLog(rindex uint64) error

	// Delete segment file by name.
	DeleteFiles(segmentNames []string) error

	// return whether is new store base on the dir
	IsNewStore() bool

	//get vdl index from raft index
	GetVindexByRindex(rindex uint64) (int64, error)

	// close store
	Close() error

	// use to fetch the max offset index (kafka max offset currently)
	// the return value should max log stream offset but <= maxOffset(param)
	MaxVindex(maxRindex uint64) (int64, error)

	// use to fetch the min offset index(kafka min offset currently)
	MinVindex() (int64, error)

	// fetch log stream messages, from startVindex, to raft log index is endRindex
	// maxBytes means max bytes fetch.
	// when there have entry from startVindex, return at least one entry event if the one entry large than maxBytes .
	// bool return whether read from cache
	FetchLogStreamMessages(startVindex int64, endRindex uint64, maxBytes int32) ([]logstream.Entry, error, bool)

	//create the metadata of segment and index file before applyIndex
	CreateSnapshotMeta(applyIndex uint64) ([]*logstream.SegmentFile, error)
}

LogStore is used to provide an interface for storing and retrieving logs in a durable fashion.

Jump to

Keyboard shortcuts

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