logdb

package
v0.0.0-...-17369de Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LogDBType is the logdb type name
	LogDBType = "sharded-rocksdb"
)

Variables

View Source
var (

	// RDBContextValueSize defines the size of byte array managed in RDB context.
	RDBContextValueSize uint64 = 1024 * 1024 * 64
)

Functions

func OpenLogDB

func OpenLogDB(dirs []string, lowLatencyDirs []string) (paxosio.ILogDB, error)

OpenLogDB opens a LogDB instance using the default implementation.

Types

type IKvStore

type IKvStore interface {
	// Name is the IKvStore name.
	Name() string
	// Close closes the underlying Key-Value store.
	Close() error
	// IterateValue iterates the key range specified by the first key fk and
	// last key lk. The inc boolean flag indicates whether it is inclusive for
	// the last key lk. For each iterated entry, the specified op will be invoked
	// on that key-value pair, the specified op func returns a boolean flag to
	// indicate whether IterateValue should continue to iterate entries.
	IterateValue(fk []byte,
		lk []byte, inc bool, op func(key []byte, data []byte) (bool, error))
	// GetValue queries the value specified the input key, the returned value
	// byte slice is passed to the specified op func.
	GetValue(key []byte, op func([]byte) error) error
	// Save value saves the specified key value pair to the underlying key-value
	// pair.
	SaveValue(key []byte, value []byte) error
	// DeleteValue deletes the key-value pair specified by the input key.
	DeleteValue(key []byte) error
	// GetWriteBatch returns an IWriteBatch object to be used by RDB.
	GetWriteBatch(ctx paxosio.IContext) IWriteBatch
	// CommitWriteBatch atomically writes everything included in the write batch
	// to the underlying key-value store.
	CommitWriteBatch(wb IWriteBatch) error
	// RemoveEntries removes entries specified by the range [firstKey, lastKey).
	// RemoveEntries is called in the main execution thread of raft, it is
	// suppose to immediately return without significant delay.
	RemoveEntries(firstKey []byte, lastKey []byte) error
	// Compaction is called by the compaction goroutine to compact the key-value
	// store for the specified range [firstKey, lastKey). This method is expected
	// to complete in the order of seconds.
	Compaction(firstKey []byte, lastKey []byte) error
}

IKvStore is the interface used by the RDB struct to access the underlying Key-Value store.

type IWriteBatch

type IWriteBatch interface {
	Destroy()
	Put([]byte, []byte)
	Clear()
	Count() int
}

IWriteBatch is the interface representing a write batch capable of atomically writing many key-value pairs to the key-value store.

type LogReader

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

LogReader is the struct used to manage logs that have already been persisted into LogDB. This implementation is influenced by CockroachDB's replicaRaftStorage.

func NewLogReader

func NewLogReader(groupID uint64, nodeID uint64, logdb paxosio.ILogDB) *LogReader

NewLogReader creates and returns a new LogReader instance.

func (*LogReader) Append

func (lr *LogReader) Append(entries []paxospb.Entry) error

Append ...

func (*LogReader) Compact

func (lr *LogReader) Compact(instanceID uint64) error

Compact compacts paxos log entries up to index

func (*LogReader) Entries

func (lr *LogReader) Entries(low, high uint64) ([]paxospb.Entry, error)

Entries ...

func (*LogReader) GetRange

func (lr *LogReader) GetRange() (uint64, uint64)

GetRange returns the index range of all logs managed by the LogReader instance.

func (*LogReader) NodeState

func (lr *LogReader) NodeState() paxospb.State

NodeState ...

func (*LogReader) SetRange

func (lr *LogReader) SetRange(firstInstanceID, length uint64)

SetRange updates the LogReader to reflect what is available in it.

func (*LogReader) SetState

func (lr *LogReader) SetState(s paxospb.State)

SetState sets the persistent state.

type PooledKey

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

PooledKey represents keys that are managed by a sync.Pool to be reused.

func NewKey

func NewKey(sz uint64, pool *sync.Pool) *PooledKey

NewKey creates and returns a new PooledKey instance.

func (*PooledKey) Key

func (k *PooledKey) Key() []byte

Key returns the []byte of the key.

func (*PooledKey) Release

func (k *PooledKey) Release()

Release puts the key back to the pool.

func (*PooledKey) SetEntryBatchKey

func (k *PooledKey) SetEntryBatchKey(groupID uint64,
	nodeID uint64, batchID uint64)

SetEntryBatchKey sets the key value opf the entry batch.

func (*PooledKey) SetEntryKey

func (k *PooledKey) SetEntryKey(groupID uint64, nodeID uint64, instance uint64)

SetEntryKey sets the key value to the specified entry key.

func (*PooledKey) SetMaxInstanceKey

func (k *PooledKey) SetMaxInstanceKey(groupID uint64, nodeID uint64)

SetMaxInstanceKey sets the key value to the max index record key.

func (*PooledKey) SetStateKey

func (k *PooledKey) SetStateKey(groupID uint64, nodeID uint64)

SetStateKey sets the key value to the specified State.

type RDB

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

RDB is the struct used to manage rocksdb backed persistent Log stores.

type ShardedRDB

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

ShardedRDB is a LogDB implementation using sharded rocksdb instances.

func OpenShardedRDB

func OpenShardedRDB(dirs []string, lldirs []string) (*ShardedRDB, error)

OpenShardedRDB ...

func (*ShardedRDB) Close

func (mw *ShardedRDB) Close()

Close closes the ShardedRDB instance.

func (*ShardedRDB) GetBootstrapInfo

func (mw *ShardedRDB) GetBootstrapInfo(groupID uint64,
	nodeID uint64) (*paxospb.Bootstrap, error)

GetBootstrapInfo returns the saved bootstrap info for the given node.

func (*ShardedRDB) GetLogDBThreadContext

func (mw *ShardedRDB) GetLogDBThreadContext() paxosio.IContext

GetLogDBThreadContext return a IContext instance.

func (*ShardedRDB) IterateEntries

func (mw *ShardedRDB) IterateEntries(groupID uint64, nodeID uint64, low uint64,
	high uint64) ([]paxospb.Entry, error)

IterateEntries ...

func (*ShardedRDB) ListNodeInfo

func (mw *ShardedRDB) ListNodeInfo() ([]paxosio.NodeInfo, error)

ListNodeInfo lists all available NodeInfo found in the log db.

func (*ShardedRDB) Name

func (mw *ShardedRDB) Name() string

Name returns the type name of the instance.

func (*ShardedRDB) ReadPaxosState

func (mw *ShardedRDB) ReadPaxosState(groupID, nodeID, lastInstance uint64) (*paxosio.PaxosState, error)

ReadPaxosState ...

func (*ShardedRDB) SaveBootstrapInfo

func (mw *ShardedRDB) SaveBootstrapInfo(groupID uint64,
	nodeID uint64, bootstrap paxospb.Bootstrap) error

SaveBootstrapInfo saves the specified bootstrap info for the given node.

func (*ShardedRDB) SavePaxosState

func (mw *ShardedRDB) SavePaxosState(updates []paxospb.Update,
	ctx paxosio.IContext) error

SavePaxosState ...

Directories

Path Synopsis
Package gorocksdb provides the ability to create and access RocksDB databases.
Package gorocksdb provides the ability to create and access RocksDB databases.
Package levigo provides the ability to create and access LevelDB databases.
Package levigo provides the ability to create and access LevelDB databases.

Jump to

Keyboard shortcuts

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