From d689fa5af7a967a6ee4e3ad3f17a2c6a2ac8b622 Mon Sep 17 00:00:00 2001 From: qiwang <1364512070@qq.com> Date: Sun, 23 Apr 2023 17:36:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BB=A3=E7=A0=81=E5=88=B02.0=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adaptor/PCM-CORE/api/desc/pcm.api | 11 ++++ .../PCM-CORE/api/desc/storage/pcm-storage.api | 52 +++++++++++++++++++ .../PCM-CORE/api/internal/handler/routes.go | 12 +++++ .../handler/storage/screenstoragehandler.go | 28 ++++++++++ .../logic/storage/screenstoragelogic.go | 30 +++++++++++ adaptor/PCM-CORE/api/internal/types/types.go | 40 ++++++++++++++ .../rpc/internal/logic/storagescreenlogic.go | 4 -- 7 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 adaptor/PCM-CORE/api/desc/storage/pcm-storage.api create mode 100644 adaptor/PCM-CORE/api/internal/handler/storage/screenstoragehandler.go create mode 100644 adaptor/PCM-CORE/api/internal/logic/storage/screenstoragelogic.go diff --git a/adaptor/PCM-CORE/api/desc/pcm.api b/adaptor/PCM-CORE/api/desc/pcm.api index ceab4392..5c1be894 100644 --- a/adaptor/PCM-CORE/api/desc/pcm.api +++ b/adaptor/PCM-CORE/api/desc/pcm.api @@ -4,6 +4,7 @@ import ( "core/pcm-core.api" "hpc/pcm-hpc.api" "ai/pcm-ai.api" + "storage/pcm-storage.api" ) info( @@ -149,4 +150,14 @@ service pcm { @handler createVisualizationJobHandler post /ai/CreateVisualizationJob (CreateVisualizationJobReq) returns (CreateVisualizationJobResp) /******************Visualization Job Method start*************************/ +} + +//screen接口 +@server( + prefix: pcm/v1 + group : storage +) +service pcm { + @handler screenStorageHandler + get /storage/screenStorage (StorageScreenReq) returns (StorageScreenResp) } \ No newline at end of file diff --git a/adaptor/PCM-CORE/api/desc/storage/pcm-storage.api b/adaptor/PCM-CORE/api/desc/storage/pcm-storage.api new file mode 100644 index 00000000..dfead49b --- /dev/null +++ b/adaptor/PCM-CORE/api/desc/storage/pcm-storage.api @@ -0,0 +1,52 @@ +syntax = "v1" + +info( + title: "AI core" + desc: "AI core微服务" + author: "wanqgi" + email: "1364512070@qq.com" +) + +/****************** screen storage start*************************/ +type( + StorageScreenReq { + + } + StorageScreenResp { + TotalSize uint32 `json:"totalSize" copier:"TotalSize"` + AiCenterInfos []AiCenterInfos `json:"aiCenterInfos" copier:"AiCenterInfos"` + StorageUsed uint32 `json:"storageUsed" copier:"StorageUsed"` + StorageUsing uint32 `json:"storageUsing" copier:"StorageUsing"` + UsageRate uint32 `json:"usageRate" copier:"UsageRate"` + UsingRate uint32 `json:"usingRate" copier:"UsingRate"` + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"ErrorMsg,omitempty"` + } + AiCenterInfos { + Id string `json:"id" copier:"Id"` + Name string `json:"name" copier:"Name"` + Desc string `json:"desc" copier:"Desc"` + Resource string `json:"resource" copier:"Resource"` + TrainJob string `json:"trainJob" copier:"TrainJob"` + ComputeScale int32 `json:"computeScale" copier:"ComputeScale"` + StorageScale int32 `json:"storageScale" copier:"StorageScale"` + Province string `json:"path:"province" copier:"Province"` + City string `json:"city" copier:"City"` + CoordinateX int32 `json:"coordinateX" copier:"CoordinateX"` + CoordinateY int32 `json:"coordinateY" copier:"CoordinateY"` + Type int32 `json:"type" copier:"Type"` + Weight int32 `json:"weight" copier:"Weight"` + ConnectionState int32 `json:"connectionState" copier:"ConnectionState"` + BusyState int32 `json:"busyState" copier:"BusyState"` + ImageUrl string `json:"imageUrl" copier:"ImageUrl"` + AccDevices string `json:"accDevices" copier:"AccDevices"` + MarketTime int64 `json:"marketTime" copier:"MarketTime"` + CreatedAt int64 `json:"createdAt" copier:"CreatedAt"` + AccessTime int32 `json:"accessTime" copier:"AccessTime"` + CardRunTime int32 `json:"cardRunTime" copier:"CardRunTime"` + JobCount int32 `json:"jobCount" copier:"JobCount"` +} +) + +/******************screen storage end*************************/ diff --git a/adaptor/PCM-CORE/api/internal/handler/routes.go b/adaptor/PCM-CORE/api/internal/handler/routes.go index c72d5b2b..0f26c1da 100644 --- a/adaptor/PCM-CORE/api/internal/handler/routes.go +++ b/adaptor/PCM-CORE/api/internal/handler/routes.go @@ -7,6 +7,7 @@ import ( ai "PCM/adaptor/PCM-CORE/api/internal/handler/ai" core "PCM/adaptor/PCM-CORE/api/internal/handler/core" hpc "PCM/adaptor/PCM-CORE/api/internal/handler/hpc" + storage "PCM/adaptor/PCM-CORE/api/internal/handler/storage" "PCM/adaptor/PCM-CORE/api/internal/svc" "github.com/zeromicro/go-zero/rest" @@ -220,4 +221,15 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { }, rest.WithPrefix("/pcm/v1"), ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodGet, + Path: "/storage/screenStorage", + Handler: storage.ScreenStorageHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) } diff --git a/adaptor/PCM-CORE/api/internal/handler/storage/screenstoragehandler.go b/adaptor/PCM-CORE/api/internal/handler/storage/screenstoragehandler.go new file mode 100644 index 00000000..34bc941f --- /dev/null +++ b/adaptor/PCM-CORE/api/internal/handler/storage/screenstoragehandler.go @@ -0,0 +1,28 @@ +package storage + +import ( + "net/http" + + "PCM/adaptor/PCM-CORE/api/internal/logic/storage" + "PCM/adaptor/PCM-CORE/api/internal/svc" + "PCM/adaptor/PCM-CORE/api/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func ScreenStorageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StorageScreenReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storage.NewScreenStorageLogic(r.Context(), svcCtx) + resp, err := l.ScreenStorage(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/adaptor/PCM-CORE/api/internal/logic/storage/screenstoragelogic.go b/adaptor/PCM-CORE/api/internal/logic/storage/screenstoragelogic.go new file mode 100644 index 00000000..637e6557 --- /dev/null +++ b/adaptor/PCM-CORE/api/internal/logic/storage/screenstoragelogic.go @@ -0,0 +1,30 @@ +package storage + +import ( + "context" + + "PCM/adaptor/PCM-CORE/api/internal/svc" + "PCM/adaptor/PCM-CORE/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScreenStorageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScreenStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScreenStorageLogic { + return &ScreenStorageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScreenStorageLogic) ScreenStorage(req *types.StorageScreenReq) (resp *types.StorageScreenResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/adaptor/PCM-CORE/api/internal/types/types.go b/adaptor/PCM-CORE/api/internal/types/types.go index 10baba99..c8b1e83b 100644 --- a/adaptor/PCM-CORE/api/internal/types/types.go +++ b/adaptor/PCM-CORE/api/internal/types/types.go @@ -1803,3 +1803,43 @@ type Nfs struct { LocalPath string `json:"localPath,optional"` ReadOnly bool `json:"readOnly,optional"` } + +type StorageScreenReq struct { +} + +type StorageScreenResp struct { + TotalSize uint32 `json:"totalSize" copier:"TotalSize"` + AiCenterInfos []AiCenterInfos `json:"aiCenterInfos" copier:"AiCenterInfos"` + StorageUsed uint32 `json:"storageUsed" copier:"StorageUsed"` + StorageUsing uint32 `json:"storageUsing" copier:"StorageUsing"` + UsageRate uint32 `json:"usageRate" copier:"UsageRate"` + UsingRate uint32 `json:"usingRate" copier:"UsingRate"` + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"ErrorMsg,omitempty"` +} + +type AiCenterInfos struct { + Id string `json:"id" copier:"Id"` + Name string `json:"name" copier:"Name"` + Desc string `json:"desc" copier:"Desc"` + Resource string `json:"resource" copier:"Resource"` + TrainJob string `json:"trainJob" copier:"TrainJob"` + ComputeScale int32 `json:"computeScale" copier:"ComputeScale"` + StorageScale int32 `json:"storageScale" copier:"StorageScale"` + Province string `json:"path:"province" copier:"Province"` + City string `json:"city" copier:"City"` + CoordinateX int32 `json:"coordinateX" copier:"CoordinateX"` + CoordinateY int32 `json:"coordinateY" copier:"CoordinateY"` + Type int32 `json:"type" copier:"Type"` + Weight int32 `json:"weight" copier:"Weight"` + ConnectionState int32 `json:"connectionState" copier:"ConnectionState"` + BusyState int32 `json:"busyState" copier:"BusyState"` + ImageUrl string `json:"imageUrl" copier:"ImageUrl"` + AccDevices string `json:"accDevices" copier:"AccDevices"` + MarketTime int64 `json:"marketTime" copier:"MarketTime"` + CreatedAt int64 `json:"createdAt" copier:"CreatedAt"` + AccessTime int32 `json:"accessTime" copier:"AccessTime"` + CardRunTime int32 `json:"cardRunTime" copier:"CardRunTime"` + JobCount int32 `json:"jobCount" copier:"JobCount"` +} diff --git a/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/storagescreenlogic.go b/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/storagescreenlogic.go index 2b146162..ea16f4d4 100644 --- a/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/storagescreenlogic.go +++ b/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/storagescreenlogic.go @@ -95,10 +95,6 @@ func (l *StorageScreenLogic) StorageScreen(in *ceph.StorageScreenReq) (*ceph.Sto UsingRate = (floatUsingStorageScale*1024 + 54.6) / (floatUsedStorageScale*1024 + floatUsingStorageScale*1024 + 54.6) StorageUsed = floatUsedStorageScale*1024 + 54.6 StorageUsing = floatUsingStorageScale*1024 + 54.6 - fmt.Println(StorageUsed) - fmt.Println(StorageUsing) - fmt.Println(UsageRate) - fmt.Println(UsingRate) resp.UsageRate = UsageRate resp.UsageRate = UsingRate resp.StorageUsing = StorageUsing