Documentation ¶
Index ¶
- Constants
- func ApplyOperator(mc *mockcluster.Cluster, op *operator.Operator)
- func ApplyOperatorStep(region *core.RegionInfo, op *operator.Operator) *core.RegionInfo
- func DecodeConfig(data []byte, v interface{}) error
- func EncodeConfig(v interface{}) ([]byte, error)
- func FindSchedulerTypeByName(name string) string
- func IsSchedulerRegistered(name string) bool
- func RegisterScheduler(typ string, createFn CreateSchedulerFunc)
- func RegisterSliceDecoderBuilder(typ string, builder ConfigSliceDecoderBuilder)
- type CheckerController
- type ConfigDecoder
- type ConfigSliceDecoderBuilder
- type CreateSchedulerFunc
- type HeartbeatStreams
- type OperatorController
- func (oc *OperatorController) AddOperator(ops ...*operator.Operator) bool
- func (oc *OperatorController) Ctx() context.Context
- func (oc *OperatorController) Dispatch(region *core.RegionInfo, source string)
- func (oc *OperatorController) GetOperator(regionID uint64) *operator.Operator
- func (oc *OperatorController) GetOperatorStatus(id uint64) *OperatorWithStatus
- func (oc *OperatorController) GetOperators() []*operator.Operator
- func (oc *OperatorController) OperatorCount(mask operator.OpKind) uint64
- func (oc *OperatorController) RemoveOperator(op *operator.Operator) (found bool)
- func (oc *OperatorController) SendScheduleCommand(region *core.RegionInfo, step operator.OpStep, source string)
- func (oc *OperatorController) SetOperator(op *operator.Operator)
- type OperatorRecords
- type OperatorWithStatus
- type Scheduler
Constants ¶
const ( DispatchFromHeartBeat = "heartbeat" DispatchFromNotifierQueue = "active push" DispatchFromCreate = "create" )
The source of dispatched region.
Variables ¶
This section is empty.
Functions ¶
func ApplyOperator ¶
func ApplyOperator(mc *mockcluster.Cluster, op *operator.Operator)
ApplyOperator applies operator. Only for test purpose.
func ApplyOperatorStep ¶
func ApplyOperatorStep(region *core.RegionInfo, op *operator.Operator) *core.RegionInfo
ApplyOperatorStep applies operator step. Only for test purpose.
func DecodeConfig ¶
DecodeConfig decode the custom config for each scheduler.
func EncodeConfig ¶
EncodeConfig encode the custom config for each scheduler.
func FindSchedulerTypeByName ¶
FindSchedulerTypeByName finds the type of the specified name.
func IsSchedulerRegistered ¶
IsSchedulerRegistered check where the named scheduler type is registered.
func RegisterScheduler ¶
func RegisterScheduler(typ string, createFn CreateSchedulerFunc)
RegisterScheduler binds a scheduler creator. It should be called in init() func of a package.
func RegisterSliceDecoderBuilder ¶
func RegisterSliceDecoderBuilder(typ string, builder ConfigSliceDecoderBuilder)
RegisterSliceDecoderBuilder convert arguments to config. It should be called in init() func of package.
Types ¶
type CheckerController ¶
type CheckerController struct {
// contains filtered or unexported fields
}
CheckerController is used to manage all checkers.
func NewCheckerController ¶
func NewCheckerController(ctx context.Context, cluster opt.Cluster, opController *OperatorController) *CheckerController
NewCheckerController create a new CheckerController. TODO: isSupportMerge should be removed.
func (*CheckerController) CheckRegion ¶
func (c *CheckerController) CheckRegion(region *core.RegionInfo) (bool, []*operator.Operator)
CheckRegion will check the region and add a new operator if needed.
type ConfigDecoder ¶
type ConfigDecoder func(v interface{}) error
ConfigDecoder used to decode the config.
func ConfigJSONDecoder ¶
func ConfigJSONDecoder(data []byte) ConfigDecoder
ConfigJSONDecoder used to build a json decoder of the config.
func ConfigSliceDecoder ¶
func ConfigSliceDecoder(name string, args []string) ConfigDecoder
ConfigSliceDecoder the default decode for the config.
type ConfigSliceDecoderBuilder ¶
type ConfigSliceDecoderBuilder func([]string) ConfigDecoder
ConfigSliceDecoderBuilder used to build slice decoder of the config.
type CreateSchedulerFunc ¶
type CreateSchedulerFunc func(opController *OperatorController, storage *core.Storage, dec ConfigDecoder) (Scheduler, error)
CreateSchedulerFunc is for creating scheduler.
type HeartbeatStreams ¶
type HeartbeatStreams interface {
SendMsg(region *core.RegionInfo, msg *schedulerpb.RegionHeartbeatResponse)
}
HeartbeatStreams is an interface of async region heartbeat.
type OperatorController ¶
OperatorController is used to limit the speed of scheduling.
func NewOperatorController ¶
func NewOperatorController(ctx context.Context, cluster opt.Cluster, hbStreams HeartbeatStreams) *OperatorController
NewOperatorController creates a OperatorController.
func (*OperatorController) AddOperator ¶
func (oc *OperatorController) AddOperator(ops ...*operator.Operator) bool
AddOperator adds operators to the running operators.
func (*OperatorController) Ctx ¶
func (oc *OperatorController) Ctx() context.Context
Ctx returns a context which will be canceled once RaftCluster is stopped. For now, it is only used to control the lifetime of TTL cache in schedulers.
func (*OperatorController) Dispatch ¶
func (oc *OperatorController) Dispatch(region *core.RegionInfo, source string)
Dispatch is used to dispatch the operator of a region.
func (*OperatorController) GetOperator ¶
func (oc *OperatorController) GetOperator(regionID uint64) *operator.Operator
GetOperator gets a operator from the given region.
func (*OperatorController) GetOperatorStatus ¶
func (oc *OperatorController) GetOperatorStatus(id uint64) *OperatorWithStatus
GetOperatorStatus gets the operator and its status with the specify id.
func (*OperatorController) GetOperators ¶
func (oc *OperatorController) GetOperators() []*operator.Operator
GetOperators gets operators from the running operators.
func (*OperatorController) OperatorCount ¶
func (oc *OperatorController) OperatorCount(mask operator.OpKind) uint64
OperatorCount gets the count of operators filtered by mask.
func (*OperatorController) RemoveOperator ¶
func (oc *OperatorController) RemoveOperator(op *operator.Operator) (found bool)
RemoveOperator removes a operator from the running operators.
func (*OperatorController) SendScheduleCommand ¶
func (oc *OperatorController) SendScheduleCommand(region *core.RegionInfo, step operator.OpStep, source string)
SendScheduleCommand sends a command to the region.
func (*OperatorController) SetOperator ¶
func (oc *OperatorController) SetOperator(op *operator.Operator)
SetOperator is only used for test.
type OperatorRecords ¶
type OperatorRecords struct {
// contains filtered or unexported fields
}
OperatorRecords remains the operator and its status for a while.
func NewOperatorRecords ¶
func NewOperatorRecords(ctx context.Context) *OperatorRecords
NewOperatorRecords returns a OperatorRecords.
func (*OperatorRecords) Get ¶
func (o *OperatorRecords) Get(id uint64) *OperatorWithStatus
Get gets the operator and its status.
func (*OperatorRecords) Put ¶
func (o *OperatorRecords) Put(op *operator.Operator, status schedulerpb.OperatorStatus)
Put puts the operator and its status.
type OperatorWithStatus ¶
type OperatorWithStatus struct { Op *operator.Operator Status schedulerpb.OperatorStatus }
OperatorWithStatus records the operator and its status.
func (*OperatorWithStatus) MarshalJSON ¶
func (o *OperatorWithStatus) MarshalJSON() ([]byte, error)
MarshalJSON returns the status of operator as a JSON string
type Scheduler ¶
type Scheduler interface { http.Handler GetName() string // GetType should in accordance with the name passing to schedule.RegisterScheduler() GetType() string EncodeConfig() ([]byte, error) GetMinInterval() time.Duration GetNextInterval(interval time.Duration) time.Duration Prepare(cluster opt.Cluster) error Cleanup(cluster opt.Cluster) Schedule(cluster opt.Cluster) *operator.Operator IsScheduleAllowed(cluster opt.Cluster) bool }
Scheduler is an interface to schedule resources.
func CreateScheduler ¶
func CreateScheduler(typ string, opController *OperatorController, storage *core.Storage, dec ConfigDecoder) (Scheduler, error)
CreateScheduler creates a scheduler with registered creator func.