Documentation ¶
Overview ¶
Package logdb implements the persistent log storage used by Dragonboat.
This package is internally used by Dragonboat, applications are not expected to import this package.
Index ¶
- Constants
- Variables
- func GetLogDBInfo(f config.LogDBFactoryFunc, nhDirs []string, fs vfs.IFS) (name string, err error)
- func NewDefaultBatchedLogDB(dirs []string, lldirs []string, fs vfs.IFS) (raftio.ILogDB, error)
- func NewDefaultLogDB(dirs []string, lldirs []string, fs vfs.IFS) (raftio.ILogDB, error)
- func NewLogDB(dirs []string, lldirs []string, batched bool, check bool, fs vfs.IFS, ...) (raftio.ILogDB, error)
- type LogReader
- func (lr *LogReader) Append(entries []pb.Entry) error
- func (lr *LogReader) ApplySnapshot(snapshot pb.Snapshot) error
- func (lr *LogReader) Compact(index uint64) error
- func (lr *LogReader) CreateSnapshot(snapshot pb.Snapshot) error
- func (lr *LogReader) Entries(low uint64, high uint64, maxSize uint64) ([]pb.Entry, error)
- func (lr *LogReader) GetRange() (uint64, uint64)
- func (lr *LogReader) NodeState() (pb.State, pb.Membership)
- func (lr *LogReader) SetRange(firstIndex uint64, length uint64)
- func (lr *LogReader) SetState(s pb.State)
- func (lr *LogReader) Snapshot() pb.Snapshot
- func (lr *LogReader) Term(index uint64) (uint64, error)
- type PooledKey
- func (k *PooledKey) Key() []byte
- func (k *PooledKey) Release()
- func (k *PooledKey) SetEntryBatchKey(clusterID uint64, nodeID uint64, batchID uint64)
- func (k *PooledKey) SetEntryKey(clusterID uint64, nodeID uint64, index uint64)
- func (k *PooledKey) SetMaxIndexKey(clusterID uint64, nodeID uint64)
- func (k *PooledKey) SetMaximumKey()
- func (k *PooledKey) SetMinimumKey()
- func (k *PooledKey) SetStateKey(clusterID uint64, nodeID uint64)
- type ShardedRDB
- func (mw *ShardedRDB) BinaryFormat() uint32
- func (mw *ShardedRDB) Close()
- func (mw *ShardedRDB) CompactEntriesTo(clusterID uint64, nodeID uint64, index uint64) (<-chan struct{}, error)
- func (mw *ShardedRDB) DeleteSnapshot(clusterID uint64, nodeID uint64, snapshotIndex uint64) error
- func (mw *ShardedRDB) GetBootstrapInfo(clusterID uint64, nodeID uint64) (*pb.Bootstrap, error)
- func (mw *ShardedRDB) GetLogDBThreadContext() raftio.IContext
- func (mw *ShardedRDB) ImportSnapshot(ss pb.Snapshot, nodeID uint64) error
- func (mw *ShardedRDB) IterateEntries(ents []pb.Entry, size uint64, clusterID uint64, nodeID uint64, low uint64, ...) ([]pb.Entry, uint64, error)
- func (mw *ShardedRDB) ListNodeInfo() ([]raftio.NodeInfo, error)
- func (mw *ShardedRDB) ListSnapshots(clusterID uint64, nodeID uint64, index uint64) ([]pb.Snapshot, error)
- func (mw *ShardedRDB) Name() string
- func (mw *ShardedRDB) ReadRaftState(clusterID uint64, nodeID uint64, lastIndex uint64) (*raftio.RaftState, error)
- func (mw *ShardedRDB) RemoveEntriesTo(clusterID uint64, nodeID uint64, index uint64) error
- func (mw *ShardedRDB) RemoveNodeData(clusterID uint64, nodeID uint64) error
- func (mw *ShardedRDB) SaveBootstrapInfo(clusterID uint64, nodeID uint64, bootstrap pb.Bootstrap) error
- func (mw *ShardedRDB) SaveRaftState(updates []pb.Update, ctx raftio.IContext) error
- func (mw *ShardedRDB) SaveSnapshots(updates []pb.Update) error
- func (mw *ShardedRDB) SelfCheckFailed() (bool, error)
Constants ¶
const (
// DefaultKVStoreTypeName is the type name of the default kv store
DefaultKVStoreTypeName = "rocksdb"
)
Variables ¶
var ( // RDBContextValueSize defines the size of byte array managed in RDB context. RDBContextValueSize uint64 = 1024 * 1024 * 64 )
Functions ¶
func GetLogDBInfo ¶
GetLogDBInfo returns logdb type name.
func NewDefaultBatchedLogDB ¶
NewDefaultBatchedLogDB creates a Log DB instance using the default KV store implementation with batched entry support.
func NewDefaultLogDB ¶
NewDefaultLogDB creates a Log DB instance using the default KV store implementation. The created Log DB tries to store entry records in plain format but it switches to the batched mode if there is already batched entries saved in the existing DB.
func NewLogDB ¶
func NewLogDB(dirs []string, lldirs []string, batched bool, check bool, fs vfs.IFS, f kvFactory) (raftio.ILogDB, error)
NewLogDB creates a Log DB instance based on provided configuration parameters. The underlying KV store used by the Log DB instance is created by the provided factory function.
Types ¶
type LogReader ¶
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 ¶
NewLogReader creates and returns a new LogReader instance.
func (*LogReader) Append ¶
Append marks the specified entries as persisted and make them available from logreader.
func (*LogReader) ApplySnapshot ¶
ApplySnapshot applies the specified snapshot.
func (*LogReader) CreateSnapshot ¶
CreateSnapshot keeps the metadata of the specified snapshot.
func (*LogReader) Entries ¶
Entries returns persisted entries between [low, high) with a total limit of up to maxSize bytes.
func (*LogReader) GetRange ¶
GetRange returns the index range of all logs managed by the LogReader instance.
func (*LogReader) NodeState ¶
func (lr *LogReader) NodeState() (pb.State, pb.Membership)
NodeState returns the initial 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 (*PooledKey) SetEntryBatchKey ¶
SetEntryBatchKey sets the key value opf the entry batch.
func (*PooledKey) SetEntryKey ¶
SetEntryKey sets the key value to the specified entry key.
func (*PooledKey) SetMaxIndexKey ¶
SetMaxIndexKey sets the key value to the max index record key.
func (*PooledKey) SetMaximumKey ¶
func (k *PooledKey) SetMaximumKey()
SetMaximumKey sets the key to the maximum possible value.
func (*PooledKey) SetMinimumKey ¶
func (k *PooledKey) SetMinimumKey()
SetMinimumKey sets the key to the minimum possible value.
func (*PooledKey) SetStateKey ¶
SetStateKey sets the key value to the specified State.
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, batched bool, check bool, fs vfs.IFS, kvf kvFactory) (*ShardedRDB, error)
OpenShardedRDB creates a ShardedRDB instance.
func (*ShardedRDB) BinaryFormat ¶
func (mw *ShardedRDB) BinaryFormat() uint32
BinaryFormat is the binary format supported by the sharded DB.
func (*ShardedRDB) CompactEntriesTo ¶
func (mw *ShardedRDB) CompactEntriesTo(clusterID uint64, nodeID uint64, index uint64) (<-chan struct{}, error)
CompactEntriesTo reclaims underlying storage space used for storing entries up to the specified index.
func (*ShardedRDB) DeleteSnapshot ¶
func (mw *ShardedRDB) DeleteSnapshot(clusterID uint64, nodeID uint64, snapshotIndex uint64) error
DeleteSnapshot removes the specified snapshot metadata from the log db.
func (*ShardedRDB) GetBootstrapInfo ¶
GetBootstrapInfo returns the saved bootstrap info for the given node.
func (*ShardedRDB) GetLogDBThreadContext ¶
func (mw *ShardedRDB) GetLogDBThreadContext() raftio.IContext
GetLogDBThreadContext return a IContext instance.
func (*ShardedRDB) ImportSnapshot ¶
func (mw *ShardedRDB) ImportSnapshot(ss pb.Snapshot, nodeID uint64) error
ImportSnapshot imports the snapshot record and other metadata records to the system.
func (*ShardedRDB) IterateEntries ¶
func (mw *ShardedRDB) IterateEntries(ents []pb.Entry, size uint64, clusterID uint64, nodeID uint64, low uint64, high uint64, maxSize uint64) ([]pb.Entry, uint64, error)
IterateEntries returns a list of saved entries starting with index low up to index high with a max size of maxSize.
func (*ShardedRDB) ListNodeInfo ¶
func (mw *ShardedRDB) ListNodeInfo() ([]raftio.NodeInfo, error)
ListNodeInfo lists all available NodeInfo found in the log db.
func (*ShardedRDB) ListSnapshots ¶
func (mw *ShardedRDB) ListSnapshots(clusterID uint64, nodeID uint64, index uint64) ([]pb.Snapshot, error)
ListSnapshots lists all available snapshots associated with the specified raft node.
func (*ShardedRDB) Name ¶
func (mw *ShardedRDB) Name() string
Name returns the type name of the instance.
func (*ShardedRDB) ReadRaftState ¶
func (mw *ShardedRDB) ReadRaftState(clusterID uint64, nodeID uint64, lastIndex uint64) (*raftio.RaftState, error)
ReadRaftState returns the persistent state of the specified raft node.
func (*ShardedRDB) RemoveEntriesTo ¶
func (mw *ShardedRDB) RemoveEntriesTo(clusterID uint64, nodeID uint64, index uint64) error
RemoveEntriesTo removes entries associated with the specified raft node up to the specified index.
func (*ShardedRDB) RemoveNodeData ¶
func (mw *ShardedRDB) RemoveNodeData(clusterID uint64, nodeID uint64) error
RemoveNodeData deletes all node data that belongs to the specified node.
func (*ShardedRDB) SaveBootstrapInfo ¶
func (mw *ShardedRDB) SaveBootstrapInfo(clusterID uint64, nodeID uint64, bootstrap pb.Bootstrap) error
SaveBootstrapInfo saves the specified bootstrap info for the given node.
func (*ShardedRDB) SaveRaftState ¶
SaveRaftState saves the raft state and logs found in the raft.Update list to the log db.
func (*ShardedRDB) SaveSnapshots ¶
func (mw *ShardedRDB) SaveSnapshots(updates []pb.Update) error
SaveSnapshots saves all snapshot metadata found in the raft.Update list.
func (*ShardedRDB) SelfCheckFailed ¶
func (mw *ShardedRDB) SelfCheckFailed() (bool, error)
SelfCheckFailed runs a self check on all db shards and report whether any failure is observed.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
leveldb/levigo
Package levigo provides the ability to create and access LevelDB databases.
|
Package levigo provides the ability to create and access LevelDB databases. |
rocksdb/gorocksdb
Package gorocksdb provides the ability to create and access RocksDB databases.
|
Package gorocksdb provides the ability to create and access RocksDB databases. |