Documentation
¶
Index ¶
- Constants
- Variables
- func GetCapacities(u *Unit, id string) (res map[string]int64)
- func GetScore(u *Unit, id string, details bool) string
- func ReservedSub(key string, value value_t, reserved value_t) value_t
- func XGetCalculator(c Candidater, key string, kind Kind) value_t
- type Candidater
- type Capacity
- type Counter
- type CounterManager
- type Counters
- type DefaultResAlgorithm
- type FailedCandidate
- type FailedCandidates
- type FailedPredicateMap
- type FitError
- type FitPredicate
- type GenericScheduler
- type HostPriority
- type HostPriorityList
- type Kind
- type MinCounters
- type MultiCounter
- type NoResourceError
- type NormalCounter
- type PredicateFailureReason
- type Priority
- type PriorityConfig
- type PriorityMapFunction
- type PriorityPreFunction
- type PriorityReduceFunction
- type ResourceAlgorithm
- type SchedContextDataItem
- type SchedLog
- type SchedLogList
- type SchedLogManager
- type SchedResultItem
- type SchedResultItemList
- type Scheduler
- type Score
- type SelectPlugin
- type SelectedCandidate
- type SharedResourceManager
- type Unit
- func (u *Unit) AllSelectPlugins() []SelectPlugin
- func (u *Unit) AppendFailedCandidates(fcs []FailedCandidate)
- func (u *Unit) AppendSelectPlugin(p SelectPlugin)
- func (u *Unit) GetCapacities(id string) map[string]Counter
- func (u *Unit) GetCapacity(id string) int64
- func (u *Unit) GetCapacityOfName(id string, name string) int64
- func (u *Unit) GetFiltedData(id string, count int64) map[string]interface{}
- func (u *Unit) GetScore(id string) int
- func (u *Unit) GetScores(id string) map[string]int
- func (u *Unit) IncreaseScore(id string, name string, increase int) error
- func (u *Unit) Info() string
- func (u *Unit) IsPublicCloudProvider() bool
- func (u *Unit) SchedData() *api.SchedData
- func (u *Unit) SessionID() string
- func (u *Unit) SetCapacity(id string, name string, capacity Counter) error
- func (u *Unit) SetFiltedData(id string, name string, data interface{}) error
- func (u *Unit) SetScore(id, name string, score int) error
- func (u *Unit) SkipDirtyMarkHost() bool
- type WaitGroupWrapper
Constants ¶
const ( EmptyScore int = 0x7FFFFFFFFFFFFFFF BaseScore int = 10000 EmptyCapacity int64 = -1 MaxCapacity int64 = 0x7FFFFFFFFFFFFFFF )
const (
NoResourceAvailableMsg = "No resource are avaliable that match all of the following predicates:"
)
const (
PriorityStep int = 100
)
Variables ¶
Functions ¶
func ReservedSub ¶
func ReservedSub(key string, value value_t, reserved value_t) value_t
func XGetCalculator ¶
func XGetCalculator(c Candidater, key string, kind Kind) value_t
Types ¶
type Candidater ¶
type Candidater interface {
// IndexKey return candidate cache item's ident, usually host ID
IndexKey() string
// Get return candidate cache item's value by key
Get(key string) interface{}
// XGet return candidate cache item's value by key and kind
XGet(key string, kind Kind) interface{}
Type() int
GetAggregates() []*models.Aggregate
GetHostAggregates() []*models.Aggregate
}
Candidater replace host Candidate resource info
type CounterManager ¶
type CounterManager struct {
Counters map[string]Counter
// contains filtered or unexported fields
}
func NewCounterManager ¶
func NewCounterManager() *CounterManager
func (*CounterManager) Get ¶
func (m *CounterManager) Get(key string) Counter
func (*CounterManager) GetOrCreate ¶
func (m *CounterManager) GetOrCreate(key string, creator func() Counter) Counter
type Counters ¶
type Counters struct {
// contains filtered or unexported fields
}
func NewCounters ¶
func NewCounters() *Counters
type DefaultResAlgorithm ¶
type DefaultResAlgorithm struct{}
func (*DefaultResAlgorithm) Sub ¶
func (al *DefaultResAlgorithm) Sub(sum value_t, reserved value_t) value_t
func (*DefaultResAlgorithm) Sum ¶
func (al *DefaultResAlgorithm) Sum(values []value_t) value_t
type FailedCandidate ¶
type FailedCandidate struct {
Stage string
Candidate Candidater
Reasons []PredicateFailureReason
}
type FailedCandidates ¶
type FailedCandidates struct {
Candidates []FailedCandidate
}
type FailedPredicateMap ¶
type FailedPredicateMap map[string][]PredicateFailureReason
type FitError ¶
type FitError struct {
Unit *Unit
FailedCandidateMap map[string]*FailedCandidates
}
type FitPredicate ¶
type FitPredicate interface {
// Get filter's name
Name() string
Clone() FitPredicate
PreExecute(*Unit, []Candidater) (bool, error)
Execute(*Unit, Candidater) (bool, []PredicateFailureReason, error)
}
type GenericScheduler ¶
type GenericScheduler struct {
Scheduler
// contains filtered or unexported fields
}
func NewGenericScheduler ¶
func NewGenericScheduler(s Scheduler) (*GenericScheduler, error)
func (*GenericScheduler) Schedule ¶
func (g *GenericScheduler) Schedule(unit *Unit, candidates []Candidater) ([]*SchedResultItem, error)
type HostPriority ¶
type HostPriority struct {
// Name of the host
Host string
// Score associated with the host
Score int
// Resource wraps Candidate host info
Candidate Candidater
}
HostPriority represents the priority of scheduling to particular host, higher priority is better.
func EqualPriority ¶
func EqualPriority(_ *Unit, candidate Candidater) (HostPriority, error)
EqualPriority is a prioritizer function that gives an equal weight of one to all candidates
type HostPriorityList ¶
type HostPriorityList []HostPriority
func PrioritizeCandidates ¶
func PrioritizeCandidates( unit *Unit, candidates []Candidater, priorities []PriorityConfig, ) (HostPriorityList, error)
PrioritizeCandidates by running the individual priority functions in parallel. Each priority function is expected to set a score of 0-10 0 is the lowest priority score (least preffered node) and 10 is the highest / Each priority function can also have its own weight The resource scores returned by priority function are multiplied by the weights to get weighted scores All scores are finally combined (added) to get the total weighted scores of all resources
func (HostPriorityList) Len ¶
func (h HostPriorityList) Len() int
func (HostPriorityList) Less ¶
func (h HostPriorityList) Less(i, j int) bool
func (HostPriorityList) Swap ¶
func (h HostPriorityList) Swap(i, j int)
type MinCounters ¶
type MinCounters struct {
// contains filtered or unexported fields
}
func NewMinCounters ¶
func NewMinCounters() *MinCounters
func (*MinCounters) Add ¶
func (c *MinCounters) Add(counter Counter)
func (*MinCounters) GetCount ¶
func (c *MinCounters) GetCount() int64
type MultiCounter ¶
type NoResourceError ¶
type NoResourceError struct {
// contains filtered or unexported fields
}
func (*NoResourceError) Error ¶
func (e *NoResourceError) Error() string
type NormalCounter ¶
type NormalCounter struct {
Value int64
}
func NewNormalCounter ¶
func NewNormalCounter(value int64) *NormalCounter
func (*NormalCounter) GetCount ¶
func (c *NormalCounter) GetCount() int64
type PredicateFailureReason ¶
type PredicateFailureReason interface {
GetReason() string
}
type Priority ¶
type Priority interface {
Name() string
Clone() Priority
Map(*Unit, Candidater) (HostPriority, error)
Reduce(*Unit, []Candidater, HostPriorityList) error
PreExecute(*Unit, []Candidater) (bool, []PredicateFailureReason, error)
}
type PriorityConfig ¶
type PriorityConfig struct {
Name string
Pre PriorityPreFunction
Map PriorityMapFunction
Reduce PriorityReduceFunction
Weight int
}
type PriorityMapFunction ¶
type PriorityMapFunction func(*Unit, Candidater) (HostPriority, error)
PriorityMapFunction is a function that computes per-resource results for a given resource.
type PriorityPreFunction ¶
type PriorityPreFunction func(*Unit, []Candidater) (bool, []PredicateFailureReason, error)
type PriorityReduceFunction ¶
type PriorityReduceFunction func(*Unit, []Candidater, HostPriorityList) error
PriorityReduceFunction is a function that aggregated per-resource results and computes final scores for all hosts.
type ResourceAlgorithm ¶
type ResourceAlgorithm interface {
Sum(values []value_t) value_t
Sub(sum value_t, reserved value_t) value_t
}
func GetResourceAlgorithm ¶
func GetResourceAlgorithm(res_name string) ResourceAlgorithm
type SchedContextDataItem ¶
type SchedLog ¶
func NewSchedLog ¶
type SchedLogList ¶
type SchedLogList []SchedLog
func (SchedLogList) Len ¶
func (logList SchedLogList) Len() int
func (SchedLogList) Less ¶
func (logList SchedLogList) Less(i, j int) bool
func (SchedLogList) Swap ¶
func (logList SchedLogList) Swap(i, j int)
type SchedLogManager ¶
type SchedLogManager struct {
Logs SchedLogList
// contains filtered or unexported fields
}
func NewSchedLogManager ¶
func NewSchedLogManager() *SchedLogManager
func (*SchedLogManager) Append ¶
func (m *SchedLogManager) Append(candidate, action, message string)
func (*SchedLogManager) Appends ¶
func (m *SchedLogManager) Appends(logs []SchedLog)
func (*SchedLogManager) Read ¶
func (m *SchedLogManager) Read() []string
type SchedResultItem ¶
type SchedResultItem struct {
ID string `json:"id"`
Name string `json:"name"`
Count int64 `json:"count"`
Data map[string]interface{} `json:"data"`
Capacity int64 `json:"capacity"`
Score int `json:"score"`
CapacityDetails map[string]int64 `json:"capacity_details"`
ScoreDetails map[string]int `json:"score_details"`
}
type SchedResultItemList ¶
type SchedResultItemList struct {
Unit *Unit
Data []*SchedResultItem
}
func (SchedResultItemList) Len ¶
func (its SchedResultItemList) Len() int
func (SchedResultItemList) Less ¶
func (its SchedResultItemList) Less(i, j int) bool
type Scheduler ¶
type Scheduler interface {
BeforePredicate() error
Predicates() (map[string]FitPredicate, error)
PriorityConfigs() ([]PriorityConfig, error)
// mark already selected candidates dirty that
// can't be use again until cleanup them
DirtySelectedCandidates([]*SelectedCandidate)
}
type SelectPlugin ¶
type SelectPlugin interface {
OnSelect(*Unit, Candidater) bool
OnSelectEnd(u *Unit, c Candidater, count int64)
}
type SelectedCandidate ¶
type SelectedCandidate struct {
Count int64
Candidate Candidater
}
func SelectHosts ¶
func SelectHosts(unit *Unit, priorityList HostPriorityList) ([]*SelectedCandidate, error)
SelectHosts takes a prioritized list of candidates and then picks a group of hosts
func (SelectedCandidate) Index ¶
func (s SelectedCandidate) Index() (string, error)
type SharedResourceManager ¶
type SharedResourceManager struct {
// contains filtered or unexported fields
}
func NewSharedResourceManager ¶
func NewSharedResourceManager() *SharedResourceManager
func (*SharedResourceManager) Add ¶
func (m *SharedResourceManager) Add(resourceKey string, capacity Counter)
type Unit ¶
type Unit struct {
SchedInfo *api.SchedInfo
CapacityMap map[string]*Capacity
ScoreMap map[string]Score
DataMap map[string]*SchedContextDataItem
CounterManager *CounterManager
FailedCandidateMap map[string]*FailedCandidates
SchedulerManager interface{}
LogManager *SchedLogManager
// contains filtered or unexported fields
}
Unit wraps sched input info and other log and record manager
func NewScheduleUnit ¶
func (*Unit) AllSelectPlugins ¶
func (u *Unit) AllSelectPlugins() []SelectPlugin
func (*Unit) AppendFailedCandidates ¶
func (u *Unit) AppendFailedCandidates(fcs []FailedCandidate)
func (*Unit) AppendSelectPlugin ¶
func (u *Unit) AppendSelectPlugin(p SelectPlugin)
func (*Unit) GetCapacity ¶
func (*Unit) GetFiltedData ¶
func (*Unit) IncreaseScore ¶
func (*Unit) IsPublicCloudProvider ¶
func (*Unit) SetCapacity ¶
func (*Unit) SetFiltedData ¶
func (*Unit) SkipDirtyMarkHost ¶
type WaitGroupWrapper ¶
func (*WaitGroupWrapper) Wrap ¶
func (w *WaitGroupWrapper) Wrap(cb func())