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.

gethpctaskloglogic.go 1.7 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package hpc
  2. import (
  3. "context"
  4. "fmt"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service"
  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 GetHpcTaskLogLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. hpcService *service.HpcService
  15. }
  16. // 超算任务日志
  17. func NewGetHpcTaskLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetHpcTaskLogLogic {
  18. cache := make(map[string]interface{}, 10)
  19. hpcService, err := service.NewHpcService(&svcCtx.Config, svcCtx.Scheduler.HpcStorages, cache)
  20. if err != nil {
  21. return nil
  22. }
  23. return &GetHpcTaskLogLogic{
  24. Logger: logx.WithContext(ctx),
  25. ctx: ctx,
  26. svcCtx: svcCtx,
  27. hpcService: hpcService,
  28. }
  29. }
  30. func (l *GetHpcTaskLogLogic) GetHpcTaskLog(req *types.HpcTaskLogReq) (resp interface{}, err error) {
  31. var hpcR TaskHPCResult
  32. tx := l.svcCtx.DbEngin.Raw(
  33. "SELECT t.id, hpc.job_id ,hpc.adapter_id FROM task t "+
  34. "INNER JOIN task_hpc hpc ON t.id = hpc.task_id "+
  35. "WHERE adapter_type_dict = 2 AND t.id = ?",
  36. req.TaskId,
  37. ).Scan(&hpcR).Error
  38. if tx != nil {
  39. return nil, fmt.Errorf("数据库查询失败: %v", tx.Error)
  40. }
  41. var adapterInfo types.AdapterInfo
  42. l.svcCtx.DbEngin.Raw("SELECT * FROM `t_adapter` where id = ?", hpcR.AdapterId).Scan(&adapterInfo)
  43. if adapterInfo.Id == "" {
  44. return nil, fmt.Errorf("adapter not found")
  45. }
  46. // 取消作业
  47. resp, err = l.hpcService.HpcExecutorAdapterMap[adapterInfo.Id].GetTaskLogs(l.ctx, hpcR.JobID)
  48. if err != nil {
  49. return nil, err
  50. }
  51. return resp, nil
  52. }

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.