server

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSnapshotDirName

func GetSnapshotDirName(index uint64) string

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

func (sc *Context) CheckNodeHostDir(addr string)

CheckNodeHostDir checks whether NodeHost dir is owned by the current nodehost.

func (*Context) CreateNodeHostDir

func (sc *Context) CreateNodeHostDir() ([]string, []string)

CreateNodeHostDir creates the top level dirs used by nodehost.

func (*Context) GetLogDBDirs

func (sc *Context) GetLogDBDirs() ([]string, []string)

GetLogDBDirs returns the directory names for LogDB

func (*Context) GetRandomSource

func (sc *Context) GetRandomSource() random.Source

GetRandomSource returns the random source associated with the Nodehost.

func (*Context) GetSnapshotDir

func (sc *Context) GetSnapshotDir(groupID uint64,
	nodeID uint64) string

GetSnapshotDir returns the snapshot directory name.

func (*Context) PrepareSnapshotDir

func (sc *Context) PrepareSnapshotDir(groupID uint64, nodeID uint64) (string, error)

PrepareSnapshotDir creates the snapshot directory for the specified node.

func (*Context) Stop

func (sc *Context) Stop()

Stop stops the context.

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

type GetSnapshotDirFunc func(clusterID uint64, nodeID uint64) string

GetSnapshotDirFunc is the function type that returns the snapshot dir for the specified raft node.

type IPartitioner

type IPartitioner interface {
	GetPartitionID(clusterID uint64) uint64
}

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 Mode

type Mode uint64

Mode is the snapshot env mode.

const (
	// SnapshottingMode is the mode used when taking snapshotting.
	SnapshottingMode Mode = iota
	// ReceivingMode is the mode used when receiving snapshots from remote nodes.
	ReceivingMode
)

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.

Jump to

Keyboard shortcuts

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