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.

hpc_service.go 2.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package service
  2. import (
  3. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/config"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector"
  6. hpcservice "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/hpc"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  8. "strconv"
  9. "sync"
  10. )
  11. const (
  12. Slurm_Arm = "slurm_arm"
  13. )
  14. type HpcService struct {
  15. HpcExecutorAdapterMap map[string]map[string]collector.HPCCollector
  16. Storage *database.HpcStorage
  17. LocalCache map[string]interface{}
  18. Conf *config.Config
  19. TaskSyncLock sync.Mutex
  20. }
  21. func NewHpcService(conf *config.Config, storages *database.HpcStorage, localCache map[string]interface{}) (*HpcService, error) {
  22. var aiType = "2"
  23. adapterIds, err := storages.GetAdapterIdsByType(aiType)
  24. if err != nil {
  25. return nil, err
  26. }
  27. hpcService := &HpcService{
  28. HpcExecutorAdapterMap: make(map[string]map[string]collector.HPCCollector),
  29. Storage: storages,
  30. LocalCache: localCache,
  31. Conf: conf,
  32. }
  33. for _, id := range adapterIds {
  34. clusters, err := storages.GetClustersByAdapterId(id)
  35. if err != nil {
  36. return nil, err
  37. }
  38. if len(clusters.List) == 0 {
  39. continue
  40. }
  41. exeClusterMap := InitHpcClusterMap(conf, clusters.List)
  42. hpcService.HpcExecutorAdapterMap[id] = exeClusterMap
  43. }
  44. return hpcService, nil
  45. }
  46. func InitHpcClusterMap(conf *config.Config, clusters []types.ClusterInfo) map[string]collector.HPCCollector {
  47. executorMap := make(map[string]collector.HPCCollector)
  48. for _, c := range clusters {
  49. switch c.Name {
  50. case Slurm_Arm:
  51. id, _ := strconv.ParseInt(c.Id, 10, 64)
  52. slurm := hpcservice.NewHpc(c.Server, id, c.Nickname)
  53. executorMap[c.Id] = slurm
  54. }
  55. }
  56. return executorMap
  57. }
  58. func (as *HpcService) UpdateHpcClusterMaps(conf *config.Config, adapterId string, clusters []types.ClusterInfo) {
  59. for _, c := range clusters {
  60. _, ok := as.HpcExecutorAdapterMap[adapterId][c.Id]
  61. if !ok {
  62. switch c.Name {
  63. case Slurm_Arm:
  64. id, _ := strconv.ParseInt(c.Id, 10, 64)
  65. slurm := hpcservice.NewHpc(c.Server, id, c.Nickname)
  66. as.HpcExecutorAdapterMap[adapterId][c.Id] = slurm
  67. }
  68. } else {
  69. continue
  70. }
  71. }
  72. }

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.