Merge remote-tracking branch 'upstream/master' into upstream
# Conflicts: # api/desc/pcm.api # api/internal/handler/routes.go Former-commit-id: 3af5fcc802746329e5e770f7fa995fcd77b1abfc
This commit is contained in:
commit
9a369dc329
|
@ -32,6 +32,23 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
HomeOverviewReq {
|
||||||
|
|
||||||
|
}
|
||||||
|
HomeOverviewResp {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Data HomeOverviewData `json:"data"`
|
||||||
|
}
|
||||||
|
HomeOverviewData{
|
||||||
|
AdaptSum int64 `json:"adaptSum"`
|
||||||
|
ClusterSum int64 `json:"clusterSum"`
|
||||||
|
StorageSum float32 `json:"storageSum"`
|
||||||
|
TaskSum int64 `json:"taskSum"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
type remoteResp {
|
type remoteResp {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|
|
@ -136,11 +136,15 @@ service pcm {
|
||||||
|
|
||||||
@doc "Statistical task status"
|
@doc "Statistical task status"
|
||||||
@handler countTaskStatus
|
@handler countTaskStatus
|
||||||
get /core/task/countTaskStatus () returns(TaskStatusResp)
|
get /core/task/countTaskStatus () returns (TaskStatusResp)
|
||||||
|
|
||||||
@doc "task details"
|
@doc "Home Page Overview"
|
||||||
@handler taskDetails
|
@handler homeOverviewHandler
|
||||||
get /core/task/details (CId) returns(TaskStatusResp)
|
get /core/homeOverview (HomeOverviewReq) returns (HomeOverviewResp)
|
||||||
|
|
||||||
|
@doc "task details"
|
||||||
|
@handler taskDetails
|
||||||
|
get /core/task/details (CId) returns(TaskStatusResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//hpc二级接口
|
//hpc二级接口
|
||||||
|
@ -214,7 +218,7 @@ service pcm {
|
||||||
|
|
||||||
@doc "Create cloud computing common tasks"
|
@doc "Create cloud computing common tasks"
|
||||||
@handler commitGeneralTask
|
@handler commitGeneralTask
|
||||||
post /cloud/task/create (GeneralTaskReq) returns ()
|
post /cloud/task/create (GeneralTaskReq) returns()
|
||||||
}
|
}
|
||||||
|
|
||||||
//智算二级接口
|
//智算二级接口
|
||||||
|
@ -982,7 +986,7 @@ service pcm {
|
||||||
|
|
||||||
@doc "alert rules"
|
@doc "alert rules"
|
||||||
@handler alertRulesHandler
|
@handler alertRulesHandler
|
||||||
get /monitoring/alert/rule (AlertRulesReq) returns (AlertRulesResp)
|
get /monitoring/alert/rule (AlertRulesReq)returns (AlertRulesResp)
|
||||||
|
|
||||||
@doc "cluster resource load"
|
@doc "cluster resource load"
|
||||||
@handler clustersLoadHandler
|
@handler clustersLoadHandler
|
||||||
|
@ -998,11 +1002,11 @@ service pcm {
|
||||||
|
|
||||||
@doc "Synchronize Cluster alert Information"
|
@doc "Synchronize Cluster alert Information"
|
||||||
@handler syncClusterAlertHandler
|
@handler syncClusterAlertHandler
|
||||||
post /monitoring/syncClusterAlert (SyncClusterAlertReq)
|
post /core/syncClusterAlert (SyncClusterAlertReq)
|
||||||
|
|
||||||
@handler taskNumHandler
|
@handler taskNumHandler
|
||||||
get /monitoring/task/num (taskNumReq) returns (taskNumResp)
|
get /monitoring/task/num (taskNumReq) returns (taskNumResp)
|
||||||
|
|
||||||
@handler adapterInfoHandler
|
@handler adapterInfoHandler
|
||||||
get /monitoring/adapter/info (adapterInfoReq) returns (adapterInfoResp)
|
get /monitoring/adapter/info (adapterInfoReq) returns (adapterInfoResp)
|
||||||
}
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func HomeOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.HomeOverviewReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := core.NewHomeOverviewLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.HomeOverview(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -165,6 +165,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/core/task/countTaskStatus",
|
Path: "/core/task/countTaskStatus",
|
||||||
Handler: core.CountTaskStatusHandler(serverCtx),
|
Handler: core.CountTaskStatusHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/homeOverview",
|
||||||
|
Handler: core.HomeOverviewHandler(serverCtx),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/core/task/details",
|
Path: "/core/task/details",
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type HomeOverviewLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewHomeOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HomeOverviewLogic {
|
||||||
|
return &HomeOverviewLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *HomeOverviewLogic) HomeOverview(req *types.HomeOverviewReq) (resp *types.HomeOverviewResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
resp = &types.HomeOverviewResp{}
|
||||||
|
var AdapterSum int //
|
||||||
|
var StorageSum float32 //
|
||||||
|
var ClusterSum int //
|
||||||
|
var TaskSum int //
|
||||||
|
//Task
|
||||||
|
sqlStrTask := "SELECT COUNT(*) FROM `task`"
|
||||||
|
txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&TaskSum)
|
||||||
|
if txTask.Error != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, txTask.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
//Storage
|
||||||
|
sqlStrStorage := "SELECT SUM(t.storage_space) as storageSum FROM `t_storage_device` t"
|
||||||
|
txStorage := l.svcCtx.DbEngin.Raw(sqlStrStorage).Scan(&StorageSum)
|
||||||
|
if txTask.Error != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, txStorage.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
//Cluster
|
||||||
|
sqlStrCluster := "SELECT COUNT(*) FROM `t_cluster`"
|
||||||
|
txCluster := l.svcCtx.DbEngin.Raw(sqlStrCluster).Scan(&ClusterSum)
|
||||||
|
if txTask.Error != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, txCluster.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
//Adapter
|
||||||
|
sqlStrAdapter := "SELECT COUNT(*) FROM `t_adapter`"
|
||||||
|
txAdapter := l.svcCtx.DbEngin.Raw(sqlStrAdapter).Scan(&AdapterSum)
|
||||||
|
if txTask.Error != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, txAdapter.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.Data.TaskSum = int64(TaskSum)
|
||||||
|
resp.Data.StorageSum = StorageSum
|
||||||
|
resp.Data.AdaptSum = int64(AdapterSum)
|
||||||
|
resp.Data.ClusterSum = int64(ClusterSum)
|
||||||
|
|
||||||
|
resp.Code = 200
|
||||||
|
resp.Message = "Success"
|
||||||
|
return resp, nil
|
||||||
|
}
|
|
@ -25,6 +25,22 @@ type CenterIndex struct {
|
||||||
CenterType string `json:"centerType"`
|
CenterType string `json:"centerType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HomeOverviewReq struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type HomeOverviewResp struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Data HomeOverviewData `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HomeOverviewData struct {
|
||||||
|
AdaptSum int64 `json:"adaptSum"`
|
||||||
|
ClusterSum int64 `json:"clusterSum"`
|
||||||
|
StorageSum float32 `json:"storageSum"`
|
||||||
|
TaskSum int64 `json:"taskSum"`
|
||||||
|
}
|
||||||
|
|
||||||
type RemoteResp struct {
|
type RemoteResp struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue