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 2.6 kB

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

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.