Documentation ¶
Index ¶
- func GetSnapshotDirName(index uint64) string
- type Context
- func (sc *Context) CheckNodeHostDir(addr string)
- func (sc *Context) CreateNodeHostDir() ([]string, []string)
- func (sc *Context) GetLogDBDirs() ([]string, []string)
- func (sc *Context) GetRandomSource() random.Source
- func (sc *Context) GetSnapshotDir(groupID uint64, nodeID uint64) string
- func (sc *Context) PrepareSnapshotDir(groupID uint64, nodeID uint64) (string, error)
- func (sc *Context) Stop()
- type DoubleFixedPartitioner
- type FixedPartitioner
- type GetSnapshotDirFunc
- type IPartitioner
- type MessageQueue
- type Mode
- type SnapshotEnv
- func (se *SnapshotEnv) CreateFlagFile(msg proto.Message) error
- func (se *SnapshotEnv) CreateTempDir() error
- func (se *SnapshotEnv) GetFilename() string
- func (se *SnapshotEnv) GetFilepath() string
- func (se *SnapshotEnv) GetFinalDir() string
- func (se *SnapshotEnv) GetRootDir() string
- func (se *SnapshotEnv) GetTempDir() string
- func (se *SnapshotEnv) GetTempFilepath() string
- func (se *SnapshotEnv) HasFlagFile() bool
- func (se *SnapshotEnv) IsFinalDirExists() bool
- func (se *SnapshotEnv) MustRemoveTempDir()
- func (se *SnapshotEnv) RemoveFinalDir() error
- func (se *SnapshotEnv) RemoveFlagFile() error
- func (se *SnapshotEnv) RemoveTempDir() error
- func (se *SnapshotEnv) RenameTempDirToFinalDir() (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSnapshotDirName ¶
GetSnapshotDirName returns the snapshot dir name for the snapshot captured at the specified index.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is the server context for NodeHost.
func NewContext ¶
func NewContext(nhConfig config.NodeHostConfig) *Context
NewContext creates and returns a new server Context object.
func (*Context) CheckNodeHostDir ¶
CheckNodeHostDir checks whether NodeHost dir is owned by the current nodehost.
func (*Context) CreateNodeHostDir ¶
CreateNodeHostDir creates the top level dirs used by nodehost.
func (*Context) GetLogDBDirs ¶
GetLogDBDirs returns the directory names for LogDB
func (*Context) GetRandomSource ¶
GetRandomSource returns the random source associated with the Nodehost.
func (*Context) GetSnapshotDir ¶
GetSnapshotDir returns the snapshot directory name.
func (*Context) PrepareSnapshotDir ¶
PrepareSnapshotDir creates the snapshot directory for the specified node.
type DoubleFixedPartitioner ¶
type DoubleFixedPartitioner struct {
// contains filtered or unexported fields
}
DoubleFixedPartitioner is the IPartitioner with two fixed capacity and naive partitioning strategy.
func NewDoubleFixedPartitioner ¶
func NewDoubleFixedPartitioner(capacity uint64, workerCount uint64) *DoubleFixedPartitioner
NewDoubleFixedPartitioner creates a new DoubleFixedPartitioner instance.
func (*DoubleFixedPartitioner) GetPartitionID ¶
func (p *DoubleFixedPartitioner) GetPartitionID(clusterID uint64) uint64
GetPartitionID returns the partition ID for the specified raft cluster.
type FixedPartitioner ¶
type FixedPartitioner struct {
// contains filtered or unexported fields
}
FixedPartitioner is the IPartitioner with fixed capacity and naive partitioning strategy.
func NewFixedPartitioner ¶
func NewFixedPartitioner(capacity uint64) *FixedPartitioner
NewFixedPartitioner creates a new FixedPartitioner instance.
func (*FixedPartitioner) GetPartitionID ¶
func (p *FixedPartitioner) GetPartitionID(clusterID uint64) uint64
GetPartitionID returns the partition ID for the specified raft cluster.
type GetSnapshotDirFunc ¶
GetSnapshotDirFunc is the function type that returns the snapshot dir for the specified raft node.
type IPartitioner ¶
IPartitioner is the interface for partitioning clusters.
type MessageQueue ¶
type MessageQueue struct {
// contains filtered or unexported fields
}
MessageQueue is the queue used to hold Paxos messages.
func NewMessageQueue ¶
func NewMessageQueue(size uint64, ch bool, lazyFreeCycle uint64) *MessageQueue
NewMessageQueue creates a new MessageQueue instance.
func (*MessageQueue) Add ¶
func (q *MessageQueue) Add(msg paxospb.PaxosMsg) (bool, bool)
Add adds the specified message to the queue.
func (*MessageQueue) Ch ¶
func (q *MessageQueue) Ch() <-chan struct{}
Ch returns the notification channel.
func (*MessageQueue) Close ¶
func (q *MessageQueue) Close()
Close closes the queue so no further messages can be added.
func (*MessageQueue) Get ¶
func (q *MessageQueue) Get() []paxospb.PaxosMsg
Get returns everything current in the queue.
func (*MessageQueue) Notify ¶
func (q *MessageQueue) Notify()
Notify notifies the notification channel listener that a new message is now available in the queue.
type SnapshotEnv ¶
type SnapshotEnv struct {
// contains filtered or unexported fields
}
SnapshotEnv is the struct used to manage involved directories for taking or receiving snapshots.
func NewSnapshotEnv ¶
func NewSnapshotEnv(f GetSnapshotDirFunc, groupID uint64, nodeID uint64, index uint64, from uint64, mode Mode) *SnapshotEnv
NewSnapshotEnv creates and returns a new SnapshotEnv instance.
func (*SnapshotEnv) CreateFlagFile ¶
func (se *SnapshotEnv) CreateFlagFile(msg proto.Message) error
CreateFlagFile creates the flag file in the temp directory.
func (*SnapshotEnv) CreateTempDir ¶
func (se *SnapshotEnv) CreateTempDir() error
CreateTempDir creates the temp snapshot directory.
func (*SnapshotEnv) GetFilename ¶
func (se *SnapshotEnv) GetFilename() string
GetFilename returns the snapshot filename.
func (*SnapshotEnv) GetFilepath ¶
func (se *SnapshotEnv) GetFilepath() string
GetFilepath returns the snapshot file path.
func (*SnapshotEnv) GetFinalDir ¶
func (se *SnapshotEnv) GetFinalDir() string
GetFinalDir returns the final snapshot directory.
func (*SnapshotEnv) GetRootDir ¶
func (se *SnapshotEnv) GetRootDir() string
GetRootDir returns the root directory. The temp and final snapshot directories are children of the root directory.
func (*SnapshotEnv) GetTempDir ¶
func (se *SnapshotEnv) GetTempDir() string
GetTempDir returns the temp snapshot directory.
func (*SnapshotEnv) GetTempFilepath ¶
func (se *SnapshotEnv) GetTempFilepath() string
GetTempFilepath returns the temp snapshot file path.
func (*SnapshotEnv) HasFlagFile ¶
func (se *SnapshotEnv) HasFlagFile() bool
HasFlagFile returns a boolean flag indicating whether the flag file is available in the final directory.
func (*SnapshotEnv) IsFinalDirExists ¶
func (se *SnapshotEnv) IsFinalDirExists() bool
IsFinalDirExists returns a boolean value indicating whether the final directory exists.
func (*SnapshotEnv) MustRemoveTempDir ¶
func (se *SnapshotEnv) MustRemoveTempDir()
MustRemoveTempDir removes the temp snapshot directory and panic if there is any error.
func (*SnapshotEnv) RemoveFinalDir ¶
func (se *SnapshotEnv) RemoveFinalDir() error
RemoveFinalDir removes the final snapshot directory.
func (*SnapshotEnv) RemoveFlagFile ¶
func (se *SnapshotEnv) RemoveFlagFile() error
RemoveFlagFile removes the flag file from the final directory.
func (*SnapshotEnv) RemoveTempDir ¶
func (se *SnapshotEnv) RemoveTempDir() error
RemoveTempDir removes the temp snapshot directory.
func (*SnapshotEnv) RenameTempDirToFinalDir ¶
func (se *SnapshotEnv) RenameTempDirToFinalDir() (bool, error)
RenameTempDirToFinalDir renames the temp directory to the final directory name. It return a boolean value indicating whether the operation failed due to target directory already exists.