meta

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetadataManager

type MetadataManager interface {
	// GetStore gets a store by address.
	GetStore(addr string) (*store.Store, error)
	// AddStore adds a new store to the cluster.
	AddStore(addr string) error
	// RemoveStore removes a store from the cluster.
	RemoveStore(addr string) error
	// GetAllStores gets all stores in the cluster.
	GetAllStores() []*store.Store
	// GetRegionByID gets a region by id.
	GetRegionByID(id uint64) (*region.Region, error)
	// GetStoreByID gets a store by id.
	GetStoreByID(id uint64) (*store.Store, error)
	// ApplyConfig applies a new config to the cluster.
	ApplyConfig(config *config.Config) error
}

MetadataManager manages the metadata of the cluster.

func NewMeta added in v1.0.12

func NewMeta(conf config.Config) MetadataManager

NewMeta creates a new meta.

type NodeStatus

type NodeStatus struct {
	ID            string    // node id
	Address       string    // node address
	Alive         bool      // whether the node is alive
	LastHeartbeat time.Time // last heartbeat time
	Capacity      int       // node capacity
	Availability  bool      // whether the node is available
}

type RoundRobinScheduler

type RoundRobinScheduler struct {
	// contains filtered or unexported fields
}

RoundRobinScheduler is a scheduler that selects nodes in round-robin order.

func (*RoundRobinScheduler) SelectNode

func (r *RoundRobinScheduler) SelectNode(nodes []*NodeStatus, key []byte, num int) (*NodeStatus, error)

SelectNode selects a node in round-robin order.

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

func NewRoundRobinScheduler added in v1.0.5

func NewRoundRobinScheduler(config *SchedulerConfig) *Scheduler

NewRoundRobinScheduler creates a new RoundRobinScheduler.

func (*Scheduler) ScheduleNode

func (s *Scheduler) ScheduleNode(key []byte) (*NodeStatus, error)

ScheduleNode schedules the key to a node.

func (*Scheduler) SetSchedulingStrategy

func (s *Scheduler) SetSchedulingStrategy(strategy SchedulingStrategy)

SetSchedulingStrategy sets the scheduling strategy.

type SchedulerConfig

type SchedulerConfig struct {
	MaxLoad              int    // max load of a node
	MinLoad              int    // min load of a node
	ReplicationFactor    int    // replication factor
	DataShardingStrategy string // data sharding strategy
	PriorityStrategy     string // priority strategy
	SchedulingAlgorithm  string // scheduling algorithm
}

type SchedulingStrategy

type SchedulingStrategy interface {
	// SelectNode selects num node to schedule the key.
	SelectNode(nodes []*NodeStatus, key []byte, num int) (*NodeStatus, error)
}

SchedulingStrategy is the interface that wraps the basic SelectNode method.

Jump to

Keyboard shortcuts

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