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

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

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.