You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

aiScheduler.go 2.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package scheduler
  13. import (
  14. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/pkg/response"
  15. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
  16. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/scheduler/algo"
  17. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
  18. "gorm.io/gorm"
  19. )
  20. type aiScheduler struct {
  21. yamlString string
  22. }
  23. func NewAiScheduler(val string) *aiScheduler {
  24. return &aiScheduler{yamlString: val}
  25. }
  26. func (as *aiScheduler) getNewStructForDb(task *response.TaskInfo, resource interface{}, participantId int64) (interface{}, error) {
  27. ai := models.Ai{
  28. ParticipantId: participantId,
  29. TaskId: task.TaskId,
  30. Status: "Saved",
  31. YamlString: as.yamlString,
  32. }
  33. utils.Convert(task.Metadata, &ai)
  34. return ai, nil
  35. }
  36. func (as *aiScheduler) pickOptimalStrategy(task *algo.Task, providers ...*algo.Provider) (*algo.Strategy, error) {
  37. return nil, nil
  38. }
  39. func (as *aiScheduler) genTaskAndProviders(task *response.TaskInfo, dbEngin *gorm.DB) (*algo.Task, []*algo.Provider) {
  40. var proParams []providerParams
  41. sqlstr := "SELECT SUM(a.disk_avail) as disk_avail,SUM(a.mem_avail) as mem_avail,SUM(a.cpu_total * a.cpu_usable) as cpu_avail,participant_id from (SELECT * from sc_node_avail_info where created_time in (SELECT MAX(created_time) as time from sc_node_avail_info where deleted_flag = 0 GROUP BY participant_id,node_name)) a GROUP BY a.participant_id"
  42. dbEngin.Raw(sqlstr).Scan(&proParams)
  43. var providerList []*algo.Provider
  44. for _, p := range proParams {
  45. provider := algo.NewProvider(p.Participant_id, p.Cpu_avail, p.Mem_avail, p.Disk_avail, 0.0, 0.0, 0.0)
  46. providerList = append(providerList, provider)
  47. }
  48. t := algo.NewTask(0, 1, 2, 75120000, 301214500, 1200, 2, 6, 2000)
  49. return t, providerList
  50. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.