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.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package hpc
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "gitlink.org.cn/JointCloud/pcm-hpc/slurm"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type JobInfoLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewJobInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobInfoLogic {
  16. return &JobInfoLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *JobInfoLogic) JobInfo(req *types.JobInfoReq) (resp *types.JobInfoResp, err error) {
  23. resp = &types.JobInfoResp{}
  24. var clusterInfo *types.ClusterInfo
  25. tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(&clusterInfo)
  26. if tx.Error != nil {
  27. return nil, tx.Error
  28. }
  29. client, err := slurm.NewClient(slurm.ClientOptions{
  30. URL: clusterInfo.Server,
  31. ClientVersion: clusterInfo.Version,
  32. RestUserName: clusterInfo.Username,
  33. Token: clusterInfo.Token})
  34. if err != nil {
  35. return nil, err
  36. }
  37. job, err := client.Job(slurm.JobOptions{})
  38. if err != nil {
  39. return nil, err
  40. }
  41. jobResp, _ := job.GetJob(slurm.GetJobReq{JobId: req.JobId})
  42. if len(jobResp.Errors) != 0 {
  43. return nil, errors.Errorf(jobResp.Errors[0].Description)
  44. }
  45. resp.JobId = jobResp.Jobs[0].JobId
  46. resp.JobState = jobResp.Jobs[0].JobState
  47. resp.CurrentWorkingDirectory = jobResp.Jobs[0].CurrentWorkingDirectory
  48. return resp, nil
  49. }

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.