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

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

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.