plan

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusStoreScoreDisallowed represents the plan is no need to be scheduled due to the score does meet the requirement.
	StatusStoreScoreDisallowed = iota + 100
	// StatusStoreAlreadyHasPeer represents the store is excluded due to the existed region peer.
	StatusStoreAlreadyHasPeer
	// StatusStoreNotMatchRule represents the placement rule cannot satisfy the requirement.
	StatusStoreNotMatchRule
)

normal status in most of situations.

View Source
const (
	// StatusStoreSnapshotThrottled represents the store cannot be selected due to the snapshot limitation.
	StatusStoreSnapshotThrottled = iota + 200
	// StatusStorePendingPeerThrottled represents the store cannot be selected due to the pending peer limitation.
	StatusStorePendingPeerThrottled
	// StatusStoreAddLimitThrottled represents the store cannot be selected due to the add peer limitation.
	StatusStoreAddLimitThrottled
	// StatusStoreRemoveLimitThrottled represents the store cannot be selected due to the remove peer limitation.
	StatusStoreRemoveLimitThrottled
)

soft limitation

View Source
const (
	// StatusStoreRejectLeader represents the store is restricted by the special configuration. e.g. reject label setting, evict leader/slow store scheduler.
	StatusStoreRejectLeader = iota + 300
	// StatusNotMatchIsolation represents the isolation cannot satisfy the requirement.
	StatusStoreNotMatchIsolation
)

config limitation

View Source
const (
	// StatusStoreBusy represents the store cannot be selected due to it is busy.
	StatusStoreBusy = iota + 400
	// StatusStoreRemoved represents the store cannot be selected due to it has been removed.
	StatusStoreRemoved
	// StatusStoreRemoving represents the data on the store is moving out.
	StatusStoreRemoving
	// StatusStoreDown represents the the store is in down state.
	StatusStoreDown
	// StatusStoreDisconnected represents the the store is in disconnected state.
	StatusStoreDisconnected
)

hard limitation

View Source
const (
	// StatusStoreLowSpace represents the store cannot be selected because it runs out of space.
	StatusStoreLowSpace = iota + 500
	// StatusStoreNotExisted represents the store cannot be found in PD.
	StatusStoreNotExisted
)
View Source
const (
	// StatusRegionHot represents the region cannot be selected due to the heavy load.
	StatusRegionHot = iota + 1000
	// StatusRegionUnhealthy represents the region cannot be selected due to the region health.
	StatusRegionUnhealthy
	// StatusRegionEmpty represents the region cannot be selected due to the region is empty.
	StatusRegionEmpty
	// StatusRegionNotReplicated represents the region does not have enough replicas.
	StatusRegionNotReplicated
	// StatusRegionNotMatchRule represents the region does not match rule constraint.
	StatusRegionNotMatchRule
	// StatusRegionNoLeader represents the region has no leader.
	StatusRegionNoLeader
	// StatusNoTargetRegion represents nts the target region of merge operation cannot be found.
	StatusNoTargetRegion
	// StatusRegionLabelReject represents the plan conflicts with region label.
	StatusRegionLabelReject
	// StatusRegionSendSnapshotThrottled represents the plan conflicts with send snapshot.
	StatusRegionSendSnapshotThrottled
)

TODO: define region status priority

View Source
const (
	// StatusCreateOperatorFailed represents the plan can not create operators.
	StatusCreateOperatorFailed = iota + 2000
)

Variables

This section is empty.

Functions

func StatusText

func StatusText(code StatusCode) string

StatusText turns the status code into string.

Types

type Collector

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

Collector is a plan collector

func NewCollector

func NewCollector(plan Plan) *Collector

NewCollector returns a new Collector

func (*Collector) Collect

func (c *Collector) Collect(opts ...Option)

Collect is used to collect a new Plan and save it into PlanCollector

func (*Collector) GetPlans

func (c *Collector) GetPlans() []Plan

GetPlans returns all plans and the first part plans are schedulable

type Option

type Option func(plan Plan)

Option is to do some action for plan

func SetResource

func SetResource(resource interface{}) Option

SetResource is used to generate Resource for plan

func SetResourceWithStep

func SetResourceWithStep(resource interface{}, step int) Option

SetResourceWithStep is used to generate Resource for plan

func SetStatus

func SetStatus(status *Status) Option

SetStatus is used to set status for plan

type Plan

type Plan interface {
	GetStep() int
	GetStatus() *Status
	GetResource(int) uint64

	Clone(ops ...Option) Plan // generate plan for clone option
	SetResource(interface{})
	// SetResourceWithStep is used to set resource for specific step.
	// The meaning of step is different for different plans.
	// Such as balancePlan, pickSource = 0, pickRegion = 1, pickTarget = 2
	SetResourceWithStep(resource interface{}, step int)
	SetStatus(*Status)
}

Plan is the basic unit for both scheduling and diagnosis. TODO: for each scheduler/checker, we can have an individual definition but need to implement the common interfaces.

type Status

type Status struct {
	StatusCode StatusCode
	// TODO: Try to indicate the user to do some actions through this field.
	DetailedReason string
}

Status describes a plan's result.

func NewStatus

func NewStatus(statusCode StatusCode, reason ...string) *Status

NewStatus create a new plan status.

func (*Status) IsNormal

func (s *Status) IsNormal() bool

IsNormal returns true if the status is noraml.

func (*Status) IsOK

func (s *Status) IsOK() bool

IsOK returns true if the status code is StatusOK.

func (*Status) Priority

func (s *Status) Priority() float32

Priority returns the priority of status for diagnose

func (*Status) String

func (s *Status) String() string

type StatusCode

type StatusCode int

StatusCode is used to classify the plan result. And the sequence of status code represents the priority, the status code number is higher, the priority is higher.

const (
	// StatusOK represents the plan can be scheduled successfully.
	StatusOK StatusCode = iota
)

type Summary

type Summary func([]Plan) (map[uint64]Status, bool, error)

Summary is used to analyse plan simply. It will return the status of store.

Jump to

Keyboard shortcuts

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