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.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type ScheduleSubmitLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewScheduleSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleSubmitLogic {
  16. return &ScheduleSubmitLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *types.ScheduleResp, err error) {
  23. resp = &types.ScheduleResp{}
  24. opt := &option.AiOption{
  25. AdapterId: req.AiOption.AdapterId,
  26. ResourceType: req.AiOption.ResourceType,
  27. Tops: req.AiOption.Tops,
  28. TaskType: req.AiOption.TaskType,
  29. DatasetsName: req.AiOption.Datasets,
  30. AlgorithmName: req.AiOption.Algorithm,
  31. StrategyName: req.AiOption.Strategy,
  32. ClusterToStaticWeight: req.AiOption.StaticWeightMap,
  33. Params: req.AiOption.Params,
  34. Envs: req.AiOption.Envs,
  35. Cmd: req.AiOption.Cmd,
  36. }
  37. aiSchdl, err := schedulers.NewAiScheduler(l.ctx, "", l.svcCtx.Scheduler, opt)
  38. if err != nil {
  39. return nil, err
  40. }
  41. results, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl)
  42. if err != nil {
  43. return nil, err
  44. }
  45. switch opt.GetOptionType() {
  46. case option.AI:
  47. rs := (results).([]*schedulers.AiResult)
  48. for _, r := range rs {
  49. scheResult := &types.ScheduleResult{}
  50. scheResult.ClusterId = r.ClusterId
  51. scheResult.TaskId = r.TaskId
  52. scheResult.Strategy = r.Strategy
  53. scheResult.Replica = r.Replica
  54. scheResult.Msg = r.Msg
  55. resp.Results = append(resp.Results, scheResult)
  56. }
  57. err = l.svcCtx.Scheduler.AiStorages.SaveTask(req.AiOption.TaskName)
  58. if err != nil {
  59. return nil, err
  60. }
  61. }
  62. return resp, nil
  63. }

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.