JCC-CSScheduler/common/pkgs/mq/manager/job.go

100 lines
3.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package manager
import (
"gitlink.org.cn/cloudream/common/pkgs/mq"
schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler"
cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
jobmod "gitlink.org.cn/cloudream/scheduler/common/models/job"
)
type JobService interface {
SubmitJobSet(msg *SubmitJobSet) (*SubmitJobSetResp, *mq.CodeMessage)
JobSetLocalFileUploaded(msg *JobSetLocalFileUploaded) (*JobSetLocalFileUploadedResp, *mq.CodeMessage)
GetJobSetStatus(msg *GetJobSetStatus) (*GetJobSetStatusResp, *mq.CodeMessage)
}
// 提交任务集
var _ = Register(Service.SubmitJobSet)
type SubmitJobSet struct {
mq.MessageBodyBase
JobSet schsdk.JobSetInfo `json:"jobSet"`
PreScheduleScheme jobmod.JobSetPreScheduleScheme `json:"preScheduleScheme"`
}
type SubmitJobSetResp struct {
mq.MessageBodyBase
JobSetID schsdk.JobSetID `json:"jobSetID"`
}
func NewSubmitJobSet(jobSet schsdk.JobSetInfo, preScheduleScheme jobmod.JobSetPreScheduleScheme) *SubmitJobSet {
return &SubmitJobSet{
JobSet: jobSet,
PreScheduleScheme: preScheduleScheme,
}
}
func NewSubmitJobSetResp(jobSetID schsdk.JobSetID) *SubmitJobSetResp {
return &SubmitJobSetResp{
JobSetID: jobSetID,
}
}
func (c *Client) SubmitJobSet(msg *SubmitJobSet, opts ...mq.RequestOption) (*SubmitJobSetResp, error) {
return mq.Request(Service.SubmitJobSet, c.roundTripper, msg, opts...)
}
// JobSet中需要使用的一个文件上传完成
var _ = Register(Service.JobSetLocalFileUploaded)
type JobSetLocalFileUploaded struct {
mq.MessageBodyBase
JobSetID schsdk.JobSetID `json:"jobSetID"`
LocalPath string `json:"localPath"`
Error string `json:"error"` // 如果上传文件失败,那么这个字段说明了失败原因
PackageID cdssdk.PackageID `json:"packageID"` // 如果上传文件成功那么这个字段是上传之后得到的PackageID
}
type JobSetLocalFileUploadedResp struct {
mq.MessageBodyBase
}
func NewJobSetLocalFileUploaded(jobSetID schsdk.JobSetID, localPath string, err string, packageID cdssdk.PackageID) *JobSetLocalFileUploaded {
return &JobSetLocalFileUploaded{
JobSetID: jobSetID,
LocalPath: localPath,
Error: err,
PackageID: packageID,
}
}
func NewJobSetLocalFileUploadedResp() *JobSetLocalFileUploadedResp {
return &JobSetLocalFileUploadedResp{}
}
func (c *Client) JobSetLocalFileUploaded(msg *JobSetLocalFileUploaded, opts ...mq.RequestOption) (*JobSetLocalFileUploadedResp, error) {
return mq.Request(Service.JobSetLocalFileUploaded, c.roundTripper, msg, opts...)
}
var _ = Register(Service.GetJobSetStatus)
// 获取任务集的状态
type GetJobSetStatus struct {
mq.MessageBodyBase
JobSetID schsdk.JobSetID `json:"jobSetID"`
}
type GetJobSetStatusResp struct {
mq.MessageBodyBase
Jobs []jobmod.JobStatus `json:"jobs"`
}
func ReqGetJobSetStatus(jobSetID schsdk.JobSetID) *GetJobSetStatus {
return &GetJobSetStatus{
JobSetID: jobSetID,
}
}
func RespGetJobSetStatus(jobs []jobmod.JobStatus) *GetJobSetStatusResp {
return &GetJobSetStatusResp{
Jobs: jobs,
}
}
func (c *Client) GetJob(msg *GetJobSetStatus, opts ...mq.RequestOption) (*GetJobSetStatusResp, error) {
return mq.Request(Service.GetJobSetStatus, c.roundTripper, msg, opts...)
}