调度结构修改5
Former-commit-id: 89372339e77858bc2b6c5443520402611f0c9bb2
This commit is contained in:
parent
b87abd2a62
commit
47d0ae257b
|
@ -3,7 +3,7 @@ package algo
|
||||||
import "math"
|
import "math"
|
||||||
|
|
||||||
type Provider struct {
|
type Provider struct {
|
||||||
Pid int
|
Pid int64
|
||||||
CpuSum float64
|
CpuSum float64
|
||||||
MemSum float64
|
MemSum float64
|
||||||
DiskSum float64
|
DiskSum float64
|
||||||
|
@ -23,7 +23,7 @@ type Provider struct {
|
||||||
ProfitPerTask map[int]float64
|
ProfitPerTask map[int]float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProvider(Pid int, CpuSum float64, MemSum float64, DiskSum float64, CpuCost float64, MemCost float64, DiskCost float64) *Provider {
|
func NewProvider(Pid int64, CpuSum float64, MemSum float64, DiskSum float64, CpuCost float64, MemCost float64, DiskCost float64) *Provider {
|
||||||
return &Provider{
|
return &Provider{
|
||||||
Pid: Pid,
|
Pid: Pid,
|
||||||
CpuSum: CpuSum,
|
CpuSum: CpuSum,
|
||||||
|
|
|
@ -48,6 +48,12 @@ func (s *scheduler) MatchLabels(dbEngin *gorm.DB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *scheduler) AssignAndSchedule() error {
|
func (s *scheduler) AssignAndSchedule() error {
|
||||||
|
// 已指定 ParticipantId
|
||||||
|
if s.task.ParticipantId != 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成算法所需参数
|
||||||
task, providerList := s.genTaskAndProviders()
|
task, providerList := s.genTaskAndProviders()
|
||||||
|
|
||||||
strategy, err := s.scheduleService.pickOptimalStrategy(task, providerList...)
|
strategy, err := s.scheduleService.pickOptimalStrategy(task, providerList...)
|
||||||
|
@ -57,6 +63,7 @@ func (s *scheduler) AssignAndSchedule() error {
|
||||||
|
|
||||||
if strategy == nil {
|
if strategy == nil {
|
||||||
s.task.ParticipantId = s.participantIds[0]
|
s.task.ParticipantId = s.participantIds[0]
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -79,5 +86,10 @@ func (s *scheduler) SaveToDb(dbEngin *gorm.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *scheduler) genTaskAndProviders() (*algo.Task, []*algo.Provider) {
|
func (s *scheduler) genTaskAndProviders() (*algo.Task, []*algo.Provider) {
|
||||||
|
//var providerList []*algo.Provider
|
||||||
|
//for _, id := range s.participantIds {
|
||||||
|
// provider := algo.NewProvider(id, 100, 200, 200, 0.0, 0.0, 0.0)
|
||||||
|
//
|
||||||
|
//}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue