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.

commithpctasklogic.go 2.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package hpc
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
  6. "k8s.io/apimachinery/pkg/util/json"
  7. "time"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  9. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type CommitHpcTaskLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewCommitHpcTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitHpcTaskLogic {
  18. return &CommitHpcTaskLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *types.CommitHpcTaskResp, err error) {
  25. // 构建主任务结构体
  26. taskModel := models.Task{
  27. Status: constants.Saved,
  28. Description: req.Description,
  29. Name: req.Name,
  30. CommitTime: time.Now(),
  31. }
  32. // 保存任务数据到数据库
  33. tx := l.svcCtx.DbEngin.Create(&taskModel)
  34. if tx.Error != nil {
  35. return nil, tx.Error
  36. }
  37. env, _ := json.Marshal(req.Environment)
  38. hpcInfo := models.TaskHpc{
  39. TaskId: taskModel.Id,
  40. ClusterId: 1706858330967773111,
  41. Name: taskModel.Name,
  42. Status: "Saved",
  43. CmdScript: req.CmdScript,
  44. StartTime: time.Now().String(),
  45. CardCount: req.CardCount,
  46. WorkDir: req.WorkDir,
  47. WallTime: req.WallTime,
  48. AppType: req.AppType,
  49. AppName: req.AppName,
  50. Queue: req.Queue,
  51. SubmitType: req.SubmitType,
  52. NNode: req.NNode,
  53. StdOutFile: req.StdOutFile,
  54. StdErrFile: req.StdErrFile,
  55. StdInput: req.StdInput,
  56. DeletedFlag: 0,
  57. CreatedBy: req.ParticipantId,
  58. CreatedTime: time.Now(),
  59. UpdatedBy: req.ParticipantId,
  60. UpdatedTime: time.Now(),
  61. Environment: string(env),
  62. }
  63. tx = l.svcCtx.DbEngin.Create(&hpcInfo)
  64. if tx.Error != nil {
  65. return nil, tx.Error
  66. }
  67. // 将任务数据转换成消息体
  68. //reqMessage, err := json.Marshal(mqInfo)
  69. //if err != nil {
  70. // logx.Error(err)
  71. // return nil, err
  72. //}
  73. //publish := l.svcCtx.RedisClient.Publish(context.Background(), mqInfo.TaskType, reqMessage)
  74. //if publish.Err() != nil {
  75. // return nil, publish.Err()
  76. //}
  77. return
  78. }

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.