任务列表信息

Former-commit-id: 6800f9a6d57d810991aea43d102cace8a9768c82
This commit is contained in:
zhangwei 2023-06-20 16:48:07 +08:00
parent 4549ff388b
commit b7eeb14f7a
4 changed files with 124 additions and 38 deletions

View File

@ -206,6 +206,14 @@ type (
AllCardRunTime float64 `json:"allCardRunTime"`
AllJobCount float64 `json:"allJobCount"`
AllJobRunTime float64 `json:"allJobRunTime"`
TrainJobs []TrainJob `json:"trainJobs"`
}
TrainJob {
Name string `json:"name"`
Status string `json:"status"`
ServiceName string `json:"ServiceName"`
SynergyStatus string `json:"synergyStatus"`
Strategy int `json:"strategy"`
}
)
@ -281,7 +289,7 @@ type (
type (
listClusterReq {
CenterId int32 `path:"centerId"`
CenterId int32 `path:"centerId"`
}
listClusterResp {
Code int32 `json:"code"`
@ -310,8 +318,8 @@ type (
}
GiResp {
CpuNum int32 `json:"cpuNum,optional"`
MemoryInGib int32 `json:"memoryInGib,optional"`
CpuNum int32 `json:"cpuNum,optional"`
MemoryInGib int32 `json:"memoryInGib,optional"`
StorageInGib int32 `json:"storageInGib,optional"`
}
)
@ -322,28 +330,28 @@ type (
DomainResourceList []DomainResource `json:"domainResourceList"`
}
DomainResource {
Id int64 `json:"id"` // id
DomainId string `json:"domainId"` // 资源域id
DomainName string `json:"domainName"` // 资源域名称
JobCount int64 `json:"jobCount"` // 资源域任务数量
DomainSource int64 `json:"domainSource"` // 资源域数据来源0-nudt1-鹏城
Stack string `json:"stack"` // 技术栈
ResourceType string `json:"resourceType"` // 资源类型
Cpu float64 `json:"cpu"` // cpu使用率
Memory float64 `json:"memory"` // 内存使用率
Disk float64 `json:"disk"` // 存储使用率
NodeCount float64 `json:"nodeCount"` //节点使用率
// DeleteFlag int64 `json:"delete_flag"` // 是否删除 0:未删除1:已经删除
Description string `json:"description"` //集群描述
ClusterName string `json:"clusterName"` //集群名称
CpuTotal float64 `json:"cpuTotal"` //cpu总核数
MemoryTotal float64 `json:"memoryTotal"` //内存总量Gi
DiskTotal float64 `json:"diskTotal"` //存储总量GB
NodeTotal float64 `json:"nodeTotal"` //容器节点数
CpuUsage float64 `json:"cpuUsage"` //cpu已使用核数
MemoryUsage float64 `json:"memoryUsage"` //内存已使用Gi
DiskUsage float64 `json:"diskUsage"` //存储已使用GB
NodeUsage float64 `json:"nodeUsage"` //容器节点已使用
Id int64 `json:"id"` // id
DomainId string `json:"domainId"` // 资源域id
DomainName string `json:"domainName"` // 资源域名称
JobCount int64 `json:"jobCount"` // 资源域任务数量
DomainSource int64 `json:"domainSource"` // 资源域数据来源0-nudt1-鹏城
Stack string `json:"stack"` // 技术栈
ResourceType string `json:"resourceType"` // 资源类型
Cpu float64 `json:"cpu"` // cpu使用率
Memory float64 `json:"memory"` // 内存使用率
Disk float64 `json:"disk"` // 存储使用率
NodeCount float64 `json:"nodeCount"` //节点使用率
// DeleteFlag int64 `json:"delete_flag"` // 是否删除 0:未删除1:已经删除
Description string `json:"description"` //集群描述
ClusterName string `json:"clusterName"` //集群名称
CpuTotal float64 `json:"cpuTotal"` //cpu总核数
MemoryTotal float64 `json:"memoryTotal"` //内存总量Gi
DiskTotal float64 `json:"diskTotal"` //存储总量GB
NodeTotal float64 `json:"nodeTotal"` //容器节点数
CpuUsage float64 `json:"cpuUsage"` //cpu已使用核数
MemoryUsage float64 `json:"memoryUsage"` //内存已使用Gi
DiskUsage float64 `json:"diskUsage"` //存储已使用GB
NodeUsage float64 `json:"nodeUsage"` //容器节点已使用
}
)
@ -400,17 +408,17 @@ type ClusterMetrics struct {
}
type MetricResult struct {
MetricName string `json:"metric_name, omitempty"`
MetricName string `json:"metric_name, omitempty"`
MetricData MetricData `json:"data, omitempty"`
}
type MetricData struct {
Result []map[string]interface{} `json:"result"`
ResultType string `json:"resultType"`
Result []map[string]interface{} `json:"result"`
ResultType string `json:"resultType"`
}
type ResultData struct {
Status string `json:"status"`
Data MetricData `json:"data"`
Status string `json:"status"`
Data MetricData `json:"data"`
}
//jccSchedule容器集群资源监控 >end
//jccSchedule容器集群资源监控 >end

View File

@ -1,9 +1,12 @@
package core
import (
"PCM/adaptor/PCM-CORE/model"
"PCM/common/enum"
"PCM/common/tool"
"context"
"k8s.io/apimachinery/pkg/util/json"
"strings"
"PCM/adaptor/PCM-CORE/api/internal/svc"
"PCM/adaptor/PCM-CORE/api/internal/types"
@ -17,6 +20,21 @@ type JobTotalLogic struct {
svcCtx *svc.ServiceContext
}
type Job struct {
TotalSize int `json:"totalSize"`
OtJobs []OtJob `json:"otJobs"`
}
type OtJob struct {
Name string `json:"name"`
Status string `json:"status"`
Tasks []Task `json:"tasks"`
}
type Task struct {
CenterName []string `json:"centerName"`
}
func NewJobTotalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobTotalLogic {
return &JobTotalLogic{
Logger: logx.WithContext(ctx),
@ -26,12 +44,64 @@ func NewJobTotalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobTotal
}
func (l *JobTotalLogic) JobTotal() (resp *types.JobTotalResp, err error) {
// todo: add your logic here and delete this line
// 获取任务时间信息
resp = &types.JobTotalResp{}
bytes, err := tool.HttpGet("GET", "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/alljobinfo")
if err != nil {
return nil, err
}
json.Unmarshal(bytes, resp)
// 获取其他任务信息
jobs := &Job{}
jobBytes, err := tool.HttpGet("GET", "https://grampus.openi.org.cn/openapi/v1/sharescreen/trainjob?pageIndex=1&pageSize=10")
if err != nil {
return nil, err
}
json.Unmarshal(jobBytes, jobs)
for _, job := range jobs.OtJobs {
resp.TrainJobs = append(resp.TrainJobs, types.TrainJob{
Name: job.Name,
Status: job.Status,
ServiceName: job.Tasks[0].CenterName[0],
Strategy: 0,
SynergyStatus: "未协同",
})
}
var tasks []model.Task
tx := l.svcCtx.DbEngin.Find(&tasks)
if tx.Error != nil {
logx.Error(err)
return nil, tx.Error
}
if len(tasks) == 0 {
return nil, nil
}
for _, task := range tasks {
tx := l.svcCtx.DbEngin.Raw("SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.service_name) ,GROUP_CONCAT(DISTINCT a.service_name) ,GROUP_CONCAT(DISTINCT c.service_name))as service_name from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?", task.Id).Scan(&task.ServiceName)
if tx.Error != nil {
logx.Error(err)
return nil, tx.Error
}
// 承接方转义
if task.ServiceName != "" {
var names []string
servicesName := strings.Split(task.ServiceName, ",")
for _, name := range servicesName {
names = append(names, enum.Partner(name).String())
}
task.ServiceName = strings.Join(names, ",")
}
resp.TrainJobs = append(resp.TrainJobs, types.TrainJob{
ServiceName: task.ServiceName,
Name: task.Name,
Strategy: int(task.Strategy),
SynergyStatus: enum.SynergyStatus(task.SynergyStatus).String(),
Status: task.Status,
})
}
return resp, nil
}

View File

@ -60,8 +60,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
ModelArtsRpc: modelartsclient.NewModelArts(zrpc.MustNewClient(c.ModelArtsRpcConf)),
CephRpc: cephclient.NewCeph(zrpc.MustNewClient(c.CephRpcConf)),
ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)),
//THRpc: hpcthclient.NewHpcTH(zrpc.MustNewClient(c.THRpcConf)),
OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)),
DockerClient: dockerClient,
OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)),
DockerClient: dockerClient,
}
}

View File

@ -181,9 +181,18 @@ type TaskInfo struct {
}
type JobTotalResp struct {
AllCardRunTime float64 `json:"allCardRunTime"`
AllJobCount float64 `json:"allJobCount"`
AllJobRunTime float64 `json:"allJobRunTime"`
AllCardRunTime float64 `json:"allCardRunTime"`
AllJobCount float64 `json:"allJobCount"`
AllJobRunTime float64 `json:"allJobRunTime"`
TrainJobs []TrainJob `json:"trainJobs"`
}
type TrainJob struct {
Name string `json:"name"`
Status string `json:"status"`
ServiceName string `json:"ServiceName"`
SynergyStatus string `json:"synergyStatus"`
Strategy int `json:"strategy"`
}
type TaskListResp struct {