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.

scheduleruntasklogic.go 2.2 kB

11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package schedule
  2. import (
  3. "context"
  4. "errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy"
  9. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
  10. "gopkg.in/yaml.v2"
  11. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  12. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  13. "github.com/zeromicro/go-zero/core/logx"
  14. )
  15. type ScheduleRunTaskLogic struct {
  16. logx.Logger
  17. ctx context.Context
  18. svcCtx *svc.ServiceContext
  19. }
  20. func NewScheduleRunTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleRunTaskLogic {
  21. return &ScheduleRunTaskLogic{
  22. Logger: logx.WithContext(ctx),
  23. ctx: ctx,
  24. svcCtx: svcCtx,
  25. }
  26. }
  27. func (l *ScheduleRunTaskLogic) ScheduleRunTask(req *types.RunTaskReq) (resp *types.RunTaskResp, err error) {
  28. task, err := l.svcCtx.Scheduler.AiStorages.GetTaskById(req.TaskID)
  29. if err != nil {
  30. return nil, err
  31. }
  32. if task == nil {
  33. return nil, errors.New("task not found ")
  34. }
  35. if task.Status == constants.Cancelled {
  36. return nil, errors.New("task has been cancelled ")
  37. }
  38. var clusters []*strategy.AssignedCluster
  39. err = yaml.Unmarshal([]byte(task.YamlString), &clusters)
  40. if err != nil {
  41. return nil, err
  42. }
  43. opt := &option.AiOption{}
  44. aiSchdl, err := schedulers.NewAiScheduler(l.ctx, "", l.svcCtx.Scheduler, opt)
  45. if err != nil {
  46. return nil, err
  47. }
  48. _, err = l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl, scheduler.STORAGE_SCHEDULE_MODE, clusters)
  49. if err != nil {
  50. return nil, err
  51. }
  52. //adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(ADAPTERID)
  53. //if err != nil {
  54. // return nil, err
  55. //}
  56. //
  57. //for _, i := range clusters {
  58. // clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(i.ClusterID)
  59. //
  60. // opt := &option.AiOption{}
  61. //
  62. // err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(task.Id, opt, adapterName, i.ClusterID, clusterName, "", constants.Saved, "")
  63. // if err != nil {
  64. // return nil, errors.New("database add failed: " + err.Error())
  65. // }
  66. //}
  67. return
  68. }

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.