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.

canceljoblogic.go 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package hpc
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  7. "gitlink.org.cn/JointCloud/pcm-hpc/slurm"
  8. )
  9. type CancelJobLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewCancelJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CancelJobLogic {
  15. return &CancelJobLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *CancelJobLogic) CancelJob(req *types.CancelJobReq) error {
  22. // todo: add your logic here and delete this line
  23. var clusterInfo *types.ClusterInfo
  24. tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(&clusterInfo)
  25. if tx.Error != nil {
  26. return tx.Error
  27. }
  28. client, err := slurm.NewClient(slurm.ClientOptions{
  29. URL: clusterInfo.Server,
  30. ClientVersion: clusterInfo.Version,
  31. RestUserName: clusterInfo.Username,
  32. Token: clusterInfo.Token})
  33. if err != nil {
  34. return err
  35. }
  36. job, err := client.Job(slurm.JobOptions{})
  37. if err != nil {
  38. return err
  39. }
  40. err = job.CancelJob(slurm.CancelJobReq{JobId: req.JobId})
  41. if err != nil {
  42. return err
  43. }
  44. return nil
  45. }

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.