Documentation ¶
Index ¶
- Constants
- Variables
- func SelectSourceContainers(containers []*core.CachedContainer, filters []Filter, ...) []*core.CachedContainer
- func SelectTargetContainers(containers []*core.CachedContainer, filters []Filter, ...) []*core.CachedContainer
- func Source(opt *config.PersistOptions, container *core.CachedContainer, filters []Filter) bool
- func Target(opt *config.PersistOptions, container *core.CachedContainer, filters []Filter) bool
- type ContainerCandidates
- func (c *ContainerCandidates) FilterSource(opt *config.PersistOptions, filters ...Filter) *ContainerCandidates
- func (c *ContainerCandidates) FilterTarget(opt *config.PersistOptions, filters ...Filter) *ContainerCandidates
- func (c *ContainerCandidates) PickFirst() *core.CachedContainer
- func (c *ContainerCandidates) RandomPick() *core.CachedContainer
- func (c *ContainerCandidates) Reverse() *ContainerCandidates
- func (c *ContainerCandidates) Shuffle() *ContainerCandidates
- func (c *ContainerCandidates) Sort(less ContainerComparer) *ContainerCandidates
- func (c *ContainerCandidates) Top(less ContainerComparer) *ContainerCandidates
- type ContainerComparer
- type ContainerStateFilter
- func (f *ContainerStateFilter) Scope() string
- func (f *ContainerStateFilter) Source(opts *config.PersistOptions, container *core.CachedContainer) bool
- func (f *ContainerStateFilter) Target(opts *config.PersistOptions, container *core.CachedContainer) bool
- func (f *ContainerStateFilter) Type() string
- type Filter
- func NewEngineFilter(scope string, allowedEngines ...string) Filter
- func NewExcludedFilter(scope string, sources, targets map[uint64]struct{}) Filter
- func NewIsolationFilter(scope, isolationLevel string, locationLabels []string, ...) Filter
- func NewLabelConstaintFilter(scope string, constraints []placement.LabelConstraint) Filter
- func NewLocationImprover(scope string, labels []string, containers []*core.CachedContainer, ...) Filter
- func NewLocationSafeguard(scope string, labels []string, containers []*core.CachedContainer, ...) Filter
- func NewOrdinaryEngineFilter(scope string) Filter
- func NewPlacementLeaderSafeguard(scope string, cluster opt.Cluster, res *core.CachedResource, ...) Filter
- func NewPlacementSafeguard(scope string, cluster opt.Cluster, res *core.CachedResource, ...) Filter
- func NewSpecialUseFilter(scope string, allowUses ...string) Filter
- func NewStorageThresholdFilter(scope string) Filter
- type ResourceFitter
Constants ¶
const ( // SpecialUseKey is the label used to indicate special use storage. SpecialUseKey = "specialUse" // SpecialUseHotResource is the hot resource value of special use label SpecialUseHotResource = "hotResource" // SpecialUseReserved is the reserved value of special use label SpecialUseReserved = "reserved" // EngineKey is the label key used to indicate engine. EngineKey = "engine" // EngineTiFlash is the tiflash value of the engine label. EngineTiFlash = "tiflash" // EngineTiKV indicates the tikv engine in metrics EngineTiKV = "tikv" )
Variables ¶
var ( // LogWhySkipped cause why the filter skip a container LogWhySkipped = false )
Functions ¶
func SelectSourceContainers ¶
func SelectSourceContainers(containers []*core.CachedContainer, filters []Filter, opt *config.PersistOptions) []*core.CachedContainer
SelectSourceContainers selects containers that be selected as source container from the list.
func SelectTargetContainers ¶
func SelectTargetContainers(containers []*core.CachedContainer, filters []Filter, opt *config.PersistOptions) []*core.CachedContainer
SelectTargetContainers selects containers that be selected as target container from the list.
func Source ¶
func Source(opt *config.PersistOptions, container *core.CachedContainer, filters []Filter) bool
Source checks if container can pass all Filters as source container.
func Target ¶
func Target(opt *config.PersistOptions, container *core.CachedContainer, filters []Filter) bool
Target checks if container can pass all Filters as target container.
Types ¶
type ContainerCandidates ¶
type ContainerCandidates struct {
Containers []*core.CachedContainer
}
ContainerCandidates wraps container list and provide utilities to select source or target container to schedule.
func NewCandidates ¶
func NewCandidates(containers []*core.CachedContainer) *ContainerCandidates
NewCandidates creates ContainerCandidates with container list.
func (*ContainerCandidates) FilterSource ¶
func (c *ContainerCandidates) FilterSource(opt *config.PersistOptions, filters ...Filter) *ContainerCandidates
FilterSource keeps containers that can pass all source filters.
func (*ContainerCandidates) FilterTarget ¶
func (c *ContainerCandidates) FilterTarget(opt *config.PersistOptions, filters ...Filter) *ContainerCandidates
FilterTarget keeps containers that can pass all target filters.
func (*ContainerCandidates) PickFirst ¶
func (c *ContainerCandidates) PickFirst() *core.CachedContainer
PickFirst returns the first container in candidate list.
func (*ContainerCandidates) RandomPick ¶
func (c *ContainerCandidates) RandomPick() *core.CachedContainer
RandomPick returns a random container from the list.
func (*ContainerCandidates) Reverse ¶
func (c *ContainerCandidates) Reverse() *ContainerCandidates
Reverse reverses the candidate container list.
func (*ContainerCandidates) Shuffle ¶
func (c *ContainerCandidates) Shuffle() *ContainerCandidates
Shuffle reorders all candidates randomly.
func (*ContainerCandidates) Sort ¶
func (c *ContainerCandidates) Sort(less ContainerComparer) *ContainerCandidates
Sort sorts container list by given comparer in ascending order.
func (*ContainerCandidates) Top ¶
func (c *ContainerCandidates) Top(less ContainerComparer) *ContainerCandidates
Top keeps all containers that have the same priority with the first container. The container list should be sorted before calling Top.
type ContainerComparer ¶
type ContainerComparer func(a, b *core.CachedContainer) int
ContainerComparer compares 2 containers. Often used for ContainerCandidates to sort candidate containers.
func IsolationComparer ¶
func IsolationComparer(locationLabels []string, resourceContainers []*core.CachedContainer) ContainerComparer
IsolationComparer creates a ContainerComparer to sort container by isolation score.
func ResourceScoreComparer ¶
func ResourceScoreComparer(groupKey string, opt *config.PersistOptions) ContainerComparer
ResourceScoreComparer creates a ContainerComparer to sort container by resource score.
type ContainerStateFilter ¶
type ContainerStateFilter struct { ActionScope string // Set true if the schedule involves any transfer leader operation. TransferLeader bool // Set true if the schedule involves any move resource operation. MoveResource bool // Set true if the scatter move the resource ScatterResource bool // Set true if allows temporary states. AllowTemporaryStates bool // Reason is used to distinguish the reason of container state filter Reason string }
ContainerStateFilter is used to determine whether a container can be selected as the source or target of the schedule based on the container's state.
func (*ContainerStateFilter) Scope ¶
func (f *ContainerStateFilter) Scope() string
Scope returns the scheduler or the checker which the filter acts on.
func (*ContainerStateFilter) Source ¶
func (f *ContainerStateFilter) Source(opts *config.PersistOptions, container *core.CachedContainer) bool
Source returns true when the container can be selected as the schedule source.
func (*ContainerStateFilter) Target ¶
func (f *ContainerStateFilter) Target(opts *config.PersistOptions, container *core.CachedContainer) bool
Target returns true when the container can be selected as the schedule target.
func (*ContainerStateFilter) Type ¶
func (f *ContainerStateFilter) Type() string
Type returns the type of the Filter.
type Filter ¶
type Filter interface { // Scope is used to indicate where the filter will act on. Scope() string Type() string // Return true if the container can be used as a source container. Source(opt *config.PersistOptions, container *core.CachedContainer) bool // Return true if the container can be used as a target container. Target(opt *config.PersistOptions, container *core.CachedContainer) bool }
Filter is an interface to filter source and target container.
func NewEngineFilter ¶
NewEngineFilter creates a filter that only keeps allowedEngines.
func NewExcludedFilter ¶
NewExcludedFilter creates a Filter that filters all specified containers.
func NewIsolationFilter ¶
func NewIsolationFilter(scope, isolationLevel string, locationLabels []string, resourceContainers []*core.CachedContainer) Filter
NewIsolationFilter creates a filter that filters out containers with isolationLevel For example, a resource has 3 replicas in z1, z2 and z3 individually. With isolationLevel = zone, if the resource on z1 is down, we need to filter out z2 and z3 because these two zones already have one of the resource's replicas on them. We need to choose a container on z1 or z4 to place the new replica to meet the isolationLevel explicitly and forcibly.
func NewLabelConstaintFilter ¶
func NewLabelConstaintFilter(scope string, constraints []placement.LabelConstraint) Filter
NewLabelConstaintFilter creates a filter that selects containers satisfy the constraints.
func NewLocationImprover ¶
func NewLocationImprover(scope string, labels []string, containers []*core.CachedContainer, source *core.CachedContainer) Filter
NewLocationImprover creates a filter that filters all containers that have lower or equal distinct score than specified container.
func NewLocationSafeguard ¶
func NewLocationSafeguard(scope string, labels []string, containers []*core.CachedContainer, source *core.CachedContainer) Filter
NewLocationSafeguard creates a filter that filters all containers that have lower distinct score than specified container.
func NewOrdinaryEngineFilter ¶
NewOrdinaryEngineFilter creates a filter that only keeps ordinary engine containers.
func NewPlacementLeaderSafeguard ¶
func NewPlacementLeaderSafeguard(scope string, cluster opt.Cluster, res *core.CachedResource, sourceContainer *core.CachedContainer, factory func() metadata.Resource) Filter
NewPlacementLeaderSafeguard creates a filter that ensures after transfer a leader with existed peer, the placement restriction will not become worse. Note that it only worked when PlacementRules enabled otherwise it will always permit the sourceContainer.
func NewPlacementSafeguard ¶
func NewPlacementSafeguard(scope string, cluster opt.Cluster, res *core.CachedResource, sourceContainer *core.CachedContainer, factory func() metadata.Resource) Filter
NewPlacementSafeguard creates a filter that ensures after replace a peer with new peer, the placement restriction will not become worse.
func NewSpecialUseFilter ¶
NewSpecialUseFilter creates a filter that filters out normal containers. By default, all containers that are not marked with a special use will be filtered out. Specify the special use label if you want to include the special containers.
func NewStorageThresholdFilter ¶
NewStorageThresholdFilter creates a Filter that filters all containers that are almost full.
type ResourceFitter ¶
type ResourceFitter interface {
FitResource(*core.CachedResource) *placement.ResourceFit
}
ResourceFitter is the interface that can fit a resource against placement rules.