fix:Increase the number of clusters, adapters, and tasks
Former-commit-id: 65112cc063de3c9d14d74651acd0ef1d9f1c7d0d
This commit is contained in:
parent
07e5bcb5ba
commit
bf8969f1a6
|
@ -764,3 +764,13 @@ type ClusterResp {
|
|||
type ClusterListResp {
|
||||
List []ClusterInfo `json:"list,omitempty"`
|
||||
}
|
||||
|
||||
type clusterSumReq {
|
||||
|
||||
}
|
||||
|
||||
type clusterSumReqResp{
|
||||
ClusterSum int `json:"ClusterSum,omitempty"`
|
||||
AdapterSum int `json:"AdapterSum,omitempty"`
|
||||
TaskSum int `json:"TaskSum,omitempty"`
|
||||
}
|
|
@ -613,6 +613,9 @@ service pcm {
|
|||
|
||||
@handler GetAdapterClusterHandler
|
||||
get /adapter/relation (AdapterReq) returns (AdapterRelationResp)
|
||||
|
||||
@handler GetClusterSumHandler
|
||||
get /adapter/clusterSum (clusterSumReq) returns (clusterSumReqResp)
|
||||
}
|
||||
|
||||
@server(
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
)
|
||||
|
||||
func GetClusterSumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClusterSumReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewGetClusterSumLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetClusterSum(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -752,36 +752,10 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/adapter/relation",
|
||||
Handler: adapters.GetAdapterClusterHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/pcm/v1"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/schedule/ai/getResourceTypes",
|
||||
Handler: schedule.ScheduleGetAiResourceTypesHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/schedule/ai/getTaskTypes",
|
||||
Handler: schedule.ScheduleGetAiTaskTypesHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/schedule/ai/getDatasets",
|
||||
Handler: schedule.ScheduleGetDatasetsHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/schedule/ai/getStrategies",
|
||||
Handler: schedule.ScheduleGetStrategyHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/schedule/submit",
|
||||
Handler: schedule.ScheduleSubmitHandler(serverCtx),
|
||||
Path: "/adapter/clusterSum",
|
||||
Handler: adapters.GetClusterSumHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/pcm/v1"),
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetClusterSumLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetClusterSumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterSumLogic {
|
||||
return &GetClusterSumLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetClusterSumLogic) GetClusterSum(req *types.ClusterSumReq) (resp *types.ClusterSumReqResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
resp = &types.ClusterSumReqResp{}
|
||||
|
||||
var AdapterSum int //
|
||||
var ClusterSum int //
|
||||
var TaskSum int //
|
||||
//
|
||||
sqlStr := "SELECT COUNT(*) FROM `t_adapter` t where t.type = 0`"
|
||||
tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&AdapterSum)
|
||||
if tx.Error != nil {
|
||||
logx.Error(err)
|
||||
return nil, tx.Error
|
||||
}
|
||||
//
|
||||
sqlStrCluster := "SELECT COUNT(*) FROM `t_cluster`t where t.label ='openstack' || t.label='kubernetes'\n"
|
||||
txCluster := l.svcCtx.DbEngin.Raw(sqlStrCluster).Scan(&ClusterSum)
|
||||
if txCluster.Error != nil {
|
||||
logx.Error(err)
|
||||
return nil, txCluster.Error
|
||||
}
|
||||
//
|
||||
sqlStrTask := "SELECT COUNT(*) FROM `task`"
|
||||
txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&TaskSum)
|
||||
if txTask.Error != nil {
|
||||
logx.Error(err)
|
||||
return nil, txTask.Error
|
||||
}
|
||||
resp.TaskSum = TaskSum
|
||||
resp.ClusterSum = ClusterSum
|
||||
resp.AdapterSum = AdapterSum
|
||||
return resp, nil
|
||||
}
|
|
@ -731,6 +731,15 @@ type ClusterListResp struct {
|
|||
List []ClusterInfo `json:"list,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterSumReq struct {
|
||||
}
|
||||
|
||||
type ClusterSumReqResp struct {
|
||||
ClusterSum int `json:"ClusterSum,omitempty"`
|
||||
AdapterSum int `json:"AdapterSum,omitempty"`
|
||||
TaskSum int `json:"TaskSum,omitempty"`
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
SlurmVersion string `json:"slurmVersion"`
|
||||
Name string `json:"name"`
|
||||
|
|
Loading…
Reference in New Issue