| @@ -0,0 +1,179 @@ | |||
| syntax = "v1" | |||
| info( | |||
| title: "type title here" | |||
| desc: "type desc here" | |||
| author: "type author here" | |||
| email: "type email here" | |||
| version: "type version here" | |||
| ) | |||
| type Job { | |||
| SlurmVersion string `json:"slurmVersion"` | |||
| Account string `json:"account"` | |||
| AllocNode string `json:"allocNode"` | |||
| AllocSid uint32 `json:"allocSid"` | |||
| ArrayJobId uint32 `json:"arrayJobId"` | |||
| ArrayTaskId uint32 `json:"arrayTaskId"` | |||
| AssocId uint32 `json:"assocId"` | |||
| BatchFlag uint32 `json:"batchFlag"` | |||
| BatchHost string `json:"batchHost"` | |||
| BatchScript string `json:"batchScript"` | |||
| Command string `json:"command"` | |||
| Comment string `json:"comment"` | |||
| Contiguous uint32 `json:"contiguous"` | |||
| CpusPerTask uint32 `json:"cpusPerTask"` | |||
| Dependency string `json:"dependency"` | |||
| DerivedEc uint32 `json:"derivedEc"` | |||
| EligibleTime int64 `json:"eligibleTime"` | |||
| EndTime int64 `json:"endTime"` | |||
| ExcNodes string `json:"excNodes"` //NodeUsed in ac | |||
| ExcNodeInx int32 `json:"excNodeInx"` | |||
| ExitCode uint32 `json:"exitCode"` | |||
| Features string `json:"features"` | |||
| Gres string `json:"gres"` | |||
| GroupId uint32 `json:"groupId"` | |||
| JobId uint32 `json:"jobId"` //JobId in ac | |||
| JobState uint32 `json:"jobState"` //JobStatus in ac | |||
| Licenses string `json:"licenses"` | |||
| MaxCpus uint32 `json:"maxCpus"` | |||
| MaxNodes uint32 `json:"maxNodes"` | |||
| BoardsPerNode uint32 `json:"boardsPerNode"` | |||
| SocketsPerBoard uint32 `json:"socketsPerBoard"` | |||
| SocketsPerNode uint32 `json:"socketsPerNode"` | |||
| CoresPerSocket uint32 `json:"coresPerSocket"` | |||
| ThreadsPerCore uint32 `json:"threadsPerCore"` | |||
| Name string `json:"name"` //JobName in ac | |||
| Network string `json:"network"` | |||
| Nodes string `json:"nodes"` | |||
| Nice uint32 `json:"nice"` | |||
| NodeInx int32 `json:"nodeInx"` | |||
| NtasksPerCore uint32 `json:"ntasksPerCore"` | |||
| NtasksPerNode uint32 `json:"ntasksPerNode"` | |||
| NtasksPerSocket uint32 `json:"ntasksPerSocket"` | |||
| NtasksPerBoard uint32 `json:"ntasksPerBoard"` | |||
| NumNodes uint32 `json:"numNodes"` | |||
| NumCpus uint32 `json:"numCpus"` //ProcNumUsed in ac | |||
| Partition string `json:"partition"` //Queue in ac | |||
| PnMinMemory uint32 `json:"pnMinMemory"` | |||
| PnMinCpus uint32 `json:"pnMinCpus"` | |||
| PnMinTmpDisk uint32 `json:"pnMinTmpDisk"` | |||
| PreSusTime int64 `json:"preSusTime"` | |||
| Priority uint32 `json:"priority"` | |||
| Profile uint32 `json:"profile"` | |||
| Qos string `json:"qos"` | |||
| ReqNodes string `json:"reqNodes"` | |||
| ReqNodeInx int32 `json:"reqNodeInx"` | |||
| ReqSwitch uint32 `json:"reqSwitch"` | |||
| Requeue uint32 `json:"requeue"` | |||
| ResizeTime int64 `json:"resizeTime"` | |||
| RestartCnt uint32 `json:"restartCnt"` | |||
| ResvName string `json:"resvName"` | |||
| Shared uint32 `json:"shared"` | |||
| ShowFlags uint32 `json:"showFlags"` | |||
| StartTime int64 `json:"startTime"` //JobStartTime in ac | |||
| StateDesc string `json:"stateDesc"` | |||
| StateReason uint32 `json:"stateReason"` | |||
| SubmitTime int64 `json:"submitTime"` | |||
| SuspendTime int64 `json:"suspendTime"` | |||
| TimeLimit uint32 `json:"timeLimit"` | |||
| TimeMin uint32 `json:"timeMin"` | |||
| UserId uint32 `json:"userId"` //User in ac | |||
| PreemptTime int64 `json:"preemptTime"` | |||
| Wait4Switch uint32 `json:"wait4Switch"` | |||
| Wckey string `json:"wckey"` | |||
| WorkDir string `json:"workDir"` //WorkDir in ac | |||
| /****ac****/ | |||
| JobRunTime string `json:"jobRunTime"` | |||
| JobmanagerId string `json:"jobmanagerId"` | |||
| JobmanagerName string `json:"jobmanagerName"` | |||
| JobmanagerType string `json:"jobmanagerType"` | |||
| ErrorPath string `json:"errorPath"` | |||
| OutputPath string `json:"outputPath"` | |||
| Reason string `json:"reason"` | |||
| AppType string `json:"appType"` | |||
| /****ac****/ | |||
| } | |||
| type ( | |||
| listJobReq { | |||
| } | |||
| listJobResp { | |||
| Code int32 `json:"code"` | |||
| Msg string `json:"msg"` | |||
| RecordCount int32 `json:"recordCount"` | |||
| Jobs []Job `json:"jobs"` | |||
| } | |||
| ) | |||
| type HistoryJob { | |||
| SlurmVersion string `json:"slurmVersion"` | |||
| AllocCPU uint32 `json:"allocCPU"` | |||
| AllocNodes uint32 `json:"allocNodes"` //Nodect 分配的节点数 in ac | |||
| Account string `json:"account"` | |||
| AssocId uint32 `json:"assocId"` | |||
| BlockId string `json:"blockId"` | |||
| Cluster string `json:"cluster"` | |||
| DerivedEc uint32 `json:"derivedEc"` | |||
| DerivedEs string `json:"derivedEs"` | |||
| Elapsed uint32 `json:"elapsed"` | |||
| Eligible int64 `json:"eligible"` | |||
| End int64 `json:"end"` //JobEndTime 作业结束时间 in ac | |||
| ExitCode uint32 `json:"exitCode"` //JobExitStatus 作业退出码 in ac | |||
| Gid uint32 `json:"gid"` | |||
| JobId uint32 `json:"jobId"` //JobId in ac | |||
| JobName string `json:"jobName"` //JobName in ac | |||
| Lft uint32 `json:"lft"` | |||
| Partition string `json:"partition"` //Queue 队列名 in ac | |||
| Nodes string `json:"nodes"` //JobExecHost 作业执行节点 in ac | |||
| Priority uint32 `json:"priority"` | |||
| Qosid uint32 `json:"qosid"` | |||
| ReqCpus uint32 `json:"reqCpus"` | |||
| ReqMem uint32 `json:"reqMem"` | |||
| Requid uint32 `json:"requid"` | |||
| Resvid uint32 `json:"resvid"` | |||
| ShowFull uint32 `json:"showFull"` | |||
| Start int64 `json:"start"` //JobStartTime 作业启动时间 in ac | |||
| State uint32 `json:"state"` //JobState 作业状态 in ac | |||
| Submit int64 `json:"submit"` | |||
| Suspended uint32 `json:"suspended"` | |||
| SysCpuSec uint32 `json:"sysCpuSec"` | |||
| SysCpuUsec uint32 `json:"sysCpuUsec"` | |||
| Timelimit uint32 `json:"timelimit"` | |||
| TotCpuSec uint32 `json:"totCpuSec"` | |||
| TotCpuUsec uint32 `json:"totCpuUsec"` | |||
| TrackSteps uint32 `json:"trackSteps"` | |||
| Uid uint32 `json:"uid"` | |||
| User string `json:"user"` //UserName 用户名 in ac | |||
| UserCpuSec uint32 `json:"userCpuSec"` | |||
| UserCpuUsec uint32 `json:"userCpuUsec"` | |||
| Wckey string `json:"wckey"` | |||
| Wckeyid uint32 `json:"wckeyid"` | |||
| WorkDir string `json:"workDir"` //Workdir 工作空间 in ac | |||
| /****************parmas from ac********************/ | |||
| AcctTime string `json:"acctTime"` // 记账时间 | |||
| AppType string `json:"appType"` // 作业应用类型 | |||
| JobQueueTime string `json:"jobQueueTime"` //作业入队列时间 | |||
| JobWalltimeUsed string `json:"jobWalltimeUsed"` //作业实际使用的Walltime,单位为秒 | |||
| JobManagerId int `json:"jobmanagerId"` //区域id | |||
| /****************parmas from ac********************/ | |||
| } | |||
| type ( | |||
| listHistoryJobReq { | |||
| SlurmVersion string `json:"slurmVersion,optional"` | |||
| StartTime string `json:"startTime,optional"` | |||
| EndTime string `json:"endTime,optional"` | |||
| TimeType string `json:"timeType,optional"` | |||
| Start int32 `json:"start,optional"` | |||
| Limit int32 `json:"limit,optional"` | |||
| IsQueryByQueueTime int32 `json:"isQueryByQueueTime,optional"` | |||
| } | |||
| listHistoryJobResp { | |||
| Code int32 `json:"code"` | |||
| Msg string `json:"msg"` | |||
| RecordCount int32 `json:"recordCount"` | |||
| HistoryJobs []HistoryJob `json:"historyJobs"` | |||
| } | |||
| ) | |||
| @@ -0,0 +1,52 @@ | |||
| syntax = "v1" | |||
| import ( | |||
| "core/pcm-core.api" | |||
| "hpc/pcm-hpc.api" | |||
| ) | |||
| info( | |||
| title: "type title here" | |||
| desc: "type desc here" | |||
| author: "type author here" | |||
| email: "type email here" | |||
| version: "type version here" | |||
| ) | |||
| //core端接口 | |||
| @server( | |||
| prefix: pcm/v1 | |||
| group : core | |||
| ) | |||
| service pcm { | |||
| @handler scheduleTaskHandler | |||
| post /core/scheduleTask (scheduleTaskReq) returns (scheduleTaskResp) | |||
| @handler TaskListHandler | |||
| get /core/taskList () returns (taskListResp) | |||
| @handler listCenterHandler | |||
| get /core/listCenter () returns (listCenterResp) | |||
| @handler submitJobHandler | |||
| post /core/submitJob (submitJobReq) returns (submitJobResp) | |||
| @handler getRegionHandler | |||
| get /core/getRegion () returns (getRegionResp) | |||
| @handler listRegionHandler | |||
| get /core/listRegion () returns (listRegionResp) | |||
| } | |||
| //hpc二级接口 | |||
| @server( | |||
| prefix: pcm/v1 | |||
| group : hpc | |||
| ) | |||
| service pcm { | |||
| @handler listJobHandler | |||
| get /hpc/listJob (listJobReq) returns (listJobResp) | |||
| @handler listHistoryJobHandler | |||
| get /hpc/listHistoryJob (listHistoryJobReq) returns (listHistoryJobResp) | |||
| } | |||
| @@ -7,7 +7,7 @@ KqProducerConf: | |||
| Brokers: | |||
| - 10.101.15.174:31895 | |||
| HpcTopic: Schedule-Hpc-Topic | |||
| CloudTopic: Schedule-Cloud-Topic | |||
| CloudTopic: Schedule-Cloud-TopicCenterOverview | |||
| AiTopic: Schedule-Ai-Topic | |||
| DB: | |||
| @@ -27,7 +27,7 @@ HpcConsumerConf: | |||
| Brokers: | |||
| - 10.101.15.174:31895 | |||
| Group: Schedule-Hpc-group | |||
| Topic: Schedule-Hpc-Topic | |||
| Topic: Schedule-Hpc-TopicCenterOverview | |||
| Offset: first | |||
| Consumers: 1 | |||
| Processors: 1 | |||
| @@ -38,7 +38,7 @@ CloudConsumerConf: | |||
| Brokers: | |||
| - 10.101.15.174:31895 | |||
| Group: Schedule-Cloud-group | |||
| Topic: Schedule-Cloud-Topic | |||
| Topic: Schedule-Cloud-TopicCenterOverview | |||
| Offset: first | |||
| Consumers: 1 | |||
| Processors: 1 | |||
| @@ -52,7 +52,6 @@ K8sNativeConf: | |||
| User: root | |||
| Pass: I9wLvrRufj | |||
| #rpc | |||
| THRpcConf: | |||
| Etcd: | |||
| @@ -1,16 +1,16 @@ | |||
| package handler | |||
| package core | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/core" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func getRegionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| func GetRegionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| l := logic.NewGetRegionLogic(r.Context(), svcCtx) | |||
| l := core.NewGetRegionLogic(r.Context(), svcCtx) | |||
| resp, err := l.GetRegion() | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| @@ -1,16 +1,16 @@ | |||
| package handler | |||
| package core | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/core" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func listCenterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| func ListCenterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| l := logic.NewListCenterLogic(r.Context(), svcCtx) | |||
| l := core.NewListCenterLogic(r.Context(), svcCtx) | |||
| resp, err := l.ListCenter() | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| @@ -1,16 +1,16 @@ | |||
| package handler | |||
| package core | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/core" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func listRegionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| func ListRegionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| l := logic.NewListRegionLogic(r.Context(), svcCtx) | |||
| l := core.NewListRegionLogic(r.Context(), svcCtx) | |||
| resp, err := l.ListRegion() | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| @@ -1,26 +1,23 @@ | |||
| package handler | |||
| package core | |||
| import ( | |||
| "PCM/common/tool" | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/core" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func scheduleTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| func ScheduleTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| var req types.ScheduleTaskReq | |||
| if err := httpx.Parse(r, &req); err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| return | |||
| } | |||
| // 解析yaml文件 | |||
| _, fileHeader, err := r.FormFile("file") | |||
| err = tool.Yaml2struct(fileHeader, &req) | |||
| l := logic.NewScheduleTaskLogic(r.Context(), svcCtx) | |||
| l := core.NewScheduleTaskLogic(r.Context(), svcCtx) | |||
| resp, err := l.ScheduleTask(&req) | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| @@ -1,15 +1,15 @@ | |||
| package handler | |||
| package core | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/core" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func submitJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| func SubmitJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| var req types.SubmitJobReq | |||
| if err := httpx.Parse(r, &req); err != nil { | |||
| @@ -17,7 +17,7 @@ func submitJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return | |||
| } | |||
| l := logic.NewSubmitJobLogic(r.Context(), svcCtx) | |||
| l := core.NewSubmitJobLogic(r.Context(), svcCtx) | |||
| resp, err := l.SubmitJob(&req) | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| @@ -1,16 +1,16 @@ | |||
| package handler | |||
| package core | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/core" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func TaskListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| l := logic.NewTaskListLogic(r.Context(), svcCtx) | |||
| l := core.NewTaskListLogic(r.Context(), svcCtx) | |||
| resp, err := l.TaskList() | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| @@ -1,15 +1,15 @@ | |||
| package handler | |||
| package hpc | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/hpc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func listHistoryJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| func ListHistoryJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| var req types.ListHistoryJobReq | |||
| if err := httpx.Parse(r, &req); err != nil { | |||
| @@ -17,7 +17,7 @@ func listHistoryJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return | |||
| } | |||
| l := logic.NewListHistoryJobLogic(r.Context(), svcCtx) | |||
| l := hpc.NewListHistoryJobLogic(r.Context(), svcCtx) | |||
| resp, err := l.ListHistoryJob(&req) | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| @@ -1,15 +1,15 @@ | |||
| package handler | |||
| package hpc | |||
| import ( | |||
| "net/http" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic" | |||
| "PCM/adaptor/PCM-CORE/api/internal/logic/hpc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/types" | |||
| "github.com/zeromicro/go-zero/rest/httpx" | |||
| ) | |||
| func listJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| func ListJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return func(w http.ResponseWriter, r *http.Request) { | |||
| var req types.ListJobReq | |||
| if err := httpx.Parse(r, &req); err != nil { | |||
| @@ -17,7 +17,7 @@ func listJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| return | |||
| } | |||
| l := logic.NewListJobLogic(r.Context(), svcCtx) | |||
| l := hpc.NewListJobLogic(r.Context(), svcCtx) | |||
| resp, err := l.ListJob(&req) | |||
| if err != nil { | |||
| httpx.ErrorCtx(r.Context(), w, err) | |||
| @@ -4,6 +4,8 @@ package handler | |||
| import ( | |||
| "net/http" | |||
| core "PCM/adaptor/PCM-CORE/api/internal/handler/core" | |||
| hpc "PCM/adaptor/PCM-CORE/api/internal/handler/hpc" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "github.com/zeromicro/go-zero/rest" | |||
| @@ -14,44 +16,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | |||
| []rest.Route{ | |||
| { | |||
| Method: http.MethodPost, | |||
| Path: "/scheduleTask", | |||
| Handler: scheduleTaskHandler(serverCtx), | |||
| Path: "/core/scheduleTask", | |||
| Handler: core.ScheduleTaskHandler(serverCtx), | |||
| }, | |||
| { | |||
| Method: http.MethodGet, | |||
| Path: "/taskList", | |||
| Handler: TaskListHandler(serverCtx), | |||
| Path: "/core/taskList", | |||
| Handler: core.TaskListHandler(serverCtx), | |||
| }, | |||
| { | |||
| Method: http.MethodGet, | |||
| Path: "/listCenter", | |||
| Handler: listCenterHandler(serverCtx), | |||
| Path: "/core/listCenter", | |||
| Handler: core.ListCenterHandler(serverCtx), | |||
| }, | |||
| { | |||
| Method: http.MethodGet, | |||
| Path: "/listJob", | |||
| Handler: listJobHandler(serverCtx), | |||
| Method: http.MethodPost, | |||
| Path: "/core/submitJob", | |||
| Handler: core.SubmitJobHandler(serverCtx), | |||
| }, | |||
| { | |||
| Method: http.MethodGet, | |||
| Path: "/listHistoryJob", | |||
| Handler: listHistoryJobHandler(serverCtx), | |||
| Path: "/core/getRegion", | |||
| Handler: core.GetRegionHandler(serverCtx), | |||
| }, | |||
| { | |||
| Method: http.MethodPost, | |||
| Path: "/submitJob", | |||
| Handler: submitJobHandler(serverCtx), | |||
| Method: http.MethodGet, | |||
| Path: "/core/listRegion", | |||
| Handler: core.ListRegionHandler(serverCtx), | |||
| }, | |||
| }, | |||
| rest.WithPrefix("/pcm/v1"), | |||
| ) | |||
| server.AddRoutes( | |||
| []rest.Route{ | |||
| { | |||
| Method: http.MethodGet, | |||
| Path: "/getRegion", | |||
| Handler: getRegionHandler(serverCtx), | |||
| Path: "/hpc/listJob", | |||
| Handler: hpc.ListJobHandler(serverCtx), | |||
| }, | |||
| { | |||
| Method: http.MethodGet, | |||
| Path: "/listRegion", | |||
| Handler: listRegionHandler(serverCtx), | |||
| Path: "/hpc/listHistoryJob", | |||
| Handler: hpc.ListHistoryJobHandler(serverCtx), | |||
| }, | |||
| }, | |||
| rest.WithPrefix("/pcm/v1"), | |||
| ) | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| package logic | |||
| package core | |||
| import ( | |||
| "PCM/adaptor/PCM-CORE/model" | |||
| @@ -1,4 +1,4 @@ | |||
| package logic | |||
| package core | |||
| import ( | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| @@ -1,4 +1,4 @@ | |||
| package logic | |||
| package core | |||
| import ( | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| @@ -1,4 +1,4 @@ | |||
| package logic | |||
| package core | |||
| import ( | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" | |||
| @@ -1,4 +1,4 @@ | |||
| package logic | |||
| package core | |||
| import ( | |||
| "PCM/adaptor/PCM-CORE/model" | |||
| @@ -1,4 +1,4 @@ | |||
| package logic | |||
| package hpc | |||
| import ( | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" | |||
| @@ -1,169 +1,6 @@ | |||
| // Code generated by goctl. DO NOT EDIT. | |||
| package types | |||
| type Job struct { | |||
| SlurmVersion string `json:"slurmVersion"` | |||
| Account string `json:"account"` | |||
| AllocNode string `json:"allocNode"` | |||
| AllocSid uint32 `json:"allocSid"` | |||
| ArrayJobId uint32 `json:"arrayJobId"` | |||
| ArrayTaskId uint32 `json:"arrayTaskId"` | |||
| AssocId uint32 `json:"assocId"` | |||
| BatchFlag uint32 `json:"batchFlag"` | |||
| BatchHost string `json:"batchHost"` | |||
| BatchScript string `json:"batchScript"` | |||
| Command string `json:"command"` | |||
| Comment string `json:"comment"` | |||
| Contiguous uint32 `json:"contiguous"` | |||
| CpusPerTask uint32 `json:"cpusPerTask"` | |||
| Dependency string `json:"dependency"` | |||
| DerivedEc uint32 `json:"derivedEc"` | |||
| EligibleTime int64 `json:"eligibleTime"` | |||
| EndTime int64 `json:"endTime"` | |||
| ExcNodes string `json:"excNodes"` //NodeUsed in ac | |||
| ExcNodeInx int32 `json:"excNodeInx"` | |||
| ExitCode uint32 `json:"exitCode"` | |||
| Features string `json:"features"` | |||
| Gres string `json:"gres"` | |||
| GroupId uint32 `json:"groupId"` | |||
| JobId uint32 `json:"jobId"` //JobId in ac | |||
| JobState uint32 `json:"jobState"` //JobStatus in ac | |||
| Licenses string `json:"licenses"` | |||
| MaxCpus uint32 `json:"maxCpus"` | |||
| MaxNodes uint32 `json:"maxNodes"` | |||
| BoardsPerNode uint32 `json:"boardsPerNode"` | |||
| SocketsPerBoard uint32 `json:"socketsPerBoard"` | |||
| SocketsPerNode uint32 `json:"socketsPerNode"` | |||
| CoresPerSocket uint32 `json:"coresPerSocket"` | |||
| ThreadsPerCore uint32 `json:"threadsPerCore"` | |||
| Name string `json:"name"` //JobName in ac | |||
| Network string `json:"network"` | |||
| Nodes string `json:"nodes"` | |||
| Nice uint32 `json:"nice"` | |||
| NodeInx int32 `json:"nodeInx"` | |||
| NtasksPerCore uint32 `json:"ntasksPerCore"` | |||
| NtasksPerNode uint32 `json:"ntasksPerNode"` | |||
| NtasksPerSocket uint32 `json:"ntasksPerSocket"` | |||
| NtasksPerBoard uint32 `json:"ntasksPerBoard"` | |||
| NumNodes uint32 `json:"numNodes"` | |||
| NumCpus uint32 `json:"numCpus"` //ProcNumUsed in ac | |||
| Partition string `json:"partition"` //Queue in ac | |||
| PnMinMemory uint32 `json:"pnMinMemory"` | |||
| PnMinCpus uint32 `json:"pnMinCpus"` | |||
| PnMinTmpDisk uint32 `json:"pnMinTmpDisk"` | |||
| PreSusTime int64 `json:"preSusTime"` | |||
| Priority uint32 `json:"priority"` | |||
| Profile uint32 `json:"profile"` | |||
| Qos string `json:"qos"` | |||
| ReqNodes string `json:"reqNodes"` | |||
| ReqNodeInx int32 `json:"reqNodeInx"` | |||
| ReqSwitch uint32 `json:"reqSwitch"` | |||
| Requeue uint32 `json:"requeue"` | |||
| ResizeTime int64 `json:"resizeTime"` | |||
| RestartCnt uint32 `json:"restartCnt"` | |||
| ResvName string `json:"resvName"` | |||
| Shared uint32 `json:"shared"` | |||
| ShowFlags uint32 `json:"showFlags"` | |||
| StartTime int64 `json:"startTime"` //JobStartTime in ac | |||
| StateDesc string `json:"stateDesc"` | |||
| StateReason uint32 `json:"stateReason"` | |||
| SubmitTime int64 `json:"submitTime"` | |||
| SuspendTime int64 `json:"suspendTime"` | |||
| TimeLimit uint32 `json:"timeLimit"` | |||
| TimeMin uint32 `json:"timeMin"` | |||
| UserId uint32 `json:"userId"` //User in ac | |||
| PreemptTime int64 `json:"preemptTime"` | |||
| Wait4Switch uint32 `json:"wait4Switch"` | |||
| Wckey string `json:"wckey"` | |||
| WorkDir string `json:"workDir"` //WorkDir in ac | |||
| JobRunTime string `json:"jobRunTime"` | |||
| JobmanagerId string `json:"jobmanagerId"` | |||
| JobmanagerName string `json:"jobmanagerName"` | |||
| JobmanagerType string `json:"jobmanagerType"` | |||
| ErrorPath string `json:"errorPath"` | |||
| OutputPath string `json:"outputPath"` | |||
| Reason string `json:"reason"` | |||
| AppType string `json:"appType"` | |||
| } | |||
| type ListJobReq struct { | |||
| } | |||
| type ListJobResp struct { | |||
| Code int32 `json:"code"` | |||
| Msg string `json:"msg"` | |||
| RecordCount int32 `json:"recordCount"` | |||
| Jobs []Job `json:"jobs"` | |||
| } | |||
| type HistoryJob struct { | |||
| SlurmVersion string `json:"slurmVersion"` | |||
| AllocCPU uint32 `json:"allocCPU"` | |||
| AllocNodes uint32 `json:"allocNodes"` //Nodect 分配的节点数 in ac | |||
| Account string `json:"account"` | |||
| AssocId uint32 `json:"assocId"` | |||
| BlockId string `json:"blockId"` | |||
| Cluster string `json:"cluster"` | |||
| DerivedEc uint32 `json:"derivedEc"` | |||
| DerivedEs string `json:"derivedEs"` | |||
| Elapsed uint32 `json:"elapsed"` | |||
| Eligible int64 `json:"eligible"` | |||
| End int64 `json:"end"` //JobEndTime 作业结束时间 in ac | |||
| ExitCode uint32 `json:"exitCode"` //JobExitStatus 作业退出码 in ac | |||
| Gid uint32 `json:"gid"` | |||
| JobId uint32 `json:"jobId"` //JobId in ac | |||
| JobName string `json:"jobName"` //JobName in ac | |||
| Lft uint32 `json:"lft"` | |||
| Partition string `json:"partition"` //Queue 队列名 in ac | |||
| Nodes string `json:"nodes"` //JobExecHost 作业执行节点 in ac | |||
| Priority uint32 `json:"priority"` | |||
| Qosid uint32 `json:"qosid"` | |||
| ReqCpus uint32 `json:"reqCpus"` | |||
| ReqMem uint32 `json:"reqMem"` | |||
| Requid uint32 `json:"requid"` | |||
| Resvid uint32 `json:"resvid"` | |||
| ShowFull uint32 `json:"showFull"` | |||
| Start int64 `json:"start"` //JobStartTime 作业启动时间 in ac | |||
| State uint32 `json:"state"` //JobState 作业状态 in ac | |||
| Submit int64 `json:"submit"` | |||
| Suspended uint32 `json:"suspended"` | |||
| SysCpuSec uint32 `json:"sysCpuSec"` | |||
| SysCpuUsec uint32 `json:"sysCpuUsec"` | |||
| Timelimit uint32 `json:"timelimit"` | |||
| TotCpuSec uint32 `json:"totCpuSec"` | |||
| TotCpuUsec uint32 `json:"totCpuUsec"` | |||
| TrackSteps uint32 `json:"trackSteps"` | |||
| Uid uint32 `json:"uid"` | |||
| User string `json:"user"` //UserName 用户名 in ac | |||
| UserCpuSec uint32 `json:"userCpuSec"` | |||
| UserCpuUsec uint32 `json:"userCpuUsec"` | |||
| Wckey string `json:"wckey"` | |||
| Wckeyid uint32 `json:"wckeyid"` | |||
| WorkDir string `json:"workDir"` //Workdir 工作空间 in ac | |||
| AcctTime string `json:"acctTime"` // 记账时间 | |||
| AppType string `json:"appType"` // 作业应用类型 | |||
| JobQueueTime string `json:"jobQueueTime"` //作业入队列时间 | |||
| JobWalltimeUsed string `json:"jobWalltimeUsed"` //作业实际使用的Walltime,单位为秒 | |||
| JobManagerId int `json:"jobmanagerId"` //区域id | |||
| } | |||
| type ListHistoryJobReq struct { | |||
| SlurmVersion string `json:"slurmVersion,optional"` | |||
| StartTime string `json:"startTime,optional"` | |||
| EndTime string `json:"endTime,optional"` | |||
| TimeType string `json:"timeType,optional"` | |||
| Start int32 `json:"start,optional"` | |||
| Limit int32 `json:"limit,optional"` | |||
| IsQueryByQueueTime int32 `json:"isQueryByQueueTime,optional"` | |||
| } | |||
| type ListHistoryJobResp struct { | |||
| Code int32 `json:"code"` | |||
| Msg string `json:"msg"` | |||
| RecordCount int32 `json:"recordCount"` | |||
| HistoryJobs []HistoryJob `json:"historyJobs"` | |||
| } | |||
| type SubmitJobReq struct { | |||
| SlurmVersion string `json:"slurmVersion"` | |||
| Apptype string `json:"apptype,optional"` | |||
| @@ -403,3 +240,166 @@ type Center struct { | |||
| Edwc bool `json:"edwc"` | |||
| Ydyl bool `json:"ydyl"` | |||
| } | |||
| type Job struct { | |||
| SlurmVersion string `json:"slurmVersion"` | |||
| Account string `json:"account"` | |||
| AllocNode string `json:"allocNode"` | |||
| AllocSid uint32 `json:"allocSid"` | |||
| ArrayJobId uint32 `json:"arrayJobId"` | |||
| ArrayTaskId uint32 `json:"arrayTaskId"` | |||
| AssocId uint32 `json:"assocId"` | |||
| BatchFlag uint32 `json:"batchFlag"` | |||
| BatchHost string `json:"batchHost"` | |||
| BatchScript string `json:"batchScript"` | |||
| Command string `json:"command"` | |||
| Comment string `json:"comment"` | |||
| Contiguous uint32 `json:"contiguous"` | |||
| CpusPerTask uint32 `json:"cpusPerTask"` | |||
| Dependency string `json:"dependency"` | |||
| DerivedEc uint32 `json:"derivedEc"` | |||
| EligibleTime int64 `json:"eligibleTime"` | |||
| EndTime int64 `json:"endTime"` | |||
| ExcNodes string `json:"excNodes"` //NodeUsed in ac | |||
| ExcNodeInx int32 `json:"excNodeInx"` | |||
| ExitCode uint32 `json:"exitCode"` | |||
| Features string `json:"features"` | |||
| Gres string `json:"gres"` | |||
| GroupId uint32 `json:"groupId"` | |||
| JobId uint32 `json:"jobId"` //JobId in ac | |||
| JobState uint32 `json:"jobState"` //JobStatus in ac | |||
| Licenses string `json:"licenses"` | |||
| MaxCpus uint32 `json:"maxCpus"` | |||
| MaxNodes uint32 `json:"maxNodes"` | |||
| BoardsPerNode uint32 `json:"boardsPerNode"` | |||
| SocketsPerBoard uint32 `json:"socketsPerBoard"` | |||
| SocketsPerNode uint32 `json:"socketsPerNode"` | |||
| CoresPerSocket uint32 `json:"coresPerSocket"` | |||
| ThreadsPerCore uint32 `json:"threadsPerCore"` | |||
| Name string `json:"name"` //JobName in ac | |||
| Network string `json:"network"` | |||
| Nodes string `json:"nodes"` | |||
| Nice uint32 `json:"nice"` | |||
| NodeInx int32 `json:"nodeInx"` | |||
| NtasksPerCore uint32 `json:"ntasksPerCore"` | |||
| NtasksPerNode uint32 `json:"ntasksPerNode"` | |||
| NtasksPerSocket uint32 `json:"ntasksPerSocket"` | |||
| NtasksPerBoard uint32 `json:"ntasksPerBoard"` | |||
| NumNodes uint32 `json:"numNodes"` | |||
| NumCpus uint32 `json:"numCpus"` //ProcNumUsed in ac | |||
| Partition string `json:"partition"` //Queue in ac | |||
| PnMinMemory uint32 `json:"pnMinMemory"` | |||
| PnMinCpus uint32 `json:"pnMinCpus"` | |||
| PnMinTmpDisk uint32 `json:"pnMinTmpDisk"` | |||
| PreSusTime int64 `json:"preSusTime"` | |||
| Priority uint32 `json:"priority"` | |||
| Profile uint32 `json:"profile"` | |||
| Qos string `json:"qos"` | |||
| ReqNodes string `json:"reqNodes"` | |||
| ReqNodeInx int32 `json:"reqNodeInx"` | |||
| ReqSwitch uint32 `json:"reqSwitch"` | |||
| Requeue uint32 `json:"requeue"` | |||
| ResizeTime int64 `json:"resizeTime"` | |||
| RestartCnt uint32 `json:"restartCnt"` | |||
| ResvName string `json:"resvName"` | |||
| Shared uint32 `json:"shared"` | |||
| ShowFlags uint32 `json:"showFlags"` | |||
| StartTime int64 `json:"startTime"` //JobStartTime in ac | |||
| StateDesc string `json:"stateDesc"` | |||
| StateReason uint32 `json:"stateReason"` | |||
| SubmitTime int64 `json:"submitTime"` | |||
| SuspendTime int64 `json:"suspendTime"` | |||
| TimeLimit uint32 `json:"timeLimit"` | |||
| TimeMin uint32 `json:"timeMin"` | |||
| UserId uint32 `json:"userId"` //User in ac | |||
| PreemptTime int64 `json:"preemptTime"` | |||
| Wait4Switch uint32 `json:"wait4Switch"` | |||
| Wckey string `json:"wckey"` | |||
| WorkDir string `json:"workDir"` //WorkDir in ac | |||
| JobRunTime string `json:"jobRunTime"` | |||
| JobmanagerId string `json:"jobmanagerId"` | |||
| JobmanagerName string `json:"jobmanagerName"` | |||
| JobmanagerType string `json:"jobmanagerType"` | |||
| ErrorPath string `json:"errorPath"` | |||
| OutputPath string `json:"outputPath"` | |||
| Reason string `json:"reason"` | |||
| AppType string `json:"appType"` | |||
| } | |||
| type ListJobReq struct { | |||
| } | |||
| type ListJobResp struct { | |||
| Code int32 `json:"code"` | |||
| Msg string `json:"msg"` | |||
| RecordCount int32 `json:"recordCount"` | |||
| Jobs []Job `json:"jobs"` | |||
| } | |||
| type HistoryJob struct { | |||
| SlurmVersion string `json:"slurmVersion"` | |||
| AllocCPU uint32 `json:"allocCPU"` | |||
| AllocNodes uint32 `json:"allocNodes"` //Nodect 分配的节点数 in ac | |||
| Account string `json:"account"` | |||
| AssocId uint32 `json:"assocId"` | |||
| BlockId string `json:"blockId"` | |||
| Cluster string `json:"cluster"` | |||
| DerivedEc uint32 `json:"derivedEc"` | |||
| DerivedEs string `json:"derivedEs"` | |||
| Elapsed uint32 `json:"elapsed"` | |||
| Eligible int64 `json:"eligible"` | |||
| End int64 `json:"end"` //JobEndTime 作业结束时间 in ac | |||
| ExitCode uint32 `json:"exitCode"` //JobExitStatus 作业退出码 in ac | |||
| Gid uint32 `json:"gid"` | |||
| JobId uint32 `json:"jobId"` //JobId in ac | |||
| JobName string `json:"jobName"` //JobName in ac | |||
| Lft uint32 `json:"lft"` | |||
| Partition string `json:"partition"` //Queue 队列名 in ac | |||
| Nodes string `json:"nodes"` //JobExecHost 作业执行节点 in ac | |||
| Priority uint32 `json:"priority"` | |||
| Qosid uint32 `json:"qosid"` | |||
| ReqCpus uint32 `json:"reqCpus"` | |||
| ReqMem uint32 `json:"reqMem"` | |||
| Requid uint32 `json:"requid"` | |||
| Resvid uint32 `json:"resvid"` | |||
| ShowFull uint32 `json:"showFull"` | |||
| Start int64 `json:"start"` //JobStartTime 作业启动时间 in ac | |||
| State uint32 `json:"state"` //JobState 作业状态 in ac | |||
| Submit int64 `json:"submit"` | |||
| Suspended uint32 `json:"suspended"` | |||
| SysCpuSec uint32 `json:"sysCpuSec"` | |||
| SysCpuUsec uint32 `json:"sysCpuUsec"` | |||
| Timelimit uint32 `json:"timelimit"` | |||
| TotCpuSec uint32 `json:"totCpuSec"` | |||
| TotCpuUsec uint32 `json:"totCpuUsec"` | |||
| TrackSteps uint32 `json:"trackSteps"` | |||
| Uid uint32 `json:"uid"` | |||
| User string `json:"user"` //UserName 用户名 in ac | |||
| UserCpuSec uint32 `json:"userCpuSec"` | |||
| UserCpuUsec uint32 `json:"userCpuUsec"` | |||
| Wckey string `json:"wckey"` | |||
| Wckeyid uint32 `json:"wckeyid"` | |||
| WorkDir string `json:"workDir"` //Workdir 工作空间 in ac | |||
| AcctTime string `json:"acctTime"` // 记账时间 | |||
| AppType string `json:"appType"` // 作业应用类型 | |||
| JobQueueTime string `json:"jobQueueTime"` //作业入队列时间 | |||
| JobWalltimeUsed string `json:"jobWalltimeUsed"` //作业实际使用的Walltime,单位为秒 | |||
| JobManagerId int `json:"jobmanagerId"` //区域id | |||
| } | |||
| type ListHistoryJobReq struct { | |||
| SlurmVersion string `json:"slurmVersion,optional"` | |||
| StartTime string `json:"startTime,optional"` | |||
| EndTime string `json:"endTime,optional"` | |||
| TimeType string `json:"timeType,optional"` | |||
| Start int32 `json:"start,optional"` | |||
| Limit int32 `json:"limit,optional"` | |||
| IsQueryByQueueTime int32 `json:"isQueryByQueueTime,optional"` | |||
| } | |||
| type ListHistoryJobResp struct { | |||
| Code int32 `json:"code"` | |||
| Msg string `json:"msg"` | |||
| RecordCount int32 `json:"recordCount"` | |||
| HistoryJobs []HistoryJob `json:"historyJobs"` | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package main | |||
| import ( | |||
| "flag" | |||
| "fmt" | |||
| "PCM/adaptor/PCM-CORE/api/internal/config" | |||
| "PCM/adaptor/PCM-CORE/api/internal/handler" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "github.com/zeromicro/go-zero/core/conf" | |||
| "github.com/zeromicro/go-zero/rest" | |||
| ) | |||
| var configFile = flag.String("f", "adaptor/PCM-CORE/api/etc/pcm.yaml", "the config file") | |||
| func main() { | |||
| flag.Parse() | |||
| var c config.Config | |||
| conf.MustLoad(*configFile, &c) | |||
| server := rest.MustNewServer(c.RestConf) | |||
| defer server.Stop() | |||
| ctx := svc.NewServiceContext(c) | |||
| handler.RegisterHandlers(server, ctx) | |||
| fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) | |||
| server.Start() | |||
| } | |||
| @@ -1,172 +0,0 @@ | |||
| package main | |||
| import ( | |||
| kqMq "PCM/adaptor/PCM-CORE/api/internal/mqs/kq" | |||
| "PCM/adaptor/PCM-CORE/model" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" | |||
| "PCM/adaptor/PCM-K8S/PCM-K8S-NATIVE/rpc/kubenative" | |||
| "PCM/common/tool" | |||
| "context" | |||
| "flag" | |||
| "fmt" | |||
| "github.com/go-redis/redis/v8" | |||
| "github.com/zeromicro/go-queue/kq" | |||
| "github.com/zeromicro/go-zero/core/service" | |||
| "github.com/zeromicro/go-zero/core/stores/sqlx" | |||
| v1 "k8s.io/api/core/v1" | |||
| "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | |||
| "k8s.io/apimachinery/pkg/runtime" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "time" | |||
| "PCM/adaptor/PCM-CORE/api/internal/config" | |||
| "PCM/adaptor/PCM-CORE/api/internal/handler" | |||
| "PCM/adaptor/PCM-CORE/api/internal/svc" | |||
| "github.com/zeromicro/go-zero/core/conf" | |||
| "github.com/zeromicro/go-zero/rest" | |||
| ) | |||
| var configFile = flag.String("f", "adaptor/PCM-CORE/api/etc/pcmcore-api.yaml", "the config file") | |||
| func main() { | |||
| flag.Parse() | |||
| var c config.Config | |||
| conf.MustLoad(*configFile, &c) | |||
| serviceGroup := service.NewServiceGroup() | |||
| defer serviceGroup.Stop() | |||
| server := rest.MustNewServer(c.RestConf) | |||
| ctx := svc.NewServiceContext(c) | |||
| ctx.Cron.Start() | |||
| handler.RegisterHandlers(server, ctx) | |||
| serviceGroup.Add(server) | |||
| services := []service.Service{ | |||
| //Listening for changes in consumption flow status | |||
| kq.MustNewQueue(c.HpcConsumerConf, kqMq.NewScheduleHpcMq(context.Background(), ctx)), | |||
| kq.MustNewQueue(c.CloudConsumerConf, kqMq.NewScheduleCloudMq(context.Background(), ctx)), | |||
| //..... | |||
| } | |||
| for _, mq := range services { | |||
| serviceGroup.Add(mq) | |||
| } | |||
| // 初始化数据到缓存 | |||
| initRedisData(ctx.SqlConn, ctx.RedisClient) | |||
| // 初始化定时任务 | |||
| initTaskCron(ctx) | |||
| fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) | |||
| serviceGroup.Start() | |||
| } | |||
| func initRedisData(sql sqlx.SqlConn, redisClient *redis.Client) { | |||
| // 查询出字典数据列表 | |||
| var dictList []model.Dict | |||
| err := sql.QueryRows(&dictList, "select * from dict") | |||
| if err != nil { | |||
| return | |||
| } | |||
| for _, dict := range dictList { | |||
| redisClient.Set(context.Background(), dict.DictValue, dict.DictCode, 0) | |||
| } | |||
| } | |||
| func initTaskCron(svc *svc.ServiceContext) { | |||
| c := context.Background() | |||
| svc.Cron.AddFunc("*/5 * * * * ?", func() { | |||
| // 查询task_base数据 | |||
| var taskList []model.Task | |||
| tasksStatus := make(map[string]string) | |||
| rows, err := svc.Db.Query("select job_id,status from task where kind = ?", "hpc") | |||
| if err != nil { | |||
| return | |||
| } | |||
| for rows.Next() { | |||
| var task model.Task | |||
| rows.Scan(&task.JobId, &task.Status) | |||
| tasksStatus[task.JobId] = task.Status | |||
| taskList = append(taskList, task) | |||
| } | |||
| // 查询ac的作业列表 | |||
| acReq := hpcAC.ListJobReq{} | |||
| acResp, err := svc.ACRpc.ListJob(c, &acReq) | |||
| if err != nil { | |||
| return | |||
| } | |||
| // 更新作业信息 | |||
| for _, job := range acResp.Jobs { | |||
| if len(tasksStatus[job.JobId]) != 0 { | |||
| _, err := svc.SqlConn.Exec("update task set status = ?,start_time=?,running_time = ?,card_count = ? where job_id = ?", job.JobStatus, job.JobStartTime, tool.RunTimeToSeconds(job.JobRunTime), job.ProcNumUsed, job.JobId) | |||
| if err != nil { | |||
| return | |||
| } | |||
| } | |||
| } | |||
| // 查询th的作业列表 | |||
| //thReq := hpcTH.ListJobReq{} | |||
| //thResp, err := svc.THRpc.ListJob(c, &thReq) | |||
| //if err != nil { | |||
| // return | |||
| //} | |||
| //// 更新作业信息 | |||
| //for _, job := range thResp.Jobs { | |||
| // if len(tasksStatus[string(job.JobId)]) != 0 && tasksStatus[string(job.JobId)] != string(job.JobState) { | |||
| // _, err := svc.SqlConn.Exec("update task set status = ?,start_time=?,running_time = ?,card_count = ? where job_id = ?", string(job.JobState), job.StartTime, tool.GetTimeDurationString(string(job.StartTime), string(job.EndTime)), 1, job.JobId) | |||
| // if err != nil { | |||
| // return | |||
| // } | |||
| // } | |||
| //} | |||
| }) | |||
| svc.Cron.AddFunc("*/5 * * * * ?", func() { | |||
| // 查询task_base数据 | |||
| var cloudList []model.Cloud | |||
| cloudStatus := make(map[string]string) | |||
| rows, err := svc.Db.Query("select status,api_version,kind,namespace,name from cloud where deleted_flag = 0 and kind = ?", "Pod") | |||
| if err != nil { | |||
| return | |||
| } | |||
| for rows.Next() { | |||
| var cloud model.Cloud | |||
| rows.Scan(&cloud.Status, &cloud.ApiVersion, &cloud.Kind, &cloud.Namespace, &cloud.Name) | |||
| cloudStatus[cloud.Namespace+"_"+cloud.Name] = cloud.Status | |||
| cloudList = append(cloudList, cloud) | |||
| } | |||
| // 查询k8s的作业列表 | |||
| acReq := kubenative.ListReq{ | |||
| YamlString: "apiVersion: v1\nkind: Pod\n", | |||
| } | |||
| acResp, err := svc.KubeNativeRpc.List(c, &acReq) | |||
| if err == nil { | |||
| unstructuredList := unstructured.UnstructuredList{} | |||
| json.Unmarshal([]byte(acResp.Data), &unstructuredList) | |||
| pods := v1.PodList{} | |||
| err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredList.UnstructuredContent(), &pods) | |||
| if err != nil { | |||
| return | |||
| } | |||
| // 更新作业信息 | |||
| for _, pod := range pods.Items { | |||
| if len(cloudStatus[pod.Namespace+"_"+pod.Name]) != 0 { | |||
| var runningTime int | |||
| var startTime time.Time | |||
| if pod.Status.Phase == "Running" { | |||
| runningTime = int(time.Now().Sub(pod.Status.StartTime.Time).Seconds()) | |||
| startTime = pod.Status.StartTime.Time | |||
| } | |||
| _, err := svc.Db.Exec("update cloud set status = ?,start_time = ?,running_time =? where namespace = ? and name = ?", string(pod.Status.Phase), startTime, runningTime, pod.Namespace, pod.Name) | |||
| if err != nil { | |||
| return | |||
| } | |||
| } | |||
| } | |||
| } | |||
| }) | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| Name: hpcac.rpc | |||
| ListenOn: 127.0.0.1:2008 | |||
| Etcd: | |||
| Hosts: | |||
| - 10.101.15.170:31890 | |||
| Key: hpcac.rpc | |||
| User: root | |||
| Pass: I9wLvrRufj | |||
| ClusterUrl: "https://api01.hpccube.com:65106/hpc/openapi/v2/cluster" | |||
| TokenUrl: "https://api01.hpccube.com:65102/ac/openapi/v2/tokens" | |||
| StateUrl: "https://api01.hpccube.com:65102/ac/openapi/v2/tokens/state" | |||
| User: "zhijiang" | |||
| Password: "111111a" | |||
| OrgId: "313ae32df03bc116255e6808949fcf57" | |||
| Layout: "2006-01-02 15:04:05" | |||
| EndPoint: https://api01.hpccube.com:65106 | |||
| @@ -1,5 +1,5 @@ | |||
| Name: hpcac.rpc | |||
| ListenOn: 127.0.0.1:2001 | |||
| ListenOn: 127.0.0.1:2002 | |||
| Etcd: | |||
| Hosts: | |||
| - 10.101.15.170:31890 | |||
| @@ -0,0 +1,27 @@ | |||
| Name: hpccore.api | |||
| Port: 2003 | |||
| Etcd: | |||
| Hosts: | |||
| - 127.0.0.1:2379 | |||
| Key: hpccore.api | |||
| DataSourceName: | |||
| #rpc | |||
| ACRpcConf: | |||
| Etcd: | |||
| Hosts: | |||
| - 127.0.0.1:2379 | |||
| Key: hpcac.rpc | |||
| #rpc | |||
| ACRpcConf2: | |||
| Etcd: | |||
| Hosts: | |||
| - 127.0.0.1:2379 | |||
| Key: hpcac.rpc | |||
| #rpc | |||
| THRpcConf: | |||
| Etcd: | |||
| Hosts: | |||
| - 127.0.0.1:2379 | |||
| Key: hpcth.rpc | |||
| @@ -0,0 +1,40 @@ | |||
| Name: hpc-core-mq | |||
| Host: 0.0.0.0 | |||
| Port: 3001 | |||
| Mode: dev | |||
| Log: | |||
| ServiceName: hpc-mq | |||
| Level: error | |||
| Redis: | |||
| Host: localhost:6379 | |||
| Cache: | |||
| - Host: localhost:6379 | |||
| #kq | |||
| KqConf: | |||
| Name: ScheduleHpc | |||
| Brokers: | |||
| - localhost:9092 | |||
| Group: Schedule-Hpc-group | |||
| Topic: Schedule-Hpc-Topic | |||
| Offset: first | |||
| Consumers: 1 | |||
| Processors: 1 | |||
| #rpc | |||
| HpcAcConf: | |||
| Endpoints: | |||
| - 127.0.0.1:2001 | |||
| NonBlock: true | |||
| #rpc | |||
| HpcCoreConf: | |||
| Endpoints: | |||
| - 127.0.0.1:2003 | |||
| NonBlock: true | |||
| DB: | |||
| DataSource: root:uJpLd6u-J?HC1@(106.53.150.192:3306)/pcm | |||
| @@ -0,0 +1,31 @@ | |||
| Name: hpccore.rpc | |||
| ListenOn: 0.0.0.0:2003 | |||
| #Etcd: | |||
| # Hosts: | |||
| # - 127.0.0.1:2379 | |||
| # Key: hpccore.rpc | |||
| #rpc | |||
| ACRpcConf: | |||
| Endpoints: | |||
| - 127.0.0.1:2001 | |||
| Etcd: | |||
| Hosts: | |||
| - 127.0.0.1:2379 | |||
| Key: hpcac.rpc | |||
| Cache: | |||
| - Host: localhost:6379 | |||
| #rpc | |||
| THRpcConf: | |||
| Endpoints: | |||
| - 127.0.0.1:2002 | |||
| NonBlock: true | |||
| Etcd: | |||
| Hosts: | |||
| - 127.0.0.1:2379 | |||
| Key: hpcth.rpc | |||
| DB: | |||
| DataSource: root:uJpLd6u-J?HC1@(106.53.150.192:3306)/pcm | |||
| @@ -0,0 +1,2 @@ | |||
| Name: hpcth.rpc | |||
| ListenOn: 0.0.0.0:2002 | |||
| @@ -1,5 +1,5 @@ | |||
| Name: kubenative.rpc | |||
| ListenOn: 0.0.0.0:2200 | |||
| ListenOn: 127.0.0.1:2005 | |||
| Etcd: | |||
| Hosts: | |||
| - 10.101.15.170:31890 | |||