数算列表接口
Former-commit-id: 1086a71a5fc77ce13f8c143218d7985985ef85f2
This commit is contained in:
parent
8dc3c3b51a
commit
13fad5ec21
|
@ -1,36 +1,57 @@
|
||||||
syntax = "v1"
|
syntax = "v1"
|
||||||
|
|
||||||
info(
|
info(
|
||||||
title: "cloud core"
|
title: "cloud core"
|
||||||
desc: "cloud core微服务"
|
desc: "cloud core微服务"
|
||||||
author: "zhangwei"
|
author: "zhangwei"
|
||||||
email: ""
|
email: ""
|
||||||
)
|
)
|
||||||
/******************find datasetList start*************************/
|
/******************find datasetList start*************************/
|
||||||
|
|
||||||
type ApplyReq{
|
type ApplyReq {
|
||||||
YamlString string `json:"yamlString" copier:"yamlString"`
|
YamlString string `json:"yamlString" copier:"yamlString"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteReq{
|
type DeleteReq {
|
||||||
YamlString string `json:"yamlString" copier:"yamlString"`
|
YamlString string `json:"yamlString" copier:"yamlString"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApplyResp{
|
type ApplyResp {
|
||||||
Code int32 `json:"code,omitempty"`
|
Code int32 `json:"code,omitempty"`
|
||||||
Msg string `json:"msg,omitempty"`
|
Msg string `json:"msg,omitempty"`
|
||||||
DataSet []DataSet `json:"dataSet,omitempty"`
|
DataSet []DataSet `json:"dataSet,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteResp{
|
type DeleteResp {
|
||||||
Code int32 `json:"code,omitempty"`
|
Code int32 `json:"code,omitempty"`
|
||||||
Msg string `json:"msg,omitempty"`
|
Msg string `json:"msg,omitempty"`
|
||||||
Data string `json:"data,omitempty"`
|
Data string `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataSet{
|
type DataSet {
|
||||||
ApiVersion int32 `json:"apiVersion,omitempty"`
|
ApiVersion int32 `json:"apiVersion,omitempty"`
|
||||||
Kind string `json:"kind,omitempty"`
|
Kind string `json:"kind,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
NameSpace string `json:"nameSpace,omitempty"`
|
NameSpace string `json:"nameSpace,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type cloudListResp {
|
||||||
|
Clouds []Cloud `json:"clouds"`
|
||||||
|
|
||||||
|
}
|
||||||
|
type Cloud{
|
||||||
|
Id int64 `json:"id"` // id
|
||||||
|
TaskId int64 `json:"taskId"` // 任务id
|
||||||
|
ParticipantId int64 `json:"participantId"` // 集群静态信息id
|
||||||
|
ApiVersion string `json:"apiVersion"`
|
||||||
|
Name string `json:"name"` // 名称
|
||||||
|
Namespace string `json:"namespace"` // 命名空间
|
||||||
|
Kind string `json:"kind"` // 种类
|
||||||
|
Status string `json:"status"` // 状态
|
||||||
|
StartTime string `json:"startTime"` // 开始时间
|
||||||
|
RunningTime int64 `json:"runningTime"` // 运行时长
|
||||||
|
CreatedBy int64 `json:"createdBy"` // 创建人
|
||||||
|
CreatedTime string `json:"createdTime"` // 创建时间
|
||||||
|
YamlString string `json:"yamlString"`
|
||||||
|
Result string `json:"result"`
|
||||||
}
|
}
|
|
@ -92,8 +92,8 @@ service pcm {
|
||||||
group : cloud
|
group : cloud
|
||||||
)
|
)
|
||||||
service pcm {
|
service pcm {
|
||||||
@handler applyYamlHandler
|
@handler cloudListHandler
|
||||||
get /cloud/ApplyYaml (ApplyReq) returns (ApplyResp)
|
get /task/list () returns (cloudListResp)
|
||||||
|
|
||||||
@handler deleteYamlHandler
|
@handler deleteYamlHandler
|
||||||
get /cloud/DeleteYaml (ApplyReq) returns (DeleteResp)
|
get /cloud/DeleteYaml (ApplyReq) returns (DeleteResp)
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package cloud
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/cloud"
|
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ApplyYamlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
var req types.ApplyReq
|
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
l := cloud.NewApplyYamlLogic(r.Context(), svcCtx)
|
|
||||||
resp, err := l.ApplyYaml(&req)
|
|
||||||
if err != nil {
|
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package cloud
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlink.org.cn/jcce-pcm/utils/result"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/cloud"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CloudListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
l := cloud.NewCloudListLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.CloudList()
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -123,8 +123,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
[]rest.Route{
|
[]rest.Route{
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/cloud/ApplyYaml",
|
Path: "/task/list",
|
||||||
Handler: cloud.ApplyYamlHandler(serverCtx),
|
Handler: cloud.CloudListHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package cloud
|
|
||||||
|
|
||||||
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 ApplyYamlLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewApplyYamlLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApplyYamlLogic {
|
|
||||||
return &ApplyYamlLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *ApplyYamlLogic) ApplyYaml(req *types.ApplyReq) (resp *types.ApplyResp, err error) {
|
|
||||||
// todo: add your logic here and delete this line
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package cloud
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/model"
|
||||||
|
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||||
|
|
||||||
|
"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 CloudListLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCloudListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CloudListLogic {
|
||||||
|
return &CloudListLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *CloudListLogic) CloudList() (resp *types.CloudListResp, err error) {
|
||||||
|
// 查询数据库中数算任务列表
|
||||||
|
var clouds []*model.Cloud
|
||||||
|
tx := l.svcCtx.DbEngin.Find(&clouds)
|
||||||
|
if tx.Error != nil {
|
||||||
|
return nil, tx.Error
|
||||||
|
}
|
||||||
|
result := types.CloudListResp{}
|
||||||
|
tool.Convert(clouds, &result.Clouds)
|
||||||
|
return &result, nil
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ func NewHpcScheduler(val string) *hpcScheduler {
|
||||||
|
|
||||||
func (h *hpcScheduler) getNewStructForDb(task *types.TaskInfo, participantId int64) (interface{}, error) {
|
func (h *hpcScheduler) getNewStructForDb(task *types.TaskInfo, participantId int64) (interface{}, error) {
|
||||||
hpc := model.Hpc{
|
hpc := model.Hpc{
|
||||||
|
Id: tool.GenSnowflakeID(),
|
||||||
TaskId: task.TaskId,
|
TaskId: task.TaskId,
|
||||||
Status: "Saved",
|
Status: "Saved",
|
||||||
ParticipantId: participantId,
|
ParticipantId: participantId,
|
||||||
|
|
|
@ -2592,3 +2592,24 @@ type DataSet struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
NameSpace string `json:"nameSpace,omitempty"`
|
NameSpace string `json:"nameSpace,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CloudListResp struct {
|
||||||
|
Clouds []Cloud `json:"clouds"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Cloud struct {
|
||||||
|
Id int64 `json:"id"` // id
|
||||||
|
TaskId int64 `json:"taskId"` // 任务id
|
||||||
|
ParticipantId int64 `json:"participantId"` // 集群静态信息id
|
||||||
|
ApiVersion string `json:"apiVersion"`
|
||||||
|
Name string `json:"name"` // 名称
|
||||||
|
Namespace string `json:"namespace"` // 命名空间
|
||||||
|
Kind string `json:"kind"` // 种类
|
||||||
|
Status string `json:"status"` // 状态
|
||||||
|
StartTime string `json:"startTime"` // 开始时间
|
||||||
|
RunningTime int64 `json:"runningTime"` // 运行时长
|
||||||
|
CreatedBy int64 `json:"createdBy"` // 创建人
|
||||||
|
CreatedTime string `json:"createdTime"` // 创建时间
|
||||||
|
YamlString string `json:"yamlString"`
|
||||||
|
Result string `json:"result"`
|
||||||
|
}
|
||||||
|
|
|
@ -45,8 +45,11 @@ func (l *SyncInfoLogic) SyncInfo(in *pcmCore.SyncInfoReq) (*pcmCore.SyncInfoResp
|
||||||
}
|
}
|
||||||
case "hpc":
|
case "hpc":
|
||||||
for _, hpcInfo := range in.HpcInfoList {
|
for _, hpcInfo := range in.HpcInfoList {
|
||||||
tx := db.Exec("update hpc set status = ?,derived_es = ?,assoc_id = ?,exit_code = ?,version = ?,alloc_cpu = ?,alloc_nodes = ?,cluster = ?,block_id = ?,start_time = ?,running_time = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?",
|
//tx := db.Exec("update hpc set status = ?,derived_es = ?,assoc_id = ?,exit_code = ?,version = ?,alloc_cpu = ?,alloc_nodes = ?,cluster = ?,block_id = ?,start_time = ?,running_time = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?",
|
||||||
hpcInfo.Status, hpcInfo.DerivedEs, hpcInfo.AssocId, hpcInfo.ExitCode, hpcInfo.Version, hpcInfo.AllocCpu, hpcInfo.AllocNodes, hpcInfo.Cluster, hpcInfo.BlockId, hpcInfo.StartTime, hpcInfo.RunningTime, hpcInfo.JobId, in.ParticipantId, hpcInfo.TaskId, hpcInfo.Name)
|
// hpcInfo.Status, hpcInfo.DerivedEs, hpcInfo.AssocId, hpcInfo.ExitCode, hpcInfo.Version, hpcInfo.AllocCpu, hpcInfo.AllocNodes, hpcInfo.Cluster, hpcInfo.BlockId, hpcInfo.StartTime, hpcInfo.RunningTime, hpcInfo.JobId, in.ParticipantId, hpcInfo.TaskId, hpcInfo.Name)
|
||||||
|
//print(tx.Error)
|
||||||
|
tx := db.Exec("update hpc set status = ?,start_time = ?,running_time = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?",
|
||||||
|
hpcInfo.Status, hpcInfo.StartTime, hpcInfo.RunningTime, hpcInfo.JobId, in.ParticipantId, hpcInfo.TaskId, hpcInfo.Name)
|
||||||
print(tx.Error)
|
print(tx.Error)
|
||||||
}
|
}
|
||||||
case "ai":
|
case "ai":
|
||||||
|
|
Loading…
Reference in New Issue