断点续传已完成

Former-commit-id: 3b1544fedc1f4cdb174c4536037bdd49dd088d79
This commit is contained in:
张威 2023-05-27 14:38:36 +08:00
parent 723a949326
commit 2bec780e03
13 changed files with 234 additions and 137 deletions

View File

@ -194,5 +194,5 @@ service pcm {
get /image/list () returns (imageListResp)
@handler checkHandler
get /image/check (checkReq) returns (checkResp)
get /image/check/:fileMd5 (checkReq) returns (checkResp)
}

View File

@ -122,7 +122,7 @@ type (
type (
checkReq {
fileMd5 string `json:"fileMd5"`
fileMd5 string `path:"fileMd5"`
}
checkResp {
exist bool `json:"exist"`

View File

@ -1,28 +0,0 @@
package image
import (
"net/http"
"PCM/adaptor/PCM-CORE/api/internal/logic/image"
"PCM/adaptor/PCM-CORE/api/internal/svc"
"PCM/adaptor/PCM-CORE/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func CheckHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CheckReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := image.NewCheckLogic(r.Context(), svcCtx)
resp, err := l.Check(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -32,7 +32,7 @@ func ChunkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
chunksPath := path.Join(linuxUploadTempPath, hash)
files, _ := ioutil.ReadDir(chunksPath)
// 排序
// 将文件根据索引序号排序
filesSort := make(map[string]string)
for _, f := range files {
nameArr := strings.Split(f.Name(), "-")

View File

@ -3,14 +3,12 @@ package image
import (
result2 "PCM/common/result"
"bufio"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"path"
"strconv"
"strings"
"syscall"
@ -26,53 +24,62 @@ var linuxUploadTempPath = path.Join(linuxUploadPath)
func UploadImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
file, _, err := r.FormFile("file")
file, fileHeader, err := r.FormFile("file")
index := r.PostFormValue("index")
hash := r.PostFormValue("hash")
// 获取uploads下所有的文件夹
nameList, err := ioutil.ReadDir(linuxUploadPath)
m := map[string]interface{}{
"code": 46900,
"msg": "文件已上传",
}
result, _ := json.MarshalIndent(m, "", " ")
// 循环判断hash是否在文件里如果有就返回上传已完成
for _, name := range nameList {
tmpName := strings.Split(name.Name(), "_")[0]
if tmpName == hash {
fmt.Fprintf(w, string(result))
return
}
}
// 合并路径
chunksPath := path.Join(linuxUploadTempPath, hash)
// 文件路径
filePath := path.Join(chunksPath + "/" + hash + "-" + index)
// 检查临时文件夹是否存在
isPathExists, err := PathExists(chunksPath)
if !isPathExists {
err = os.MkdirAll(chunksPath, os.ModePerm)
}
destFile, err := os.OpenFile(path.Join(chunksPath+"/"+hash+"-"+index), syscall.O_CREAT|syscall.O_WRONLY, 0777)
reader := bufio.NewReader(file)
writer := bufio.NewWriter(destFile)
buf := make([]byte, 1024*1024) // 1M buf
for {
n, err := reader.Read(buf)
if err == io.EOF {
writer.Flush()
break
} else if err != nil {
exists, err := PathExists(filePath)
if exists {
fileInfo, _ := os.Stat(filePath)
if fileInfo.Size() == fileHeader.Size {
return
} else {
writer.Write(buf[:n])
}
}
start := strconv.Itoa(int(fileInfo.Size()))
oldfile, _ := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY, os.ModePerm)
defer file.Close()
count, _ := strconv.ParseInt(start, 10, 64)
fmt.Println("已上传:", count)
// 设置读,写的偏移量
file.Seek(count, 0)
oldfile.Seek(count, 0)
data := make([]byte, 1024, 1024)
for {
total, err := file.Read(data)
if err == io.EOF {
fmt.Println("文件复制完毕")
break
}
oldfile.Write(data[:total])
defer file.Close()
defer destFile.Close()
if err != nil {
log.Fatal("%v", err)
}
} else {
destFile, _ := os.OpenFile(path.Join(chunksPath+"/"+hash+"-"+index), syscall.O_CREAT|syscall.O_WRONLY, 0777)
reader := bufio.NewReader(file)
writer := bufio.NewWriter(destFile)
buf := make([]byte, 1024*1024) // 1M buf
for {
n, err := reader.Read(buf)
if err == io.EOF {
writer.Flush()
break
} else if err != nil {
return
} else {
writer.Write(buf[:n])
}
}
defer file.Close()
defer destFile.Close()
}
fmt.Printf("第%s:%s块上传完成\n", index, destFile.Name())
result2.HttpResult(r, w, nil, err)
}

View File

@ -288,7 +288,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
},
{
Method: http.MethodGet,
Path: "/image/check",
Path: "/image/check/:fileMd5",
Handler: image.CheckHandler(serverCtx),
},
},

View File

@ -2,7 +2,10 @@ package image
import (
"context"
"io/ioutil"
"os"
"path"
"strings"
"PCM/adaptor/PCM-CORE/api/internal/svc"
"PCM/adaptor/PCM-CORE/api/internal/types"
@ -16,6 +19,10 @@ type CheckLogic struct {
svcCtx *svc.ServiceContext
}
var dir, _ = os.Getwd()
var windowsUploadPath = strings.ReplaceAll(path.Join(dir, "uploads"), "/", "\\")
var linuxUploadPath = path.Join(dir, "uploads")
func NewCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckLogic {
return &CheckLogic{
Logger: logx.WithContext(ctx),
@ -26,6 +33,14 @@ func NewCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckLogic
func (l *CheckLogic) Check(req *types.CheckReq) (resp *types.CheckResp, err error) {
// todo: add your logic here and delete this line
path.Join()
return
files, err := ioutil.ReadDir(windowsUploadPath)
if err != nil {
return nil, err
}
for _, file := range files {
if req.FileMd5 == file.Name() {
resp.Exist = true
}
}
return resp, nil
}

View File

@ -279,23 +279,23 @@ type DomainResource struct {
}
type ResourcePanelConfigReq struct {
Id int64 `json:"id,optional"` //id
Title string `json:"title,optional"` //标题
TitleColor string `json:"titleColor,optional"` //标题色
MainColor string `json:"mainColor,optional"` //主色调
MainColor2 string `json:"mainColor2,optional"` //次主色调
TextColor string `json:"textColor,optional"` //文字颜色
BackgroundColor string `json:"backgroundColor,optional"` //背景底色
Center string `json:"center,optional"` //中心点
CenterPosition string `json:"centerPosition,optional"` //comment 中心点坐标
ProvinceBgColor string `json:"provinceBgColor,optional"` //三级地图底色
StatusIng string `json:"statusIng,optional"` //接入中图标
StatusUn string `json:"statusUn,optional"` //未接入图标
StatusEnd string `json:"statusEnd,optional"` //已接入图标
TitleIcon string `json:"titleIcon,optional"` //标题底图
SubTitleIcon string `json:"subTitleIcon,optional"` //小标题底图
NumberBg string `json:"numberBg,optional"` //数字底图
TaskBg string `json:"taskBg,optional"` //任务底图
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
TitleColor string `json:"titleColor"` //标题色
MainColor string `json:"mainColor"` //主色调
MainColor2 string `json:"mainColor2"` //次主色调
TextColor string `json:"textColor"` //文字颜色
BackgroundColor string `json:"backgroundColor"` //背景底色
Center string `json:"center"` //中心点
CenterPosition string `json:"centerPosition"` //comment 中心点坐标
ProvinceBgColor string `json:"provinceBgColor"` //三级地图底色
StatusIng string `json:"statusIng"` //接入中图标
StatusUn string `json:"statusUn"` //未接入图标
StatusEnd string `json:"statusEnd"` //已接入图标
TitleIcon string `json:"titleIcon"` //标题底图
SubTitleIcon string `json:"subTitleIcon"` //小标题底图
NumberBg string `json:"numberBg"` //数字底图
TaskBg string `json:"taskBg"` //任务底图
}
type ResourcePanelConfigResp struct {
@ -1904,7 +1904,7 @@ type ImageTagsResp struct {
}
type CheckReq struct {
FileMd5 string `json:"fileMd5"`
FileMd5 string `path:"fileMd5"`
}
type CheckResp struct {

View File

@ -55,6 +55,15 @@ type (
Result string `db:"result"`
YamlString string `db:"yaml_string"`
CmdScript string `db:"cmd_script"`
derivedEs string `db:"derived_es"`
cluster string `db:"cluster"`
blockId string `db:"block_id"`
allocNodes uint32 `db:"alloc_nodes"`
allocCpu uint32 `db:"alloc_cpu"`
version string `db:"version"`
account string `db:"account"`
exitCode string `db:"exit_code"`
assocId uint32 `db:"assoc_id"`
}
)

View File

@ -54,6 +54,15 @@ message HpcInfo {
string workDir = 9;
string wallTime = 10;
string cmdScript = 11;
string derivedEs = 12;
string cluster =13;
string blockId = 14;
string allocNodes = 15;
string allocCpu =16;
string version = 17;
string account =18;
string exitCode =19;
string assocId = 20;
}
message SyncInfoResp{

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.30.0
// protoc v3.19.4
// protoc-gen-go v1.28.1
// protoc v3.21.10
// source: pcmCore.proto
package pcmCore
@ -385,6 +385,15 @@ type HpcInfo struct {
WorkDir string `protobuf:"bytes,9,opt,name=workDir,proto3" json:"workDir,omitempty"`
WallTime string `protobuf:"bytes,10,opt,name=wallTime,proto3" json:"wallTime,omitempty"`
CmdScript string `protobuf:"bytes,11,opt,name=cmdScript,proto3" json:"cmdScript,omitempty"`
DerivedEs string `protobuf:"bytes,12,opt,name=derivedEs,proto3" json:"derivedEs,omitempty"`
Cluster string `protobuf:"bytes,13,opt,name=cluster,proto3" json:"cluster,omitempty"`
BlockId string `protobuf:"bytes,14,opt,name=blockId,proto3" json:"blockId,omitempty"`
AllocNodes string `protobuf:"bytes,15,opt,name=allocNodes,proto3" json:"allocNodes,omitempty"`
AllocCpu string `protobuf:"bytes,16,opt,name=allocCpu,proto3" json:"allocCpu,omitempty"`
Version string `protobuf:"bytes,17,opt,name=version,proto3" json:"version,omitempty"`
Account string `protobuf:"bytes,18,opt,name=account,proto3" json:"account,omitempty"`
ExitCode string `protobuf:"bytes,19,opt,name=exitCode,proto3" json:"exitCode,omitempty"`
AssocId string `protobuf:"bytes,20,opt,name=assocId,proto3" json:"assocId,omitempty"`
}
func (x *HpcInfo) Reset() {
@ -496,6 +505,69 @@ func (x *HpcInfo) GetCmdScript() string {
return ""
}
func (x *HpcInfo) GetDerivedEs() string {
if x != nil {
return x.DerivedEs
}
return ""
}
func (x *HpcInfo) GetCluster() string {
if x != nil {
return x.Cluster
}
return ""
}
func (x *HpcInfo) GetBlockId() string {
if x != nil {
return x.BlockId
}
return ""
}
func (x *HpcInfo) GetAllocNodes() string {
if x != nil {
return x.AllocNodes
}
return ""
}
func (x *HpcInfo) GetAllocCpu() string {
if x != nil {
return x.AllocCpu
}
return ""
}
func (x *HpcInfo) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
func (x *HpcInfo) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
func (x *HpcInfo) GetExitCode() string {
if x != nil {
return x.ExitCode
}
return ""
}
func (x *HpcInfo) GetAssocId() string {
if x != nil {
return x.AssocId
}
return ""
}
type SyncInfoResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -730,7 +802,7 @@ var file_pcmCore_proto_rawDesc = []byte{
0x67, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18,
0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1e, 0x0a,
0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x0b, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xb1, 0x02,
0x09, 0x52, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xa9, 0x04,
0x0a, 0x07, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74,
@ -750,34 +822,50 @@ var file_pcmCore_proto_rawDesc = []byte{
0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x77, 0x61, 0x6c, 0x6c, 0x54,
0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6d, 0x64, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74,
0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6d, 0x64, 0x53, 0x63, 0x72, 0x69, 0x70,
0x74, 0x22, 0x34, 0x0a, 0x0c, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73,
0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x43, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x4c,
0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a,
0x0c, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x32, 0x0a,
0x0b, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x48, 0x70, 0x63,
0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73,
0x74, 0x12, 0x38, 0x0a, 0x0d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69,
0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f,
0x72, 0x65, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0d, 0x43, 0x6c,
0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x0a, 0x41,
0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x0f, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f,
0x52, 0x0a, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x32, 0x7b, 0x0a, 0x07,
0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x49,
0x6e, 0x66, 0x6f, 0x12, 0x14, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x79,
0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43,
0x6f, 0x72, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70,
0x12, 0x37, 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x2e, 0x70,
0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52,
0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66,
0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, 0x0a, 0x5a, 0x08, 0x2f, 0x70, 0x63,
0x6d, 0x43, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x45, 0x73, 0x18, 0x0c,
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x64, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x45, 0x73, 0x12,
0x18, 0x0a, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0x49, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63,
0x6b, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x4e, 0x6f, 0x64, 0x65,
0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x4e, 0x6f,
0x64, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x43, 0x70, 0x75, 0x18,
0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x43, 0x70, 0x75, 0x12,
0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f,
0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x69, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18,
0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x78, 0x69, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x18, 0x0a, 0x07, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x49, 0x64, 0x22, 0x34, 0x0a, 0x0c, 0x53, 0x79, 0x6e,
0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a,
0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22,
0x43, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x12,
0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69,
0x6e, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x4e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x0c, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73,
0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x32, 0x0a, 0x0b, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f,
0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x63, 0x6d,
0x43, 0x6f, 0x72, 0x65, 0x2e, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x48, 0x70,
0x63, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x0d, 0x43, 0x6c, 0x6f,
0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x12, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64,
0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x4c,
0x69, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x0a, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73,
0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72,
0x65, 0x2e, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f,
0x4c, 0x69, 0x73, 0x74, 0x32, 0x7b, 0x0a, 0x07, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12,
0x37, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x2e, 0x70, 0x63,
0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63,
0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6f,
0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49,
0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, 0x6d,
0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73,
0x70, 0x42, 0x0a, 0x5a, 0x08, 0x2f, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.19.4
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.21.10
// source: pcmCore.proto
package pcmCore
@ -18,18 +18,13 @@ import (
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
PcmCore_SyncInfo_FullMethodName = "/pcmCore.pcmCore/SyncInfo"
PcmCore_InfoList_FullMethodName = "/pcmCore.pcmCore/InfoList"
)
// PcmCoreClient is the client API for PcmCore service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type PcmCoreClient interface {
//SyncInfo Synchronous data information
// SyncInfo Synchronous data information
SyncInfo(ctx context.Context, in *SyncInfoReq, opts ...grpc.CallOption) (*SyncInfoResp, error)
//InfoList
// InfoList
InfoList(ctx context.Context, in *InfoListReq, opts ...grpc.CallOption) (*InfoListResp, error)
}
@ -43,7 +38,7 @@ func NewPcmCoreClient(cc grpc.ClientConnInterface) PcmCoreClient {
func (c *pcmCoreClient) SyncInfo(ctx context.Context, in *SyncInfoReq, opts ...grpc.CallOption) (*SyncInfoResp, error) {
out := new(SyncInfoResp)
err := c.cc.Invoke(ctx, PcmCore_SyncInfo_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/pcmCore.pcmCore/SyncInfo", in, out, opts...)
if err != nil {
return nil, err
}
@ -52,7 +47,7 @@ func (c *pcmCoreClient) SyncInfo(ctx context.Context, in *SyncInfoReq, opts ...g
func (c *pcmCoreClient) InfoList(ctx context.Context, in *InfoListReq, opts ...grpc.CallOption) (*InfoListResp, error) {
out := new(InfoListResp)
err := c.cc.Invoke(ctx, PcmCore_InfoList_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/pcmCore.pcmCore/InfoList", in, out, opts...)
if err != nil {
return nil, err
}
@ -63,9 +58,9 @@ func (c *pcmCoreClient) InfoList(ctx context.Context, in *InfoListReq, opts ...g
// All implementations must embed UnimplementedPcmCoreServer
// for forward compatibility
type PcmCoreServer interface {
//SyncInfo Synchronous data information
// SyncInfo Synchronous data information
SyncInfo(context.Context, *SyncInfoReq) (*SyncInfoResp, error)
//InfoList
// InfoList
InfoList(context.Context, *InfoListReq) (*InfoListResp, error)
mustEmbedUnimplementedPcmCoreServer()
}
@ -103,7 +98,7 @@ func _PcmCore_SyncInfo_Handler(srv interface{}, ctx context.Context, dec func(in
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PcmCore_SyncInfo_FullMethodName,
FullMethod: "/pcmCore.pcmCore/SyncInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PcmCoreServer).SyncInfo(ctx, req.(*SyncInfoReq))
@ -121,7 +116,7 @@ func _PcmCore_InfoList_Handler(srv interface{}, ctx context.Context, dec func(in
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PcmCore_InfoList_FullMethodName,
FullMethod: "/pcmCore.pcmCore/InfoList",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PcmCoreServer).InfoList(ctx, req.(*InfoListReq))

View File

@ -5,6 +5,7 @@ import (
"PCM/adaptor/PCM-HPC/PCM-TH/rpc/hpcTH"
"PCM/adaptor/PCM-HPC/PCM-TH/rpc/internal/svc"
"PCM/common/enum"
"PCM/common/tool"
"context"
"github.com/zeromicro/go-zero/core/logx"
"strconv"
@ -38,6 +39,7 @@ func InitCron(svc *svc.ServiceContext) {
for index, _ := range infoList.HpcInfoList {
for _, job := range listJob.Jobs {
if job.Name == infoList.HpcInfoList[index].Name {
tool.Convert(job, infoList.HpcInfoList[index])
infoList.HpcInfoList[index].JobId = strconv.Itoa(int(job.JobId))
infoList.HpcInfoList[index].StartTime = time.Unix(job.StartTime, 0).String()
infoList.HpcInfoList[index].RunningTime = int64(time.Now().Sub(time.Unix(job.StartTime, 0)).Seconds())