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.

schedulesubmitlogic.go 3.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package schedule
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
  9. "strconv"
  10. "strings"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type ScheduleSubmitLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewScheduleSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleSubmitLogic {
  19. return &ScheduleSubmitLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *types.ScheduleResp, err error) {
  26. resp = &types.ScheduleResp{}
  27. opt := &option.AiOption{
  28. AdapterId: req.AiOption.AdapterId,
  29. ClusterIds: req.AiOption.AiClusterIds,
  30. TaskName: req.AiOption.TaskName,
  31. ResourceType: req.AiOption.ResourceType,
  32. Replica: req.AiOption.Replica,
  33. ComputeCard: req.AiOption.ComputeCard,
  34. Tops: req.AiOption.Tops,
  35. TaskType: req.AiOption.TaskType,
  36. DatasetsName: req.AiOption.Datasets,
  37. AlgorithmName: req.AiOption.Algorithm,
  38. StrategyName: req.AiOption.Strategy,
  39. ClusterToStaticWeight: req.AiOption.StaticWeightMap,
  40. Params: req.AiOption.Params,
  41. Envs: req.AiOption.Envs,
  42. Cmd: req.AiOption.Cmd,
  43. }
  44. aiSchdl, err := schedulers.NewAiScheduler(l.ctx, "", l.svcCtx.Scheduler, opt)
  45. if err != nil {
  46. return nil, err
  47. }
  48. results, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl)
  49. if err != nil {
  50. return nil, err
  51. }
  52. switch opt.GetOptionType() {
  53. case option.AI:
  54. rs := (results).([]*schedulers.AiResult)
  55. var synergystatus int64
  56. if len(rs) > 1 {
  57. synergystatus = 1
  58. }
  59. strategyCode, err := l.svcCtx.Scheduler.AiStorages.GetStrategyCode(req.AiOption.Strategy)
  60. if err != nil {
  61. return nil, err
  62. }
  63. adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(rs[0].AdapterId)
  64. if err != nil {
  65. return nil, err
  66. }
  67. id, err := l.svcCtx.Scheduler.AiStorages.SaveTask(req.AiOption.TaskName, strategyCode, synergystatus, "10")
  68. if err != nil {
  69. return nil, err
  70. }
  71. for _, r := range rs {
  72. scheResult := &types.ScheduleResult{}
  73. scheResult.ClusterId = r.ClusterId
  74. scheResult.TaskId = strconv.FormatInt(id, 10)
  75. scheResult.JobId = r.JobId
  76. scheResult.Strategy = r.Strategy
  77. scheResult.Card = strings.ToUpper(r.Card)
  78. scheResult.Replica = r.Replica
  79. scheResult.Msg = r.Msg
  80. opt.ComputeCard = strings.ToUpper(r.Card)
  81. clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(r.ClusterId)
  82. err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, r.ClusterId, clusterName, r.JobId, constants.Saved, r.Msg)
  83. if err != nil {
  84. return nil, err
  85. }
  86. l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(r.AdapterId, adapterName, r.ClusterId, clusterName, r.TaskName, "create", "任务创建中")
  87. resp.Results = append(resp.Results, scheResult)
  88. }
  89. }
  90. return resp, nil
  91. }

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.