From fb957526e518cde762412ee83ef10538a1ebb322 Mon Sep 17 00:00:00 2001 From: tzwang Date: Thu, 9 May 2024 18:54:25 +0800 Subject: [PATCH 1/2] added getComputeCards api Former-commit-id: 78b5fa73e9106a813df8d05e57c1e5dfd0a219a4 --- api/desc/pcm.api | 3 +++ api/desc/schedule/pcm-schedule.api | 9 +++++++++ api/internal/logic/ai/getcentertasklistlogic.go | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api/desc/pcm.api b/api/desc/pcm.api index 8a3ac032..73c6577d 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -972,6 +972,9 @@ service pcm { @handler UploadAlgothmCodeHandler post /schedule/getDownloadAlgothmCode (UploadAlgorithmCodeReq) returns (UploadAlgorithmCodeResp) + + @handler GetComputeCardsByClusterHandler + get /schedule/getComputeCardsByCluster/:adapterId/:clusterId (GetComputeCardsByClusterReq) returns (GetComputeCardsByClusterResp) } @server( diff --git a/api/desc/schedule/pcm-schedule.api b/api/desc/schedule/pcm-schedule.api index 0611dc4d..776851db 100644 --- a/api/desc/schedule/pcm-schedule.api +++ b/api/desc/schedule/pcm-schedule.api @@ -129,4 +129,13 @@ type ( UploadAlgorithmCodeResp { } + + GetComputeCardsByClusterReq { + AdapterId string `path:"adapterId"` + ClusterId string `path:"clusterId"` + } + + GetComputeCardsByClusterResp { + Cards []string `json:"cards"` + } ) \ No newline at end of file diff --git a/api/internal/logic/ai/getcentertasklistlogic.go b/api/internal/logic/ai/getcentertasklistlogic.go index ff1d2883..edf3d1b4 100644 --- a/api/internal/logic/ai/getcentertasklistlogic.go +++ b/api/internal/logic/ai/getcentertasklistlogic.go @@ -77,7 +77,7 @@ func (l *GetCenterTaskListLogic) GetCenterTaskList() (resp *types.CenterTaskList select { case _ = <-ch: return resp, nil - case <-time.After(1 * time.Second): + case <-time.After(2 * time.Second): return resp, nil } From 6bc14cfabd0e0e547b299a5f77a34c328e038892 Mon Sep 17 00:00:00 2001 From: tzwang Date: Thu, 9 May 2024 19:11:44 +0800 Subject: [PATCH 2/2] updated protobuf Former-commit-id: 6e3382beb8290c1c9602ca197c3781ce8a80a296 --- api/internal/handler/routes.go | 5 ++++ .../schedule/downloadalgothmcodehandler.go | 28 +++++++++++++++++++ .../getcomputecardsbyclusterhandler.go | 28 +++++++++++++++++++ .../schedule/uploadalgothmcodehandler.go | 28 +++++++++++++++++++ api/internal/types/types.go | 9 ++++++ 5 files changed, 98 insertions(+) create mode 100644 api/internal/handler/schedule/downloadalgothmcodehandler.go create mode 100644 api/internal/handler/schedule/getcomputecardsbyclusterhandler.go create mode 100644 api/internal/handler/schedule/uploadalgothmcodehandler.go diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index c558141a..0a2e86a0 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -1215,6 +1215,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/schedule/getDownloadAlgothmCode", Handler: schedule.UploadAlgothmCodeHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/schedule/getComputeCardsByCluster/:adapterId/:clusterId", + Handler: schedule.GetComputeCardsByClusterHandler(serverCtx), + }, }, rest.WithPrefix("/pcm/v1"), ) diff --git a/api/internal/handler/schedule/downloadalgothmcodehandler.go b/api/internal/handler/schedule/downloadalgothmcodehandler.go new file mode 100644 index 00000000..14207bba --- /dev/null +++ b/api/internal/handler/schedule/downloadalgothmcodehandler.go @@ -0,0 +1,28 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" +) + +func DownloadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DownloadAlgorithmCodeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := schedule.NewDownloadAlgothmCodeLogic(r.Context(), svcCtx) + resp, err := l.DownloadAlgothmCode(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/schedule/getcomputecardsbyclusterhandler.go b/api/internal/handler/schedule/getcomputecardsbyclusterhandler.go new file mode 100644 index 00000000..2c4393e1 --- /dev/null +++ b/api/internal/handler/schedule/getcomputecardsbyclusterhandler.go @@ -0,0 +1,28 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" +) + +func GetComputeCardsByClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetComputeCardsByClusterReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := schedule.NewGetComputeCardsByClusterLogic(r.Context(), svcCtx) + resp, err := l.GetComputeCardsByCluster(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/schedule/uploadalgothmcodehandler.go b/api/internal/handler/schedule/uploadalgothmcodehandler.go new file mode 100644 index 00000000..bfbd05d1 --- /dev/null +++ b/api/internal/handler/schedule/uploadalgothmcodehandler.go @@ -0,0 +1,28 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" +) + +func UploadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UploadAlgorithmCodeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := schedule.NewUploadAlgothmCodeLogic(r.Context(), svcCtx) + resp, err := l.UploadAlgothmCode(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 887ef866..4520f873 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -5705,6 +5705,15 @@ type UploadAlgorithmCodeReq struct { type UploadAlgorithmCodeResp struct { } +type GetComputeCardsByClusterReq struct { + AdapterId string `path:"adapterId"` + ClusterId string `path:"clusterId"` +} + +type GetComputeCardsByClusterResp struct { + Cards []string `json:"cards"` +} + type CreateAlertRuleReq struct { CLusterId string `json:"clusterId"` ClusterName string `json:"clusterName"`