hakeeper

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package hakeeper implements MO's hakeeper component.

Index

Constants

View Source
const (
	DefaultTickPerSecond   = 10
	DefaultLogStoreTimeout = 5 * time.Minute
	DefaultDNStoreTimeout  = 10 * time.Second
	DefaultCNStoreTimeout  = 30 * time.Second
)
View Source
const (
	K8SIDRangeStart uint64 = 131072
	K8SIDRangeEnd   uint64 = 262144
	// CheckDuration defines how often HAKeeper checks the health state of the cluster
	CheckDuration = 3 * time.Second
	// DefaultHAKeeperShardID is the shard ID assigned to the special HAKeeper
	// shard.
	DefaultHAKeeperShardID uint64 = 0
)

Variables

This section is empty.

Functions

func GetCNStoreHeartbeatCmd

func GetCNStoreHeartbeatCmd(data []byte) []byte

func GetDNStoreHeartbeatCmd

func GetDNStoreHeartbeatCmd(data []byte) []byte

func GetGetIDCmd

func GetGetIDCmd(count uint64) []byte

func GetInitialClusterRequestCmd

func GetInitialClusterRequestCmd(numOfLogShards uint64,
	numOfDNShards uint64, numOfLogReplicas uint64) []byte

func GetLogStoreHeartbeatCmd

func GetLogStoreHeartbeatCmd(data []byte) []byte

func GetSetStateCmd

func GetSetStateCmd(state pb.HAKeeperState) []byte

func GetSetTaskSchedulerStateCmd added in v0.7.0

func GetSetTaskSchedulerStateCmd(state pb.TaskSchedulerState) []byte

func GetTaskTableUserCmd added in v0.6.0

func GetTaskTableUserCmd(user pb.TaskTableUser) []byte

func GetTickCmd

func GetTickCmd() []byte

func GetUpdateCommandsCmd

func GetUpdateCommandsCmd(term uint64, cmds []pb.ScheduleCommand) []byte

func NewStateMachine

func NewStateMachine(shardID uint64, replicaID uint64) sm.IStateMachine

Types

type BootstrapManager

type BootstrapManager interface {
	Bootstrap(util.IDAllocator, pb.DNState, pb.LogState) ([]pb.ScheduleCommand, error)

	CheckBootstrap(pb.LogState) bool
}

BootstrapManager is the interface suppose to be implemented by HAKeeper's bootstrap manager.

type Checker

type Checker interface {
	// Check is periodically called by the HAKeeper for checking the cluster
	// health status, a list of Operator instances will be returned describing
	// actions required to ensure the high availability of the cluster.
	Check(alloc util.IDAllocator, state pb.CheckerState) []pb.ScheduleCommand
}

Checker is the interface suppose to be implemented by HAKeeper's coordinator. Checker is supposed to be stateless - Checker is free to maintain whatever internal states, but those states should never be assumed to be persistent across reboots.

type ClusterDetailsQuery added in v0.5.1

type ClusterDetailsQuery struct{ Cfg Config }

type Config added in v0.6.0

type Config struct {
	// TickPerSecond indicates how many ticks every second.
	// In HAKeeper, we do not use actual time to measure time elapse.
	// Instead, we use ticks.
	TickPerSecond int

	// LogStoreTimeout is the actual time limit between a log store's heartbeat.
	// If HAKeeper does not receive two heartbeat within LogStoreTimeout,
	// it regards the log store as down.
	LogStoreTimeout time.Duration

	// DNStoreTimeout is the actual time limit between a dn store's heartbeat.
	// If HAKeeper does not receive two heartbeat within DNStoreTimeout,
	// it regards the dn store as down.
	DNStoreTimeout time.Duration

	// CNStoreTimeout is the actual time limit between a cn store's heartbeat.
	// If HAKeeper does not receive two heartbeat within CNStoreTimeout,
	// it regards the dn store as down.
	CNStoreTimeout time.Duration
}

func (Config) CNStoreExpired added in v0.6.0

func (cfg Config) CNStoreExpired(start, current uint64) bool

func (Config) DNStoreExpired added in v0.6.0

func (cfg Config) DNStoreExpired(start, current uint64) bool

func (Config) ExpiredTick added in v0.6.0

func (cfg Config) ExpiredTick(start uint64, timeout time.Duration) uint64

func (*Config) Fill added in v0.6.0

func (cfg *Config) Fill()

func (Config) LogStoreExpired added in v0.6.0

func (cfg Config) LogStoreExpired(start, current uint64) bool

func (Config) Validate added in v0.6.0

func (cfg Config) Validate() error

type IDAllocator

type IDAllocator interface {
	// Next returns a new ID that can be used as the replica ID of a DN shard or
	// Log shard. When the return boolean value is false, it means no more ID
	// can be allocated at this time.
	Next() (uint64, bool)
	Set(first uint64, last uint64)
	Capacity() uint64
}

type ScheduleCommandQuery

type ScheduleCommandQuery struct{ UUID string }

type StateQuery

type StateQuery struct{}

type TaskScheduler added in v0.6.0

type TaskScheduler interface {
	Schedule(cnState pb.CNState, currentTick uint64)

	// Create an asynchronous task that executes a single time, this method is idempotent, the
	// same task is not created repeatedly based on multiple calls.
	Create(context.Context, []task.TaskMetadata) error

	// StartScheduleCronTask start schedule cron tasks. A timer will be started to pull the latest CronTask
	// from the TaskStore at regular intervals, and a timer will be maintained in memory for all Cron's to be
	// triggered at regular intervals.
	StartScheduleCronTask()
	// StopScheduleCronTask stop schedule cron tasks.
	StopScheduleCronTask()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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