Documentation ¶
Index ¶
- Constants
- Variables
- func AddContextLock(parent context.Context, lock *PoolLock) (context.Context, error)
- func DatabaseExists(cfg *DatabaseConfig) (bool, error)
- func ErrFindingNotFound(seq uint64) error
- func GetLogEntries(log logging.Logger, cfg *DatabaseConfig, maxEntries ...uint64) (<-chan *LogEntryDetails, error)
- func GetRaftConfiguration(log logging.Logger, cfg *DatabaseConfig) (raft.Configuration, error)
- func IsFindingNotFound(err error) bool
- func IsRaftLeadershipError(err error) bool
- func RecoverLocalReplica(log logging.Logger, cfg *DatabaseConfig) error
- func RestoreLocalReplica(log logging.Logger, cfg *DatabaseConfig, snapPath string) error
- type CheckerDatabase
- type CheckerFindingMap
- type Database
- func MockDatabase(t *testing.T, log logging.Logger) *Database
- func MockDatabaseWithAddr(t *testing.T, log logging.Logger, addr *net.TCPAddr) *Database
- func MockDatabaseWithCfg(t *testing.T, log logging.Logger, dbCfg *DatabaseConfig) *Database
- func MockDatabaseWithFaultDomainTree(t *testing.T, log logging.Logger, tree *system.FaultDomainTree) *Database
- func NewDatabase(log logging.Logger, cfg *DatabaseConfig) (*Database, error)
- func TestDatabase(t *testing.T, log logging.Logger, replicas ...*net.TCPAddr) (*Database, func())
- func (db *Database) AddCheckerFinding(finding *checker.Finding) error
- func (db *Database) AddMember(newMember *system.Member) error
- func (db *Database) AddOrUpdateCheckerFinding(finding *checker.Finding) error
- func (db *Database) AddPoolService(ctx context.Context, ps *system.PoolService) error
- func (db *Database) AllMembers() ([]*system.Member, error)
- func (db *Database) Barrier() error
- func (db *Database) CheckLeader() error
- func (db *Database) CheckReplica() error
- func (db *Database) ConfigureTransport(srv *grpc.Server, dialOpts ...grpc.DialOption) error
- func (db *Database) CurMapVersion() (uint32, error)
- func (db *Database) DataVersion() (uint64, error)
- func (db *Database) FaultDomainTree() *system.FaultDomainTree
- func (db *Database) FindMemberByRank(rank ranklist.Rank) (*system.Member, error)
- func (db *Database) FindMemberByUUID(uuid uuid.UUID) (*system.Member, error)
- func (db *Database) FindMembersByAddr(addr *net.TCPAddr) ([]*system.Member, error)
- func (db *Database) FindPoolServiceByLabel(label string) (*system.PoolService, error)
- func (db *Database) FindPoolServiceByUUID(uuid uuid.UUID) (*system.PoolService, error)
- func (db *Database) GetCheckerFinding(seq uint64) (*checker.Finding, error)
- func (db *Database) GetCheckerFindings(searchList ...uint64) ([]*checker.Finding, error)
- func (db *Database) GetSystemAttrs(keys []string, filterFn func(string) bool) (map[string]string, error)
- func (db *Database) GroupMap() (*GroupMap, error)
- func (db *Database) IncMapVer() error
- func (db *Database) IsBootstrap() bool
- func (db *Database) IsLeader() bool
- func (db *Database) IsReplica() bool
- func (db *Database) LeaderQuery() (leader string, replicas []string, err error)
- func (db *Database) MemberCount(desiredStates ...system.MemberState) (int, error)
- func (db *Database) MemberRanks(desiredStates ...system.MemberState) ([]ranklist.Rank, error)
- func (db *Database) OnEvent(_ context.Context, evt *events.RASEvent)
- func (db *Database) OnLeadershipGained(fns ...onLeadershipGainedFn)
- func (db *Database) OnLeadershipLost(fns ...onLeadershipLostFn)
- func (db *Database) OnRaftShutdown(fns ...onRaftShutdownFn)
- func (db *Database) PeerAddrs() ([]*net.TCPAddr, error)
- func (db *Database) PoolServiceList(all bool) ([]*system.PoolService, error)
- func (db *Database) RemoveCheckerFinding(finding *checker.Finding) error
- func (db *Database) RemoveCheckerFindingsForPools(poolIDs ...string) error
- func (db *Database) RemoveFiles() error
- func (db *Database) RemoveMember(m *system.Member) error
- func (db *Database) RemovePoolService(ctx context.Context, poolUUID uuid.UUID) error
- func (db *Database) ReplicaAddr() (*net.TCPAddr, error)
- func (db *Database) ResetCheckerData() error
- func (db *Database) ResignLeadership(cause error) error
- func (db *Database) SetCheckerFindingAction(seq uint64, action int32) error
- func (db *Database) SetSystemAttrs(props map[string]string) error
- func (db *Database) ShutdownRaft() error
- func (db *Database) Start(parent context.Context) error
- func (db *Database) Stop() error
- func (db *Database) SystemName() string
- func (db *Database) TakePoolLock(ctx context.Context, poolUUID uuid.UUID) (*PoolLock, error)
- func (db *Database) UpdateCheckerFinding(finding *checker.Finding) error
- func (db *Database) UpdateMember(m *system.Member) error
- func (db *Database) UpdatePoolService(ctx context.Context, ps *system.PoolService) error
- func (db *Database) WaitForLeaderStepUp()
- type DatabaseConfig
- type GroupMap
- type LogEntryDetails
- type MemberAddrMap
- type MemberDatabase
- type MemberRankMap
- type MemberUuidMap
- type PoolDatabase
- type PoolLabelMap
- type PoolLock
- type PoolRankMap
- type PoolUuidMap
- type RaftComponents
- type RankEntry
- type SnapshotDetails
- type SystemDatabase
Constants ¶
const (
// CurrentSchemaVersion indicates the current db schema version.
CurrentSchemaVersion = 0
)
Variables ¶
var ( // ErrNoRaftLogEntries is returned when there are no raft log entries. ErrNoRaftLogEntries = errors.New("no raft log entries") // ErrNoRaftSnapshots is returned when there are no raft snapshots. ErrNoRaftSnapshots = errors.New("no raft snapshots") )
Functions ¶
func AddContextLock ¶
AddContextLock adds a pool lock to the supplied context.
func DatabaseExists ¶
func DatabaseExists(cfg *DatabaseConfig) (bool, error)
DatabaseExists returns true if the system database file exists.
func ErrFindingNotFound ¶
ErrFindingNotFound creates an error that indicates a specified finding wasn't found in the database.
func GetLogEntries ¶
func GetLogEntries(log logging.Logger, cfg *DatabaseConfig, maxEntries ...uint64) (<-chan *LogEntryDetails, error)
GetLogEntries returns the log entries from the raft log via a channel which is closed when there are no more entries to be read.
func GetRaftConfiguration ¶
func GetRaftConfiguration(log logging.Logger, cfg *DatabaseConfig) (raft.Configuration, error)
GetRaftConfiguration returns the current raft configuration.
func IsFindingNotFound ¶
IsFindingNotFound checks whether an error is an ErrFindingNotFound.
func IsRaftLeadershipError ¶
IsRaftLeadershipError returns true if the given error is a known leadership error returned by the raft library.
func RecoverLocalReplica ¶
func RecoverLocalReplica(log logging.Logger, cfg *DatabaseConfig) error
RecoverLocalReplica recovers the MS from the local on-disk replica state.
func RestoreLocalReplica ¶
func RestoreLocalReplica(log logging.Logger, cfg *DatabaseConfig, snapPath string) error
RestoreLocalReplica restores the MS from the snapshot at the supplied path.
Types ¶
type CheckerDatabase ¶
type CheckerDatabase struct {
Findings CheckerFindingMap
}
CheckerDatabase is the database containing all checker Findings.
type CheckerFindingMap ¶
CheckerFindingMap allows the lookup of a Finding by its sequence number.
type Database ¶
Database provides high-level access methods for the system data as well as structure for managing the raft service that replicates the system data.
func MockDatabase ¶
MockDatabase returns a lightweight implementation of the system database that does not support raft replication and does all operations in memory.
func MockDatabaseWithAddr ¶
MockDatabaseWithAddr is similar to MockDatabase but allows a custom replica address to be supplied.
func MockDatabaseWithCfg ¶
MockDatabaseWithCfg is similar to MockDatabase but allows a custom DatabaseConfig to be supplied.
func MockDatabaseWithFaultDomainTree ¶
func MockDatabaseWithFaultDomainTree(t *testing.T, log logging.Logger, tree *system.FaultDomainTree) *Database
MockDatabaseWithFaultDomainTree creates a MockDatabase and sets the fault domain tree.
func NewDatabase ¶
func NewDatabase(log logging.Logger, cfg *DatabaseConfig) (*Database, error)
NewDatabase returns a configured and initialized Database instance.
func TestDatabase ¶
TestDatabase returns a database that is backed by temporary storage and can be started. Uses an in-memory transport. Much heavier-weight implementation and should only be used by tests that require it.
func (*Database) AddCheckerFinding ¶
AddCheckerFinding adds a finding to the database.
func (*Database) AddOrUpdateCheckerFinding ¶
AddOrUpdateCheckerFinding updates a finding in the database if it is already stored, or stores it if not.
func (*Database) AddPoolService ¶
AddPoolService creates an entry for a new pool service in the pool database.
func (*Database) AllMembers ¶
AllMembers returns a copy of the system membership.
func (*Database) Barrier ¶
Barrier blocks until the raft implementation has persisted all outstanding log entries.
func (*Database) CheckLeader ¶
CheckLeader returns an error if the node is not a replica or is not the current system leader. The error can be inspected for hints about where to find the current leader.
func (*Database) CheckReplica ¶
CheckReplica returns an error if the node is not configured as a replica or the service is not running.
func (*Database) ConfigureTransport ¶
ConfigureTransport configures the raft transport for the database.
func (*Database) CurMapVersion ¶
CurMapVersion returns the current system map version.
func (*Database) DataVersion ¶
DataVersion returns the current version of the system database.
func (*Database) FaultDomainTree ¶
func (db *Database) FaultDomainTree() *system.FaultDomainTree
FaultDomainTree returns the tree of fault domains of joined members.
func (*Database) FindMemberByRank ¶
FindMemberByRank searches the member database by rank. If no member is found, an error is returned.
func (*Database) FindMemberByUUID ¶
FindMemberByUUID searches the member database by UUID. If no member is found, an error is returned.
func (*Database) FindMembersByAddr ¶
FindMembersByAddr searches the member database by control address. If no members are found, an error is returned. This search may return multiple members, as a given address may be associated with more than one rank.
func (*Database) FindPoolServiceByLabel ¶
func (db *Database) FindPoolServiceByLabel(label string) (*system.PoolService, error)
FindPoolServiceByLabel searches the pool database by Label. If no pool service is found, an error is returned.
func (*Database) FindPoolServiceByUUID ¶
FindPoolServiceByUUID searches the pool database by UUID. If no pool service is found, an error is returned.
func (*Database) GetCheckerFinding ¶
GetCheckerFinding looks up a finding by sequence number.
func (*Database) GetCheckerFindings ¶
GetCheckerFindings fetches findings from the database by sequence number, or fetches all of them if no list is provided.
func (*Database) GetSystemAttrs ¶
func (db *Database) GetSystemAttrs(keys []string, filterFn func(string) bool) (map[string]string, error)
GetSystemAttrs returns a copy of the system properties map.
func (*Database) IsBootstrap ¶
IsBootstrap returns true if the system is a replica and meets the criteria for bootstrapping (starting without configured peers) the system database as part of initial wireup.
func (*Database) IsLeader ¶
IsLeader returns a boolean indicating whether or not this system thinks that is a) a replica and b) the current leader.
func (*Database) LeaderQuery ¶
LeaderQuery returns the system leader, if known.
func (*Database) MemberCount ¶
func (db *Database) MemberCount(desiredStates ...system.MemberState) (int, error)
MemberCount returns the number of members in the system.
func (*Database) MemberRanks ¶
MemberRanks returns a slice of all the ranks in the membership.
func (*Database) OnLeadershipGained ¶
func (db *Database) OnLeadershipGained(fns ...onLeadershipGainedFn)
OnLeadershipGained registers callbacks to be run when this instance gains the leadership role.
func (*Database) OnLeadershipLost ¶
func (db *Database) OnLeadershipLost(fns ...onLeadershipLostFn)
OnLeadershipLost registers callbacks to be run when this instance loses the leadership role.
func (*Database) OnRaftShutdown ¶
func (db *Database) OnRaftShutdown(fns ...onRaftShutdownFn)
OnRaftShutdown registers callbacks to be run when this instance shuts down.
func (*Database) PoolServiceList ¶
func (db *Database) PoolServiceList(all bool) ([]*system.PoolService, error)
PoolServiceList returns a list of pool services registered with the system. If the all parameter is not true, only pool services in the "Ready" state are returned.
func (*Database) RemoveCheckerFinding ¶
RemoveCheckerFinding removes a given finding from the checker database.
func (*Database) RemoveCheckerFindingsForPools ¶
RemoveCheckerFindingsForPools removes any findings in the database associated with one or more pool IDs.
func (*Database) RemoveFiles ¶
RemoveFiles destructively removes files associated with the system database.
func (*Database) RemoveMember ¶
RemoveMember removes a member from the system.
func (*Database) RemovePoolService ¶
RemovePoolService removes a pool database entry.
func (*Database) ReplicaAddr ¶
ReplicaAddr returns the system's replica address if the system is configured as a MS replica.
func (*Database) ResetCheckerData ¶
ResetCheckerData clears all findings in the database.
func (*Database) ResignLeadership ¶
ResignLeadership causes this instance to give up its raft leadership state. No-op if there is only one replica configured or the cause is a raft leadership error.
func (*Database) SetCheckerFindingAction ¶
SetCheckerFindingAction sets the action chosen for a giving finding.
func (*Database) SetSystemAttrs ¶
SetSystemAttrs submits an update to the system properties map.
func (*Database) ShutdownRaft ¶
ShutdownRaft signals that the raft implementation should shut down and release any resources it is holding. Blocks until the shutdown is complete.
func (*Database) Start ¶
Start checks to see if the system is configured as a MS replica. If not, it returns early without an error. If it is, the persistent storage is initialized if necessary, and the replica is started to begin the process of choosing a MS leader.
func (*Database) Stop ¶
Stop signals to the database that it should shutdown all background tasks and release any resources.
func (*Database) SystemName ¶
SystemName returns the system name set in the configuration.
func (*Database) TakePoolLock ¶
TakePoolLock attempts to take a lock on the pool with the given UUID, if the supplied context does not already contain a valid lock for that pool.
func (*Database) UpdateCheckerFinding ¶
UpdateCheckerFinding updates a finding that is already in the database.
func (*Database) UpdateMember ¶
UpdateMember updates an existing member.
func (*Database) UpdatePoolService ¶
UpdatePoolService updates an existing pool database entry.
func (*Database) WaitForLeaderStepUp ¶
func (db *Database) WaitForLeaderStepUp()
WaitForLeaderStepUp waits for all OnLeadershipGained functions to finish executing.
type DatabaseConfig ¶
type DatabaseConfig struct { Replicas []*net.TCPAddr RaftDir string RaftSnapshotThreshold uint64 RaftSnapshotInterval time.Duration SystemName string ReadOnly bool }
DatabaseConfig defines the configuration for the system database.
func (*DatabaseConfig) DBFilePath ¶
func (cfg *DatabaseConfig) DBFilePath() string
DBFilePath returns the path to the system database file.
func (*DatabaseConfig) LocalReplicaAddr ¶
func (cfg *DatabaseConfig) LocalReplicaAddr() (addr *net.TCPAddr, err error)
LocalReplicaAddr returns the address corresponding to the local MS replica, or an error indicating that this node is not a configured replica.
func (*DatabaseConfig) PeerReplicaAddrs ¶
func (cfg *DatabaseConfig) PeerReplicaAddrs() (peers []*net.TCPAddr)
type GroupMap ¶
type GroupMap struct { Version uint32 RankEntries map[ranklist.Rank]RankEntry MSRanks []ranklist.Rank }
GroupMap represents a version of the system membership map.
type LogEntryDetails ¶
LogEntryDetails contains details of a raft log entry.
func GetLastLogEntry ¶
func GetLastLogEntry(log logging.Logger, cfg *DatabaseConfig) (*LogEntryDetails, error)
GetLastLogEntry returns the last (highest index) log entry from the raft log.
func (*LogEntryDetails) DecodeLog ¶
func (led *LogEntryDetails) DecodeLog() error
DecodeLog decodes the log entry data into the LogEntryDetails.
type MemberAddrMap ¶
MemberAddrMap provides a map of string->[]*system.Member.
func (MemberAddrMap) MarshalJSON ¶
func (mam MemberAddrMap) MarshalJSON() ([]byte, error)
MarshalJSON creates a serialized representation of the MemberAddrMap. The member's UUID is used to represent the member in order to avoid duplicating member details in the serialized format.
type MemberDatabase ¶
type MemberDatabase struct { Ranks MemberRankMap Uuids MemberUuidMap Addrs MemberAddrMap FaultDomains *system.FaultDomainTree }
MemberDatabase contains a set of maps for looking up members and provides methods for managing the membership.
func (*MemberDatabase) UnmarshalJSON ¶
func (mdb *MemberDatabase) UnmarshalJSON(data []byte) error
UnmarshalJSON "inflates" the MemberDatabase from a compressed and serialized representation. The MemberUuidMap contains a full representation of each Member, whereas the other serialized maps simply use the Member UUID as a placeholder for the mapping.
type MemberRankMap ¶
MemberRankMap provides a map of Rank->*system.Member.
func (MemberRankMap) MarshalJSON ¶
func (mrm MemberRankMap) MarshalJSON() ([]byte, error)
MarshalJSON creates a serialized representation of the MemberRankMap. The member's UUID is used to represent the member in order to avoid duplicating member details in the serialized format.
type MemberUuidMap ¶
MemberUuidMap provides a map of UUID->*system.Member.
type PoolDatabase ¶
type PoolDatabase struct { Ranks PoolRankMap Uuids PoolUuidMap Labels PoolLabelMap }
PoolDatabase contains a set of maps for looking up DAOS Pool Service instances and methods for managing the pool membership.
func (*PoolDatabase) UnmarshalJSON ¶
func (pdb *PoolDatabase) UnmarshalJSON(data []byte) error
UnmarshalJSON "inflates" the PoolDatabase from a compressed and serialized representation. The PoolUuidMap contains a full representation of each PoolService, whereas the other serialized maps simply use the Pool UUID as a placeholder for the mapping.
type PoolLabelMap ¶
type PoolLabelMap map[string]*system.PoolService
PoolLabelMap provides a map of Label->*PoolService.
func (PoolLabelMap) MarshalJSON ¶
func (plm PoolLabelMap) MarshalJSON() ([]byte, error)
MarshalJSON creates a serialized representation of the PoolLabelMap. The pool's UUID is used to represent the pool service in order to avoid duplicating pool service details in the serialized format.
type PoolLock ¶
type PoolLock struct {
// contains filtered or unexported fields
}
PoolLock represents a lock on a pool. These locks are reference counted to make them reentrant. Note that the lock release closure will only ever be called once, no matter how many times Release() is called.
func (*PoolLock) InContext ¶
InContext returns a new child context with the lock added as a value. NB: It is the caller's responsibility to ensure that the parent context is valid and does not already contain a different pool lock. For a more robust implementation, see the AddContextLock() function.
type PoolRankMap ¶
type PoolRankMap map[ranklist.Rank][]*system.PoolService
PoolRankMap provides a map of Rank->[]*PoolService.
func (PoolRankMap) MarshalJSON ¶
func (prm PoolRankMap) MarshalJSON() ([]byte, error)
MarshalJSON creates a serialized representation of the PoolRankMap. The pool's UUID is used to represent the pool service in order to avoid duplicating pool service details in the serialized format.
type PoolUuidMap ¶
type PoolUuidMap map[uuid.UUID]*system.PoolService
PoolUuidMap provides a map of UUID->*PoolService.
type RaftComponents ¶
type RaftComponents struct { Logger logging.Logger Bootstrap bool ReplicaAddr *net.TCPAddr Config *raft.Config LogStore raft.LogStore StableStore raft.StableStore SnapshotStore raft.SnapshotStore }
RaftComponents holds the components required to start a raft instance.
func ConfigureComponents ¶
func ConfigureComponents(log logging.Logger, dbCfg *DatabaseConfig) (*RaftComponents, error)
ConfigureComponents configures the raft components of the database.
type RankEntry ¶
type RankEntry struct { PrimaryURI string NumPrimaryCtxs uint32 SecondaryURIs []string NumSecondaryCtxs []uint32 Incarnation uint64 }
RankEntry comprises the information about a rank in GroupMap.
type SnapshotDetails ¶
type SnapshotDetails struct { Metadata *raft.SnapshotMeta Path string Version uint MapVersion uint SchemaVersion uint NextRank uint MemberRanks *ranklist.RankSet Pools []string }
SnapshotDetails contains details of a raft snapshot, including an interpretation of the snapshot data in database format.
func GetLatestSnapshot ¶
func GetLatestSnapshot(log logging.Logger, cfg *DatabaseConfig) (*SnapshotDetails, error)
GetLatestSnapshot returns the latest snapshot found on the system.
func GetSnapshotInfo ¶
func GetSnapshotInfo(log logging.Logger, cfg *DatabaseConfig) ([]*SnapshotDetails, error)
GetSnapshotInfo returns a list of snapshot details found on the system.
func ReadSnapshotInfo ¶
func ReadSnapshotInfo(path string) (*SnapshotDetails, error)
ReadSnapshotInfo reads the snapshot metadata and data from the given path.
func (*SnapshotDetails) DecodeSnapshot ¶
func (sd *SnapshotDetails) DecodeSnapshot(data []byte) error
DecodeSnapshot decodes the snapshot data into the SnapshotDetails.
type SystemDatabase ¶
SystemDatabase contains system-level information that must be raft-replicated.