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.

jobinfologic.go 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package hpc
  2. import (
  3. "context"
  4. "github.com/go-resty/resty/v2"
  5. "github.com/pkg/errors"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  8. "gitlink.org.cn/JointCloud/pcm-hpc/slurm"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type JobInfoLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewJobInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobInfoLogic {
  17. return &JobInfoLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *JobInfoLogic) JobInfo(req *types.JobInfoReq) (resp *types.JobInfoResp, err error) {
  24. resp = &types.JobInfoResp{}
  25. var clusterInfo *types.ClusterInfo
  26. tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(&clusterInfo)
  27. if tx.Error != nil {
  28. return nil, tx.Error
  29. }
  30. // 查询p端调用地址
  31. var adapterAddress string
  32. l.svcCtx.DbEngin.Raw("SELECT server FROM `t_adapter` where id = ?", clusterInfo.AdapterId).Scan(&adapterAddress)
  33. var jobResp slurm.GetJobResp
  34. httpClient := resty.New().R()
  35. _, err = httpClient.SetHeader("Content-Type", "application/json").
  36. SetQueryParams(map[string]string{
  37. "jobId": req.JobId,
  38. "server": clusterInfo.Server,
  39. "version": clusterInfo.Version,
  40. "token": clusterInfo.Token,
  41. "username": clusterInfo.Username,
  42. }).
  43. SetResult(&jobResp).
  44. Get(adapterAddress + "/api/v1/job/info")
  45. if err != nil {
  46. return nil, err
  47. }
  48. if len(jobResp.Errors) != 0 {
  49. return nil, errors.Errorf(jobResp.Errors[0].Description)
  50. }
  51. resp.JobId = jobResp.Jobs[0].JobId
  52. resp.JobState = jobResp.Jobs[0].JobState
  53. resp.CurrentWorkingDirectory = jobResp.Jobs[0].CurrentWorkingDirectory
  54. return resp, nil
  55. }

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.