placement

package
v3.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster interface {
	GetRegion(id uint64) *core.RegionInfo
	GetStores() []*core.StoreInfo
	GetStore(id uint64) *core.StoreInfo
	GetRegionStores(region *core.RegionInfo) []*core.StoreInfo
}

Cluster provides an overview of a cluster's region distribution.

type Config

type Config struct {
	Constraints []*Constraint
}

Config is consist of a list of constraints.

func ParseConfig

func ParseConfig(str string) (*Config, error)

ParseConfig parses a user configuration string.

type Constraint

type Constraint struct {
	Function string   // One of "count", "label_values", "count_leader", "isolation_level".
	Filters  []Filter // "key:value" formed parameters.
	Labels   []string // "key" formed parameters.
	Op       string   // One of "<", "<=", "=", ">=", ">".
	Value    int      // Expected expression evaluate value.
}

Constraint represents a user-defined region placement rule. Each constraint is configured as an expression, for example 'count(zone:z1,rack:r1,host)>=3'.

func (Constraint) Score

func (c Constraint) Score(region *core.RegionInfo, cluster Cluster) int

Score calculates the score of the constraint expression. The greater score is better. A nagative score means the constraint is not satisfied.

type Filter

type Filter struct {
	Key, Value string
}

Filter is used for filtering replicas of a region. The form in the configuration is "key:value", which appears in the function argument of the expression.

Jump to

Keyboard shortcuts

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