Documentation ¶
Index ¶
- Constants
- Variables
- func GetCapacities(u *Unit, id string) (res map[string]int64)
- func ReservedSub(key string, value value_t, reserved value_t) value_t
- type AllocatedResource
- type CandidatePropertyGetter
- 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 IResultHelper
- type IsolatedDeviceDesc
- type Kind
- type LogMessage
- type LogMessages
- type MinCounters
- type MultiCounter
- type NoResourceError
- type NormalCounter
- type PredicateFailureError
- type PredicateFailureReason
- type Priority
- type PriorityConfig
- type PriorityMapFunction
- type PriorityPreFunction
- type PriorityReduceFunction
- type ResourceAlgorithm
- type SResultHelperFunc
- type SSelectPriority
- type SSelectPriorityUpdater
- type SSelectPriorityValue
- type SchedContextDataItem
- type SchedLog
- type SchedLogList
- type SchedLogManager
- type SchedResultItem
- type SchedResultItemList
- type SchedResultItems
- type ScheduleResult
- type Scheduler
- type Score
- type ScoreValue
- type SelectPlugin
- type SelectedCandidate
- type SharedResourceManager
- type StorageUsed
- type Unit
- func (u *Unit) AllSelectPlugins() []SelectPlugin
- func (u *Unit) AppendFailedCandidates(fcs []FailedCandidate)
- func (u *Unit) AppendSelectPlugin(p SelectPlugin)
- func (u *Unit) GetAllocatedResource(candidateId string) *AllocatedResource
- 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) GetHypervisor() string
- func (u *Unit) GetHypervisorDriver() models.IGuestDriver
- func (u *Unit) GetMaxSelectPriority() (max SSelectPriorityValue)
- func (u *Unit) GetScore(id string) Score
- func (u *Unit) GetScoreDetails(id string) string
- func (u *Unit) GetSelectPriority(id string) SSelectPriorityValue
- func (u *Unit) Info() string
- func (u *Unit) RegisterSelectPriorityUpdater(name string, f SSelectPriorityUpdater)
- func (u *Unit) SchedData() *api.SchedInfo
- func (u *Unit) SessionID() string
- func (u *Unit) SetAvoidScore(id string, val score.SScore)
- 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) SetPreferScore(id string, val score.SScore)
- func (u *Unit) SetScore(id string, val score.SScore)
- func (u *Unit) SetSelectPriorityWithLock(id string, name string, spv SSelectPriorityValue)
- func (u *Unit) UpdateSelectPriority()
- type VendorModel
- type WaitGroupWrapper
Constants ¶
const ( EmptyCapacity int64 = -1 MaxCapacity int64 = 0x7FFFFFFFFFFFFFFF )
const (
NoResourceAvailableMsg = "No resource are avaliable that match all of the following predicates:"
)
const (
PriorityStep int = 1
)
Variables ¶
var ( EmptyCapacities = make(map[string]Counter) EmptySelectPriorityValue = SSelectPriorityValue(0) )
var ErrInstanceGroupNotFound = errors.Error("InstanceGroupNotFound")
Functions ¶
func ReservedSub ¶
func ReservedSub(key string, value value_t, reserved value_t) value_t
Types ¶
type AllocatedResource ¶
type AllocatedResource struct { Disks []*schedapi.CandidateDiskV2 `json:"disks"` Nets []*schedapi.CandidateNet `json:"nets"` }
func NewAllocatedResource ¶
func NewAllocatedResource() *AllocatedResource
type CandidatePropertyGetter ¶
type CandidatePropertyGetter interface { Id() string Name() string Zone() *computemodels.SZone Host() *computemodels.SHost Cloudprovider() *computemodels.SCloudprovider IsPublic() bool DomainId() string PublicScope() string Region() *computemodels.SCloudregion HostType() string Sku(string) *sku.ServerSku Storages() []*api.CandidateStorage Networks() []*api.CandidateNetwork OvnCapable() bool Status() string HostStatus() string Enabled() bool IsEmpty() bool ResourceType() string NetInterfaces() map[string][]computemodels.SNetInterface ProjectGuests() map[string]int64 CreatingGuestCount() int CPUArch() string IsArmHost() bool RunningCPUCount() int64 TotalCPUCount(useRsvd bool) int64 FreeCPUCount(useRsvd bool) int64 RunningMemorySize() int64 TotalMemorySize(useRsvd bool) int64 FreeMemorySize(useRsvd bool) int64 GetFreeCpuNuma() []*schedapi.SFreeNumaCpuMem NumaAllocateEnabled() bool StorageInfo() []*baremetal.BaremetalStorage GetFreeStorageSizeOfType(storageType string, mediumType string, useRsvd bool, reqMaxSize int64) (int64, int64, error) GetFreePort(netId string) int InstanceGroups() map[string]*api.CandidateGroup GetFreeGroupCount(groupId string) (int, error) GetAllClassMetadata() (map[string]string, error) GetIpmiInfo() types.SIPMIInfo GetNics() []*types.SNic GetQuotaKeys(s *api.SchedInfo) computemodels.SComputeResourceKeys GetPendingUsage() *schedmodels.SPendingUsage // isloatedDevices UnusedIsolatedDevices() []*IsolatedDeviceDesc UnusedIsolatedDevicesByType(devType string) []*IsolatedDeviceDesc UnusedIsolatedDevicesByVendorModel(vendorModel string) []*IsolatedDeviceDesc UnusedIsolatedDevicesByModel(model string) []*IsolatedDeviceDesc UnusedIsolatedDevicesByModelAndWire(model, wire string) []*IsolatedDeviceDesc UnusedIsolatedDevicesByDevicePath(devPath string) []*IsolatedDeviceDesc GetIsolatedDevice(devID string) *IsolatedDeviceDesc UnusedGpuDevices() []*IsolatedDeviceDesc GetIsolatedDevices() []*IsolatedDeviceDesc db.IResource }
type Candidater ¶
type Candidater interface { Getter() CandidatePropertyGetter // IndexKey return candidate cache item's ident, usually host ID IndexKey() string Type() int GetSchedDesc() *jsonutils.JSONDict GetGuestCount() int64 GetResourceType() string AllocCpuNumaPin(vcpuCount, memSizeKB int, preferNumaNodes []int) []schedapi.SCpuNumaPin AllocCpuNumaPinWithNodeCount(vcpuCount, memSizeKB, nodeCount int) []schedapi.SCpuNumaPin }
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(context.Context, *Unit, []Candidater) (bool, error) Execute(context.Context, *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(ctx context.Context, unit *Unit, candidates []Candidater, helper IResultHelper) (*ScheduleResult, error)
type HostPriority ¶
type HostPriority struct { // Name of the host Host string // Score associated with the host Score Score // 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 IResultHelper ¶
type IResultHelper interface {
ResultHelp(result *SchedResultItemList, schedInfo *api.SchedInfo) *ScheduleResult
}
type IsolatedDeviceDesc ¶
type IsolatedDeviceDesc struct { ID string GuestID string HostID string DevType string Model string Addr string VendorDeviceID string WireId string DevicePath string }
func (*IsolatedDeviceDesc) GetVendorModel ¶
func (i *IsolatedDeviceDesc) GetVendorModel() *VendorModel
func (*IsolatedDeviceDesc) VendorID ¶
func (i *IsolatedDeviceDesc) VendorID() string
type LogMessage ¶
type LogMessages ¶
type LogMessages []*LogMessage
func (LogMessages) String ¶
func (ms LogMessages) String() string
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 PredicateFailureError ¶
type PredicateFailureError interface {
GetReason() string
}
type PredicateFailureReason ¶
type PredicateFailureReason interface { PredicateFailureError GetType() 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) // Score intervals ScoreIntervals() score.Intervals }
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 SResultHelperFunc ¶
type SResultHelperFunc func(result *SchedResultItemList, schedInfo *api.SchedInfo) *ScheduleResult
ResultHelperFunc type is an adapter to allwo the use of ordinary functions as a ResultHelper. If f is a function with the appropriate signature, ResultHelperFunc(f) is a ResultHelper that calls f.
func (SResultHelperFunc) ResultHelp ¶
func (r SResultHelperFunc) ResultHelp(result *SchedResultItemList, schedInfo *api.SchedInfo) *ScheduleResult
type SSelectPriority ¶
type SSelectPriority map[string]SSelectPriorityValue
func NewSSelctPriority ¶
func NewSSelctPriority() SSelectPriority
func (SSelectPriority) Value ¶
func (s SSelectPriority) Value() (val SSelectPriorityValue)
type SSelectPriorityUpdater ¶
type SSelectPriorityUpdater func(u *Unit, origin SSelectPriorityValue, hostID string) SSelectPriorityValue
SSelectPriorityUpdater will call to update the specified host after each round of selection
type SSelectPriorityValue ¶
type SSelectPriorityValue int
func (SSelectPriorityValue) IsEmpty ¶
func (s SSelectPriorityValue) IsEmpty() bool
func (SSelectPriorityValue) Less ¶
func (s SSelectPriorityValue) Less(sp SSelectPriorityValue) bool
func (SSelectPriorityValue) Sub ¶
func (s SSelectPriorityValue) Sub(sp SSelectPriorityValue) (ret SSelectPriorityValue)
func (SSelectPriorityValue) SubOne ¶
func (s SSelectPriorityValue) SubOne() SSelectPriorityValue
type SchedContextDataItem ¶
type SchedLog ¶
type SchedLog struct { Candidate string Action string Messages LogMessages IsFailed bool }
func NewSchedLog ¶
func NewSchedLog(candidate, action string, messages LogMessages, isFailed bool) SchedLog
type SchedLogList ¶
type SchedLogList []SchedLog
func (SchedLogList) Get ¶
func (logList SchedLogList) Get(index string) *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) Appends ¶
func (m *SchedLogManager) Appends(logs []SchedLog)
func (*SchedLogManager) FailedLogs ¶
func (m *SchedLogManager) FailedLogs() SchedLogList
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 Score `json:"score"` CapacityDetails map[string]int64 `json:"capacity_details"` ScoreDetails string `json:"score_details"` Candidater Candidater `json:"-"` *AllocatedResource SchedData *api.SchedInfo }
func (*SchedResultItem) ToCandidateResource ¶
func (item *SchedResultItem) ToCandidateResource(storageUsed *StorageUsed) *schedapi.CandidateResource
type SchedResultItemList ¶
type SchedResultItemList struct { Unit *Unit Data SchedResultItems }
func (SchedResultItemList) String ¶
func (its SchedResultItemList) String() string
type SchedResultItems ¶
type SchedResultItems []*SchedResultItem
func (SchedResultItems) Len ¶
func (its SchedResultItems) Len() int
func (SchedResultItems) Less ¶
func (its SchedResultItems) Less(i, j int) bool
func (SchedResultItems) Swap ¶
func (its SchedResultItems) Swap(i, j int)
type ScheduleResult ¶
type ScheduleResult struct { // Result is sync schedule result Result *schedapi.ScheduleOutput // ForecastResult is forecast schedule result ForecastResult *api.SchedForecastResult // TestResult is test schedule result TestResult interface{} }
func ResultHelp ¶
func ResultHelp(result *SchedResultItemList, schedInfo *api.SchedInfo) *ScheduleResult
func ResultHelpForForcast ¶
func ResultHelpForForcast(result *SchedResultItemList, _ *api.SchedInfo) *ScheduleResult
func ResultHelpForTest ¶
func ResultHelpForTest(result *SchedResultItemList, schedInfo *api.SchedInfo) *ScheduleResult
type Scheduler ¶
type Scheduler interface { BeforePredicate() error Predicates() (map[string]FitPredicate, error) PriorityConfigs() ([]PriorityConfig, error) }
type Score ¶
type Score struct {
*score.ScoreBucket
}
type ScoreValue ¶
type ScoreValue struct {
// contains filtered or unexported fields
}
type SelectPlugin ¶
type SelectPlugin interface { Name() string OnPriorityEnd(*Unit, Candidater) 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) GetCount ¶
func (s SelectedCandidate) GetCount() uint64
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 StorageUsed ¶
type StorageUsed struct {
// contains filtered or unexported fields
}
func NewStorageUsed ¶
func NewStorageUsed() *StorageUsed
func (*StorageUsed) Add ¶
func (s *StorageUsed) Add(storageId string, used int64)
func (*StorageUsed) Get ¶
func (s *StorageUsed) Get(storageId string) int64
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 AllocatedResources map[string]*AllocatedResource SelectPriorityMap map[string]SSelectPriority SelectPriorityUpdaterMap map[string]SSelectPriorityUpdater SelectPriorityLock sync.Mutex // 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) GetAllocatedResource ¶
func (u *Unit) GetAllocatedResource(candidateId string) *AllocatedResource
func (*Unit) GetCapacity ¶
func (*Unit) GetFiltedData ¶
func (*Unit) GetHypervisor ¶
func (*Unit) GetHypervisorDriver ¶
func (u *Unit) GetHypervisorDriver() models.IGuestDriver
func (*Unit) GetMaxSelectPriority ¶
func (u *Unit) GetMaxSelectPriority() (max SSelectPriorityValue)
func (*Unit) GetScoreDetails ¶
func (*Unit) GetSelectPriority ¶
func (u *Unit) GetSelectPriority(id string) SSelectPriorityValue
func (*Unit) RegisterSelectPriorityUpdater ¶
func (u *Unit) RegisterSelectPriorityUpdater(name string, f SSelectPriorityUpdater)
func (*Unit) SetCapacity ¶
func (*Unit) SetFiltedData ¶
func (*Unit) SetSelectPriorityWithLock ¶
func (u *Unit) SetSelectPriorityWithLock(id string, name string, spv SSelectPriorityValue)
func (*Unit) UpdateSelectPriority ¶
func (u *Unit) UpdateSelectPriority()
type VendorModel ¶
func NewVendorModelByStr ¶
func NewVendorModelByStr(desc string) *VendorModel
func (*VendorModel) IsMatch ¶
func (vm *VendorModel) IsMatch(target *VendorModel) bool
type WaitGroupWrapper ¶
func (*WaitGroupWrapper) Wrap ¶
func (w *WaitGroupWrapper) Wrap(cb func())