filter

package
v4.0.0-beta.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectSourceStores

func SelectSourceStores(stores []*core.StoreInfo, filters []Filter, opt opt.Options) []*core.StoreInfo

SelectSourceStores selects stores that be selected as source store from the list.

func SelectTargetStores

func SelectTargetStores(stores []*core.StoreInfo, filters []Filter, opt opt.Options) []*core.StoreInfo

SelectTargetStores selects stores that be selected as target store from the list.

func Source

func Source(opt opt.Options, store *core.StoreInfo, filters []Filter) bool

Source checks if store can pass all Filters as source store.

func Target

func Target(opt opt.Options, store *core.StoreInfo, filters []Filter) bool

Target checks if store can pass all Filters as target store.

Types

type BlacklistStoreFilter

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

BlacklistStoreFilter filters the store according to the blacklist.

func NewBlacklistStoreFilter

func NewBlacklistStoreFilter(scope string, typ BlacklistType) *BlacklistStoreFilter

NewBlacklistStoreFilter creates a blacklist filter.

func (*BlacklistStoreFilter) Add

func (f *BlacklistStoreFilter) Add(storeID uint64)

Add adds the store to the blacklist.

func (*BlacklistStoreFilter) Scope

func (f *BlacklistStoreFilter) Scope() string

Scope returns the scheduler or the checker which the filter acts on.

func (*BlacklistStoreFilter) Source

func (f *BlacklistStoreFilter) Source(opt opt.Options, store *core.StoreInfo) bool

Source implements the Filter.

func (*BlacklistStoreFilter) Target

func (f *BlacklistStoreFilter) Target(opt opt.Options, store *core.StoreInfo) bool

Target implements the Filter.

func (*BlacklistStoreFilter) Type

func (f *BlacklistStoreFilter) Type() string

Type implements the Filter.

type BlacklistType

type BlacklistType int

BlacklistType the type of BlackListStore Filter.

const (
	// blacklist associated with the source.
	BlacklistSource BlacklistType = 1 << iota
	// blacklist associated with the target.
	BlacklistTarget
)

some flags about blacklist type.

type Filter

type Filter interface {
	// Scope is used to indicate where the filter will act on.
	Scope() string
	Type() string
	// Return true if the store can be used as a source store.
	Source(opt opt.Options, store *core.StoreInfo) bool
	// Return true if the store can be used as a target store.
	Target(opt opt.Options, store *core.StoreInfo) bool
}

Filter is an interface to filter source and target store.

func NewDistinctScoreFilter

func NewDistinctScoreFilter(scope string, labels []string, stores []*core.StoreInfo, source *core.StoreInfo) Filter

NewDistinctScoreFilter creates a filter that filters all stores that have lower distinct score than specified store.

func NewExcludedFilter

func NewExcludedFilter(scope string, sources, targets map[uint64]struct{}) Filter

NewExcludedFilter creates a Filter that filters all specified stores.

func NewHealthFilter

func NewHealthFilter(scope string) Filter

NewHealthFilter creates a Filter that filters all stores that are Busy or Down.

func NewLabelConstaintFilter

func NewLabelConstaintFilter(scope string, constraints []placement.LabelConstraint) Filter

NewLabelConstaintFilter creates a filter that selects stores satisfy the constraints.

func NewPendingPeerCountFilter

func NewPendingPeerCountFilter(scope string) Filter

NewPendingPeerCountFilter creates a Filter that filters all stores that are currently handling too many pending peers.

func NewRuleFitFilter

func NewRuleFitFilter(scope string, fitter RegionFitter, region *core.RegionInfo, oldStoreID uint64) Filter

NewRuleFitFilter creates a filter that ensures after replace a peer with new one, the isolation level will not decrease. Its function is the same as distinctScoreFilter but used when placement rules is enabled.

func NewSnapshotCountFilter

func NewSnapshotCountFilter(scope string) Filter

NewSnapshotCountFilter creates a Filter that filters all stores that are currently handling too many snapshots.

func NewSpecialUseFilter

func NewSpecialUseFilter(scope string, allowUses ...string) Filter

NewSpecialUseFilter creates a filter that filters stores for special use.

func NewStateFilter

func NewStateFilter(scope string) Filter

NewStateFilter creates a Filter that filters all stores that are not UP.

func NewStorageThresholdFilter

func NewStorageThresholdFilter(scope string) Filter

NewStorageThresholdFilter creates a Filter that filters all stores that are almost full.

func NewStoreLimitFilter

func NewStoreLimitFilter(scope string) Filter

NewStoreLimitFilter creates a Filter that filters all stores those exceed the limit of a store.

type RegionFitter

type RegionFitter interface {
	FitRegion(*core.RegionInfo) *placement.RegionFit
}

RegionFitter is the interface that can fit a region against placement rules.

type StoreStateFilter

type StoreStateFilter struct {
	ActionScope string
	// Set true if the schedule involves any transfer leader operation.
	TransferLeader bool
	// Set true if the schedule involves any move region operation.
	MoveRegion bool
}

StoreStateFilter is used to determine whether a store can be selected as the source or target of the schedule based on the store's state.

func (StoreStateFilter) Scope

func (f StoreStateFilter) Scope() string

Scope returns the scheduler or the checker which the filter acts on.

func (StoreStateFilter) Source

func (f StoreStateFilter) Source(opt opt.Options, store *core.StoreInfo) bool

Source returns true when the store can be selected as the schedule source.

func (StoreStateFilter) Target

func (f StoreStateFilter) Target(opts opt.Options, store *core.StoreInfo) bool

Target returns true when the store can be selected as the schedule target.

func (StoreStateFilter) Type

func (f StoreStateFilter) Type() string

Type returns the type of the Filter.

Jump to

Keyboard shortcuts

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