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.

listjoblogic.go 1.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package hpc
  2. import (
  3. "context"
  4. "gitlink.org.cn/jcce-pcm/utils/enum"
  5. "strings"
  6. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  7. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type ListJobLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewListJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListJobLogic {
  16. return &ListJobLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *ListJobLogic) ListJob(req *types.ListJobReq) (resp *types.ListJobResp, err error) {
  23. resp = &types.ListJobResp{}
  24. var tasks []types.Job
  25. // 查询任务数据
  26. tx := l.svcCtx.DbEngin.Raw("SELECT h.service_name as SlurmVersion,h.name,h.start_time as JobStartTime,h.running_time as JobRunTime,t.status as StateofJob from hpc h join task t on t.id = h.task_id and t.status != 'Completed'").Scan(&tasks)
  27. if tx.Error != nil {
  28. logx.Error(err)
  29. return nil, tx.Error
  30. }
  31. for _, task := range tasks {
  32. // 承接方转义
  33. if task.SlurmVersion != "" {
  34. var names []string
  35. servicesName := strings.Split(task.SlurmVersion, ",")
  36. for _, name := range servicesName {
  37. names = append(names, enum.Partner(name).String())
  38. }
  39. task.SlurmVersion = strings.Join(names, ",")
  40. }
  41. resp.Jobs = append(resp.Jobs, types.Job{
  42. SlurmVersion: task.SlurmVersion,
  43. Name: task.Name,
  44. JobStartTime: task.JobStartTime,
  45. JobRunTime: task.JobRunTime + "s",
  46. StateofJob: task.StateofJob,
  47. })
  48. }
  49. resp.Code = 200
  50. resp.Msg = "success"
  51. resp.RecordCount = int32(len(resp.Jobs))
  52. return resp, nil
  53. }

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.