This commit is contained in:
zhouqunjie 2023-07-14 09:15:32 +08:00
parent d47414b968
commit 198d1508ae
15 changed files with 4301 additions and 0 deletions

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
rpc-gen:
goctl rpc protoc ./pb/*.proto --go_out=./ --go-grpc_out=./ --zrpc_out=.

13
etc/hpcth.yaml Normal file
View File

@ -0,0 +1,13 @@
NacosConfig:
DataId: pcm-th-rpc.yaml
Group: DEFAULT_GROUP
ServerConfigs:
- IpAddr: nacos.jcce.dev
Port: 8848
ClientConfig:
NamespaceId: test
TimeoutMs: 5000
NotLoadCacheAtStart: true
LogDir:
CacheDir:
LogLevel: debug

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module gitlink.org.cn/jcce-pcm/pcm-participant-slurm
go 1.19

2772
hpcTH/hpcTH.pb.go Normal file

File diff suppressed because it is too large Load Diff

183
hpcTH/hpcTH_grpc.pb.go Normal file
View File

@ -0,0 +1,183 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.19.4
// source: hpcTH.proto
package hpcTH
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// HpcTHClient is the client API for HpcTH 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 HpcTHClient interface {
// ListJob list all jobs
ListJob(ctx context.Context, in *ListJobReq, opts ...grpc.CallOption) (*ListJobResp, error)
// ListHistoryJob list all history jobs
ListHistoryJob(ctx context.Context, in *ListHistoryJobReq, opts ...grpc.CallOption) (*ListHistoryJobResp, error)
// Submit job
SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error)
}
type hpcTHClient struct {
cc grpc.ClientConnInterface
}
func NewHpcTHClient(cc grpc.ClientConnInterface) HpcTHClient {
return &hpcTHClient{cc}
}
func (c *hpcTHClient) ListJob(ctx context.Context, in *ListJobReq, opts ...grpc.CallOption) (*ListJobResp, error) {
out := new(ListJobResp)
err := c.cc.Invoke(ctx, "/hpcTH.hpcTH/ListJob", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *hpcTHClient) ListHistoryJob(ctx context.Context, in *ListHistoryJobReq, opts ...grpc.CallOption) (*ListHistoryJobResp, error) {
out := new(ListHistoryJobResp)
err := c.cc.Invoke(ctx, "/hpcTH.hpcTH/ListHistoryJob", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *hpcTHClient) SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error) {
out := new(SubmitJobResp)
err := c.cc.Invoke(ctx, "/hpcTH.hpcTH/SubmitJob", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// HpcTHServer is the server API for HpcTH service.
// All implementations must embed UnimplementedHpcTHServer
// for forward compatibility
type HpcTHServer interface {
// ListJob list all jobs
ListJob(context.Context, *ListJobReq) (*ListJobResp, error)
// ListHistoryJob list all history jobs
ListHistoryJob(context.Context, *ListHistoryJobReq) (*ListHistoryJobResp, error)
// Submit job
SubmitJob(context.Context, *SubmitJobReq) (*SubmitJobResp, error)
mustEmbedUnimplementedHpcTHServer()
}
// UnimplementedHpcTHServer must be embedded to have forward compatible implementations.
type UnimplementedHpcTHServer struct {
}
func (UnimplementedHpcTHServer) ListJob(context.Context, *ListJobReq) (*ListJobResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListJob not implemented")
}
func (UnimplementedHpcTHServer) ListHistoryJob(context.Context, *ListHistoryJobReq) (*ListHistoryJobResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListHistoryJob not implemented")
}
func (UnimplementedHpcTHServer) SubmitJob(context.Context, *SubmitJobReq) (*SubmitJobResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method SubmitJob not implemented")
}
func (UnimplementedHpcTHServer) mustEmbedUnimplementedHpcTHServer() {}
// UnsafeHpcTHServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to HpcTHServer will
// result in compilation errors.
type UnsafeHpcTHServer interface {
mustEmbedUnimplementedHpcTHServer()
}
func RegisterHpcTHServer(s grpc.ServiceRegistrar, srv HpcTHServer) {
s.RegisterService(&HpcTH_ServiceDesc, srv)
}
func _HpcTH_ListJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListJobReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HpcTHServer).ListJob(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/hpcTH.hpcTH/ListJob",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HpcTHServer).ListJob(ctx, req.(*ListJobReq))
}
return interceptor(ctx, in, info, handler)
}
func _HpcTH_ListHistoryJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListHistoryJobReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HpcTHServer).ListHistoryJob(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/hpcTH.hpcTH/ListHistoryJob",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HpcTHServer).ListHistoryJob(ctx, req.(*ListHistoryJobReq))
}
return interceptor(ctx, in, info, handler)
}
func _HpcTH_SubmitJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SubmitJobReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HpcTHServer).SubmitJob(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/hpcTH.hpcTH/SubmitJob",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HpcTHServer).SubmitJob(ctx, req.(*SubmitJobReq))
}
return interceptor(ctx, in, info, handler)
}
// HpcTH_ServiceDesc is the grpc.ServiceDesc for HpcTH service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var HpcTH_ServiceDesc = grpc.ServiceDesc{
ServiceName: "hpcTH.hpcTH",
HandlerType: (*HpcTHServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ListJob",
Handler: _HpcTH_ListJob_Handler,
},
{
MethodName: "ListHistoryJob",
Handler: _HpcTH_ListHistoryJob_Handler,
},
{
MethodName: "SubmitJob",
Handler: _HpcTH_SubmitJob_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "hpcTH.proto",
}

65
hpcth.go Normal file
View File

@ -0,0 +1,65 @@
package main
import (
"flag"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/service"
"github.com/zeromicro/go-zero/zrpc"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/hpcTH"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/config"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/logic"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/server"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/svc"
"gitlink.org.cn/jcce-pcm/utils/interceptor/rpcserver"
commonConfig "gitlink.org.cn/jcce-pcm/utils/nacos"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/hpcth.yaml", "the config file")
func main() {
flag.Parse()
var bootstrapConfig commonConfig.BootstrapConfig
conf.MustLoad(*configFile, &bootstrapConfig)
//解析业务配置
var c config.Config
nacosConfig := bootstrapConfig.NacosConfig
serviceConfigContent := nacosConfig.InitConfig(func(data string) {
err := conf.LoadFromYamlBytes([]byte(data), &c)
if err != nil {
panic(err)
}
})
err := conf.LoadFromYamlBytes([]byte(serviceConfigContent), &c)
if err != nil {
panic(err)
}
// start log component
logx.MustSetup(c.LogConf)
// 注册到nacos
nacosConfig.Discovery(&c.RpcServerConf)
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
hpcTH.RegisterHpcTHServer(grpcServer, server.NewHpcTHServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
//rpc log
s.AddUnaryInterceptors(rpcserver.LoggerInterceptor)
defer s.Stop()
logic.InitCron(ctx)
logx.Infof("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}

64
hpcthclient/hpcth.go Normal file
View File

@ -0,0 +1,64 @@
// Code generated by goctl. DO NOT EDIT.
// Source: hpcTH.proto
package hpcthclient
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/hpcTH"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
Argv = hpcTH.Argv
Environment = hpcTH.Environment
HistoryJob = hpcTH.HistoryJob
Job = hpcTH.Job
ListHistoryJobReq = hpcTH.ListHistoryJobReq
ListHistoryJobResp = hpcTH.ListHistoryJobResp
ListJobReq = hpcTH.ListJobReq
ListJobResp = hpcTH.ListJobResp
SubmitJobReq = hpcTH.SubmitJobReq
SubmitJobResp = hpcTH.SubmitJobResp
SubmitResponseMsg = hpcTH.SubmitResponseMsg
HpcTH interface {
// ListJob list all jobs
ListJob(ctx context.Context, in *ListJobReq, opts ...grpc.CallOption) (*ListJobResp, error)
// ListHistoryJob list all history jobs
ListHistoryJob(ctx context.Context, in *ListHistoryJobReq, opts ...grpc.CallOption) (*ListHistoryJobResp, error)
// Submit job
SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error)
}
defaultHpcTH struct {
cli zrpc.Client
}
)
func NewHpcTH(cli zrpc.Client) HpcTH {
return &defaultHpcTH{
cli: cli,
}
}
// ListJob list all jobs
func (m *defaultHpcTH) ListJob(ctx context.Context, in *ListJobReq, opts ...grpc.CallOption) (*ListJobResp, error) {
client := hpcTH.NewHpcTHClient(m.cli.Conn())
return client.ListJob(ctx, in, opts...)
}
// ListHistoryJob list all history jobs
func (m *defaultHpcTH) ListHistoryJob(ctx context.Context, in *ListHistoryJobReq, opts ...grpc.CallOption) (*ListHistoryJobResp, error) {
client := hpcTH.NewHpcTHClient(m.cli.Conn())
return client.ListHistoryJob(ctx, in, opts...)
}
// Submit job
func (m *defaultHpcTH) SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error) {
client := hpcTH.NewHpcTHClient(m.cli.Conn())
return client.SubmitJob(ctx, in, opts...)
}

12
internal/config/config.go Normal file
View File

@ -0,0 +1,12 @@
package config
import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
zrpc.RpcServerConf
LogConf logx.LogConf
PcmCoreRpcConf zrpc.RpcClientConf
}

View File

@ -0,0 +1,82 @@
package logic
import (
"context"
"github.com/jinzhu/copier"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmcoreclient"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/hpcTH"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/svc"
"gitlink.org.cn/jcce-pcm/utils/enum"
"gitlink.org.cn/jcce-pcm/utils/tool"
"strconv"
"time"
)
func InitCron(svc *svc.ServiceContext) {
svc.Cron.Start()
submitJobLogic := NewSubmitJobLogic(context.Background(), svc)
listLogic := NewListJobLogic(context.Background(), svc)
svc.Cron.AddFunc("*/5 * * * * ?", func() {
// 查询core端分发下来的任务列表
infoReq := pcmcoreclient.InfoListReq{
Kind: "hpc",
ServiceName: "th",
}
infoList, err := svc.PcmCoreRpc.InfoList(context.Background(), &infoReq)
if err != nil {
logx.Error(err)
return
}
// 提交任务
submitJob(infoList, submitJobLogic)
// 查询运行中的任务列表同步信息
listReq := hpcTH.ListJobReq{}
listJob, err := listLogic.ListJob(&listReq)
if err != nil {
logx.Error(err)
return
}
for index, _ := range infoList.HpcInfoList {
for _, job := range listJob.Jobs {
if job.Name == infoList.HpcInfoList[index].Name {
copier.CopyWithOption(&infoList.HpcInfoList[index], job, copier.Option{Converters: tool.Converters})
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())
infoList.HpcInfoList[index].Status = enum.State(job.JobState).String()
infoList.HpcInfoList[index].Version = "slurm 2.6.9"
}
}
}
// 同步信息到core端
if len(infoList.HpcInfoList) != 0 {
syncInfoReq := pcmcoreclient.SyncInfoReq{
Kind: "hpc",
ServiceName: "th",
HpcInfoList: infoList.HpcInfoList,
}
svc.PcmCoreRpc.SyncInfo(context.Background(), &syncInfoReq)
}
})
}
func submitJob(infoList *pcmcoreclient.InfoListResp, submitJobLogic *SubmitJobLogic) {
for index, _ := range infoList.HpcInfoList {
if infoList.HpcInfoList[index].Status == "Saved" {
submitReq := hpcTH.SubmitJobReq{
Account: infoList.HpcInfoList[index].Account,
Name: infoList.HpcInfoList[index].Name,
WorkDir: "/root",
Script: infoList.HpcInfoList[index].CmdScript,
UserId: 0,
MinNodes: 1,
}
jobResult, _ := submitJobLogic.SubmitJob(&submitReq)
// 任务提交成功
infoList.HpcInfoList[index].Status = "Pending"
infoList.HpcInfoList[index].JobId = strconv.Itoa(int(jobResult.SubmitResponseMsg[0].JobId))
}
}
}

View File

@ -0,0 +1,154 @@
package logic
/*
#cgo LDFLAGS: -lslurmdb
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <slurm/slurm.h>
#include <slurm/slurmdb.h>
#include <slurm/slurm_errno.h>
#include <memory.h>
#include <malloc.h>
slurmdb_job_rec_t *get_all_slurmdb_job() {
slurmdb_job_cond_t *job_cond = NULL;
void *conn = slurmdb_connection_get();
List joblist = slurmdb_jobs_get(conn, job_cond);
uint16_t listsize = slurm_list_count(joblist);
//qosinfo.record_count = size;
slurmdb_job_rec_t *jobarray = malloc(listsize * sizeof(slurmdb_job_rec_t));
ListIterator itr = slurm_list_iterator_create(joblist);
slurmdb_job_rec_t *rec = NULL;
int i = 0;
while ((rec = slurm_list_next(itr))) {
jobarray[i] = *rec;
i++;
}
slurmdb_connection_close(&conn);
slurm_list_destroy(joblist);
//int arraysize = sizeof(jobarray);
//printf("%d\n", arraysize);
return jobarray;
}
slurmdb_job_rec_t *job_from_array(slurmdb_job_rec_t *job_rec_array, int i) {
return (slurmdb_job_rec_t *) &(job_rec_array[i]);
}
slurmdb_job_rec_t *job_from_array_by_id(slurmdb_job_rec_t *job_rec_array, int job_id) {
int i;
int arraysize = sizeof(job_rec_array);
for (i=0; i<arraysize; i++)
{
//printf("var: %d : %p : %d \n", var, &(job_rec_array[var]), (job_rec_array[var]).stats.cpu_min);
//printf("%d \n",(job_rec_array[i]).stats.cpu_min);
//printf("var: %d : %p : %d \n", var, &(job_rec_array[var]), (job_rec_array[var]).jobid);
if (job_id==(job_rec_array[i]).jobid)
{
break;
} else {
return NULL;
}
}
return (slurmdb_job_rec_t *) &(job_rec_array[i]);
}
int getLength(slurmdb_job_rec_t *job_rec_array) {
return sizeof(job_rec_array);
}
*/
import "C"
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/hpcTH"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type ListHistoryJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListHistoryJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListHistoryJobLogic {
return &ListHistoryJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ListHistoryJob list all jobs from slurmdb
func (l *ListHistoryJobLogic) ListHistoryJob(in *hpcTH.ListHistoryJobReq) (*hpcTH.ListHistoryJobResp, error) {
var dbJobResp hpcTH.ListHistoryJobResp
jobInfos := C.get_all_slurmdb_job()
size := uint32(C.getLength(jobInfos))
dbJobResp.RecordCount = size
for i := uint32(0); i < size; i++ {
cJob := C.job_from_array(jobInfos, C.int(i))
goJob := SlurmdbJobConvertCToGo(cJob)
dbJobResp.HistoryJobs = append(dbJobResp.HistoryJobs, &goJob)
}
dbJobResp.Code = 200
dbJobResp.Msg = "success"
return &dbJobResp, nil
}
func SlurmdbJobConvertCToGo(cStructJob *C.slurmdb_job_rec_t) hpcTH.HistoryJob {
var goStruct hpcTH.HistoryJob
goStruct.Account = C.GoString(cStructJob.account)
goStruct.Associd = uint32(cStructJob.associd)
goStruct.AllocCpu = uint32(cStructJob.alloc_cpus)
goStruct.AllocNodes = uint32(cStructJob.alloc_nodes)
goStruct.Blockid = C.GoString(cStructJob.blockid)
goStruct.Cluster = C.GoString(cStructJob.cluster)
goStruct.DerivedEs = C.GoString(cStructJob.derived_es)
goStruct.DerivedEc = uint32(cStructJob.derived_ec)
goStruct.End = int64(cStructJob.end)
goStruct.Elapsed = uint32(cStructJob.elapsed)
goStruct.Eligible = int64(cStructJob.eligible)
goStruct.Exitcode = uint32(cStructJob.exitcode)
goStruct.Gid = uint32(cStructJob.gid)
goStruct.Jobid = uint32(cStructJob.jobid)
goStruct.Jobname = C.GoString(cStructJob.jobname)
goStruct.Lft = uint32(cStructJob.lft)
goStruct.Nodes = C.GoString(cStructJob.nodes)
goStruct.Priority = uint32(cStructJob.priority)
goStruct.Partition = C.GoString(cStructJob.partition)
goStruct.Qosid = uint32(cStructJob.qosid)
goStruct.Resvid = uint32(cStructJob.resvid)
goStruct.Requid = uint32(cStructJob.requid)
goStruct.ReqCpus = uint32(cStructJob.req_cpus)
goStruct.ReqMem = uint32(cStructJob.req_mem)
goStruct.Start = int64(cStructJob.start)
goStruct.State = uint32(cStructJob.state)
goStruct.SysCpuUsec = uint32(cStructJob.sys_cpu_usec)
goStruct.SysCpuSec = uint32(cStructJob.sys_cpu_sec)
goStruct.Submit = int64(cStructJob.submit)
goStruct.Suspended = uint32(cStructJob.suspended)
goStruct.ShowFull = uint32(cStructJob.show_full)
//var stats_adrs []*pbslurm.SlurmdbStatsT
//var stats pbslurm.SlurmdbStatsT
//stat.ActCpufreq = float64(c_struct_job.stats.act_cpufreq)
//stats.CpuMin = uint32((c_struct_job.stats).cpu_min)
//stat.CpuAve = float64(c_struct_job.stats.cpu_ave)
//stats_adrs = append(stats_adrs, &stats)
//go_struct.Stats = stats
return goStruct
}

View File

@ -0,0 +1,200 @@
package logic
/*
#cgo LDFLAGS: -lslurm
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <slurm/slurm.h>
#include <slurm/slurm_errno.h>
#include <signal.h>
inline uint8_t uint8_ptr(uint8_t* pointer) {
if (NULL == pointer) {
return -1;}
return *pointer;
}
inline int8_t int8_ptr(int8_t* pointer) {
if (NULL == pointer) {
return -1;}
return *pointer;
}
inline uint16_t uint16_ptr(uint16_t* pointer) {
if (NULL == pointer) {
return -1;}
return *pointer;
}
inline int16_t int16_ptr(int16_t* pointer) {
if (NULL == pointer) {
return -1;}
return *pointer;
}
inline uint32_t uint32_ptr(uint32_t* pointer) {
if (NULL == pointer) {
return -1;}
return *pointer;
}
inline int32_t int32_ptr(int32_t* pointer) {
if (NULL == pointer) {
return -1;}
return *pointer;
}
inline uint64_t uint64_ptr(uint64_t* pointer) {
if (NULL == pointer) {
return -1;}
return *pointer;
}
inline int64_t int64_ptr(int16_t* pointer) {
if (NULL == pointer) {
return -1;}
return *pointer;
}
struct job_info_msg *get_job_info(){
struct job_info_msg* job_buffer;
if(slurm_load_jobs ((time_t) NULL,
&job_buffer, SHOW_ALL)) {
return NULL;
}
return job_buffer;
}
struct job_info* job_from_list(struct job_info_msg *list, int i){
return &list->job_array[i];
}
struct job_info_msg *get_single_job_info(uint32_t id){
struct job_info_msg* job_buffer;
if( slurm_load_job (&job_buffer, id, SHOW_DETAIL)) {
return NULL;
}
return job_buffer;
}
*/
import "C"
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/hpcTH"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/svc"
)
func JobCtoGo(cStruct *C.struct_job_info) hpcTH.Job {
var goStruct hpcTH.Job
goStruct.Account = C.GoString(cStruct.account)
goStruct.AllocNode = C.GoString(cStruct.alloc_node)
goStruct.AllocSid = uint32(cStruct.alloc_sid)
goStruct.ArrayJobId = uint32(cStruct.array_job_id)
goStruct.ArrayTaskId = uint32(cStruct.array_task_id)
goStruct.AssocId = uint32(cStruct.assoc_id)
goStruct.BatchFlag = uint32(cStruct.batch_flag)
goStruct.BatchHost = C.GoString(cStruct.batch_host)
goStruct.BoardsPerNode = uint32(cStruct.boards_per_node)
goStruct.BatchScript = C.GoString(cStruct.batch_script)
goStruct.Command = C.GoString(cStruct.command)
goStruct.Comment = C.GoString(cStruct.comment)
goStruct.Contiguous = uint32(cStruct.contiguous)
goStruct.CoresPerSocket = uint32(cStruct.cores_per_socket)
goStruct.CpusPerTask = uint32(cStruct.cpus_per_task)
goStruct.Dependency = C.GoString(cStruct.dependency)
goStruct.DerivedEc = uint32(cStruct.derived_ec)
goStruct.EligibleTime = int64(cStruct.eligible_time)
goStruct.EndTime = int64(cStruct.end_time)
goStruct.ExcNodes = C.GoString(cStruct.exc_nodes)
goStruct.ExcNodeInx = int32(C.int32_ptr(cStruct.exc_node_inx))
goStruct.ExitCode = uint32(cStruct.exit_code)
goStruct.Features = C.GoString(cStruct.features)
goStruct.GroupId = uint32(cStruct.group_id)
goStruct.Gres = C.GoString(cStruct.gres)
goStruct.JobId = uint32(cStruct.job_id)
goStruct.JobState = uint32(cStruct.job_state)
goStruct.Licenses = C.GoString(cStruct.licenses)
goStruct.MaxCpus = uint32(cStruct.max_cpus)
goStruct.MaxNodes = uint32(cStruct.max_nodes)
goStruct.Name = C.GoString(cStruct.name)
goStruct.Network = C.GoString(cStruct.network)
goStruct.Nodes = C.GoString(cStruct.nodes)
goStruct.Nice = uint32(cStruct.nice)
goStruct.NodeInx = int32(C.int32_ptr(cStruct.node_inx))
goStruct.NtasksPerCore = uint32(cStruct.ntasks_per_core)
goStruct.NtasksPerNode = uint32(cStruct.ntasks_per_node)
goStruct.NtasksPerSocket = uint32(cStruct.ntasks_per_socket)
goStruct.NtasksPerBoard = uint32(cStruct.ntasks_per_board)
goStruct.NumCpus = uint32(cStruct.num_cpus)
goStruct.NumNodes = uint32(cStruct.num_nodes)
goStruct.Partition = C.GoString(cStruct.partition)
goStruct.PnMinMemory = uint32(cStruct.pn_min_memory)
goStruct.PnMinCpus = uint32(cStruct.pn_min_cpus)
goStruct.PnMinTmpDisk = uint32(cStruct.pn_min_tmp_disk)
goStruct.PreemptTime = int64(cStruct.preempt_time)
goStruct.PreSusTime = int64(cStruct.pre_sus_time)
goStruct.Priority = uint32(cStruct.priority)
goStruct.Profile = uint32(cStruct.profile)
goStruct.Qos = C.GoString(cStruct.qos)
goStruct.ReqNodes = C.GoString(cStruct.req_nodes)
goStruct.ReqNodeInx = int32(C.int32_ptr(cStruct.req_node_inx))
goStruct.ReqSwitch = uint32(cStruct.req_switch)
goStruct.Requeue = uint32(cStruct.requeue)
goStruct.ResizeTime = int64(cStruct.resize_time)
goStruct.RestartCnt = uint32(cStruct.restart_cnt)
goStruct.ResvName = C.GoString(cStruct.resv_name)
goStruct.Shared = uint32(cStruct.shared)
goStruct.ShowFlags = uint32(cStruct.show_flags)
goStruct.SocketsPerBoard = uint32(cStruct.sockets_per_board)
goStruct.SocketsPerNode = uint32(cStruct.sockets_per_node)
goStruct.StartTime = int64(cStruct.start_time)
goStruct.StateDesc = C.GoString(cStruct.state_desc)
goStruct.StateReason = uint32(cStruct.state_reason)
goStruct.SubmitTime = int64(cStruct.submit_time)
goStruct.SuspendTime = int64(cStruct.suspend_time)
goStruct.TimeLimit = uint32(cStruct.time_limit)
goStruct.TimeMin = uint32(cStruct.time_min)
goStruct.ThreadsPerCore = uint32(cStruct.threads_per_core)
goStruct.UserId = uint32(cStruct.user_id)
goStruct.Wait4Switch = uint32(cStruct.wait4switch)
goStruct.Wckey = C.GoString(cStruct.wckey)
goStruct.WorkDir = C.GoString(cStruct.work_dir)
return goStruct
}
type ListJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListJobLogic {
return &ListJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ListJob list all jobs
func (l *ListJobLogic) ListJob(in *hpcTH.ListJobReq) (*hpcTH.ListJobResp, error) {
var jobResp hpcTH.ListJobResp
cJobBuffer := C.get_job_info()
if cJobBuffer == nil {
jobResp.RecordCount = uint32(0)
jobResp.Jobs = nil
return &jobResp, nil
}
jobResp.RecordCount = uint32(cJobBuffer.record_count)
for i := uint32(0); i < jobResp.RecordCount; i++ {
job := C.job_from_list(cJobBuffer, C.int(i))
goJob := JobCtoGo(job)
jobResp.Jobs = append(jobResp.Jobs, &goJob)
}
jobResp.Code = 200
jobResp.Msg = "success"
C.slurm_free_job_info_msg(cJobBuffer)
return &jobResp, nil
}

View File

@ -0,0 +1,402 @@
package logic
/*
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include<slurm/slurm.h>
#include<slurm/slurm_errno.h>
struct submit_response_msg *submit_job(struct job_descriptor *desc)
{
struct submit_response_msg *resp_msg;
if (slurm_submit_batch_job(desc,
&resp_msg)) {
return NULL;
}
return resp_msg;
}
void free_submit_response_msg(struct submit_response_msg *msg)
{
slurm_free_submit_response_response_msg(msg);
}
int update_job (struct job_descriptor *msg) {
return slurm_update_job (msg);
}
*/
import "C"
import (
"context"
"fmt"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/hpcTH"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/svc"
"unsafe"
"github.com/zeromicro/go-zero/core/logx"
)
type SubmitJobLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewSubmitJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitJobLogic {
return &SubmitJobLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// Submit job
func (l *SubmitJobLogic) SubmitJob(in *hpcTH.SubmitJobReq) (*hpcTH.SubmitJobResp, error) {
var cStruct C.struct_job_descriptor
C.slurm_init_job_desc_msg(&cStruct)
if in.Account != "" {
accountS := C.CString(in.Account)
defer C.free(unsafe.Pointer(accountS))
cStruct.account = accountS
}
if in.AcctgFreq != "" {
acctgFreqS := C.CString(in.AcctgFreq)
defer C.free(unsafe.Pointer(acctgFreqS))
cStruct.acctg_freq = acctgFreqS
}
if in.AllocNode != "" {
allocNodeS := C.CString(in.AllocNode)
defer C.free(unsafe.Pointer(allocNodeS))
cStruct.alloc_node = allocNodeS
}
if in.AllocRespPort != 0 {
cStruct.alloc_resp_port = C.uint16_t(in.AllocRespPort)
}
if in.AllocSid != 0 {
cStruct.alloc_sid = C.uint32_t(in.AllocSid)
}
if len(in.Argv) > 0 {
cStruct.argc = C.uint32_t(len(in.Argv))
cArray := C.malloc(C.size_t(C.size_t(len(in.Argv)) * C.size_t(unsafe.Sizeof(uintptr(0)))))
a := (*[1<<30 - 1]*C.char)(cArray)
for i := 0; i < len(in.Argv); i++ {
a[i] = C.CString(in.Argv[i].String())
}
cStruct.argv = (**C.char)(cArray)
fmt.Printf("test\n")
}
if in.ArrayInx != "" {
arrayInxS := C.CString(in.ArrayInx)
defer C.free(unsafe.Pointer(arrayInxS))
cStruct.array_inx = arrayInxS
}
if in.BeginTime != 0 {
cStruct.begin_time = C.int64_t(in.BeginTime)
}
if in.CkptInterval != 0 {
cStruct.ckpt_interval = C.uint16_t(in.CkptInterval)
}
if in.CkptDir != "" {
ckptDirS := C.CString(in.CkptDir)
defer C.free(unsafe.Pointer(ckptDirS))
cStruct.ckpt_dir = ckptDirS
}
if in.Comment != "" {
commentS := C.CString(in.Comment)
defer C.free(unsafe.Pointer(commentS))
cStruct.comment = commentS
}
if in.Contiguous != 0 {
cStruct.contiguous = C.uint16_t(in.Contiguous)
}
if in.CpuBind != "" {
cpuBindS := C.CString(in.CpuBind)
defer C.free(unsafe.Pointer(cpuBindS))
cStruct.cpu_bind = cpuBindS
}
if in.CpuBindType != 0 {
cStruct.cpu_bind_type = C.uint16_t(in.CpuBindType)
}
if in.Dependency != "" {
dependencyS := C.CString(in.Dependency)
defer C.free(unsafe.Pointer(dependencyS))
cStruct.dependency = dependencyS
}
if in.EndTime != 0 {
cStruct.end_time = C.int64_t(in.EndTime)
}
if len(in.Environment) > 0 {
cStruct.env_size = C.uint32_t(len(in.Environment))
cArray := C.malloc(C.size_t(C.size_t(len(in.Environment)) * C.size_t(unsafe.Sizeof(uintptr(0)))))
a := (*[1<<30 - 1]*C.char)(cArray)
for i := 0; i < len(in.Environment); i++ {
a[i] = C.CString(in.Environment[i].String())
defer C.free(unsafe.Pointer(a[i]))
}
cStruct.environment = (**C.char)(cArray)
} else {
cStruct.env_size = 1
cArray := C.malloc(C.size_t(C.size_t(1) * C.size_t(unsafe.Sizeof(uintptr(0)))))
a := (*[1<<30 - 1]*C.char)(cArray)
a[0] = C.CString("SLURM_GO_JOB=TRUE")
defer C.free(unsafe.Pointer(a[0]))
cStruct.environment = (**C.char)(cArray)
}
if in.ExcNodes != "" {
excNodesS := C.CString(in.ExcNodes)
defer C.free(unsafe.Pointer(excNodesS))
cStruct.exc_nodes = excNodesS
}
if in.Features != "" {
featuresS := C.CString(in.Features)
defer C.free(unsafe.Pointer(featuresS))
cStruct.features = featuresS
}
if in.GroupId != 0 {
cStruct.group_id = C.uint32_t(in.GroupId)
}
if in.Immediate != 0 {
cStruct.immediate = C.uint16_t(in.Immediate)
}
if in.JobId != 0 {
cStruct.job_id = C.uint32_t(in.JobId)
}
if in.KillOnNodeFail != 0 {
cStruct.kill_on_node_fail = C.uint16_t(in.KillOnNodeFail)
}
if in.Licenses != "" {
licensesS := C.CString(in.Licenses)
defer C.free(unsafe.Pointer(licensesS))
cStruct.licenses = licensesS
}
if in.MailType != 0 {
cStruct.mail_type = C.uint16_t(in.MailType)
}
if in.MailUser != "" {
mailUserS := C.CString(in.MailUser)
defer C.free(unsafe.Pointer(mailUserS))
cStruct.mail_user = mailUserS
}
if in.MemBind != "" {
memBindS := C.CString(in.MemBind)
defer C.free(unsafe.Pointer(memBindS))
cStruct.mem_bind = memBindS
}
if in.MemBindType != 0 {
cStruct.mem_bind_type = C.uint16_t(in.MemBindType)
}
if in.Name != "" {
nameS := C.CString(in.Name)
defer C.free(unsafe.Pointer(nameS))
cStruct.name = nameS
}
if in.Network != "" {
networkS := C.CString(in.Network)
defer C.free(unsafe.Pointer(networkS))
cStruct.network = networkS
}
if in.Nice != 0 {
cStruct.nice = C.uint16_t(in.Nice)
}
if in.NumTasks != 0 {
cStruct.num_tasks = C.uint32_t(in.NumTasks)
}
if in.OpenMode != 0 {
cStruct.open_mode = C.uint8_t(in.OpenMode)
}
if in.OtherPort != 0 {
cStruct.other_port = C.uint16_t(in.OtherPort)
}
if in.Overcommit != 0 {
cStruct.overcommit = C.uint8_t(in.Overcommit)
}
if in.Partition != "" {
partitionS := C.CString(in.Partition)
defer C.free(unsafe.Pointer(partitionS))
cStruct.partition = partitionS
}
if in.PlaneSize != 0 {
cStruct.plane_size = C.uint16_t(in.PlaneSize)
}
if in.Priority != 0 {
cStruct.priority = C.uint32_t(in.Priority)
}
if in.Profile != 0 {
cStruct.profile = C.uint32_t(in.Profile)
}
if in.Qos != "" {
qosS := C.CString(in.Qos)
defer C.free(unsafe.Pointer(qosS))
cStruct.qos = qosS
}
if in.Reboot != 0 {
cStruct.reboot = C.uint16_t(in.Reboot)
}
if in.RespHost != "" {
respHostS := C.CString(in.RespHost)
defer C.free(unsafe.Pointer(respHostS))
cStruct.resp_host = respHostS
}
if in.ReqNodes != "" {
reqNodesS := C.CString(in.ReqNodes)
defer C.free(unsafe.Pointer(reqNodesS))
cStruct.req_nodes = reqNodesS
}
if in.Requeue != 0 {
cStruct.requeue = C.uint16_t(in.Requeue)
}
if in.Reservation != "" {
reservationS := C.CString(in.Reservation)
defer C.free(unsafe.Pointer(reservationS))
cStruct.reservation = reservationS
}
if in.Script != "" {
scriptS := C.CString(in.Script)
defer C.free(unsafe.Pointer(scriptS))
cStruct.script = scriptS
}
if in.Shared != 0 {
cStruct.shared = C.uint16_t(in.Shared)
}
if in.SpankJobEnvSize != 0 {
cStruct.spank_job_env_size = C.uint32_t(in.SpankJobEnvSize)
}
if in.TaskDist != 0 {
cStruct.task_dist = C.uint16_t(in.TaskDist)
}
if in.TimeLimit != 0 {
cStruct.time_limit = C.uint32_t(in.TimeLimit)
}
if in.TimeMin != 0 {
cStruct.time_min = C.uint32_t(in.TimeMin)
}
//if go_struct.User_id != 0 {
// c_struct.user_id = C.uint32_t(go_struct.User_id)
//}
cStruct.user_id = C.uint32_t(in.UserId)
if in.WaitAllNodes != 0 {
cStruct.wait_all_nodes = C.uint16_t(in.WaitAllNodes)
}
if in.WarnSignal != 0 {
cStruct.warn_signal = C.uint16_t(in.WarnSignal)
}
if in.WarnTime != 0 {
cStruct.warn_time = C.uint16_t(in.WarnTime)
}
if in.WorkDir != "" {
workDirS := C.CString(in.WorkDir)
defer C.free(unsafe.Pointer(workDirS))
cStruct.work_dir = workDirS
}
if in.CpusPerTask != 0 {
cStruct.cpus_per_task = C.uint16_t(in.CpusPerTask)
}
if in.MinCpus != 0 {
cStruct.min_cpus = C.uint32_t(in.MinCpus)
}
if in.MaxCpus != 0 {
cStruct.max_cpus = C.uint32_t(in.MaxCpus)
}
if in.MinNodes != 0 {
cStruct.min_nodes = C.uint32_t(in.MinNodes)
}
if in.MaxNodes != 0 {
cStruct.max_nodes = C.uint32_t(in.MaxNodes)
}
if in.BoardsPerNode != 0 {
cStruct.boards_per_node = C.uint16_t(in.BoardsPerNode)
}
if in.SocketsPerBoard != 0 {
cStruct.sockets_per_board = C.uint16_t(in.SocketsPerBoard)
}
if in.SocketsPerNode != 0 {
cStruct.sockets_per_node = C.uint16_t(in.SocketsPerNode)
}
if in.CoresPerSocket != 0 {
cStruct.cores_per_socket = C.uint16_t(in.CoresPerSocket)
}
if in.ThreadsPerCore != 0 {
cStruct.threads_per_core = C.uint16_t(in.ThreadsPerCore)
}
if in.NtasksPerNode != 0 {
cStruct.ntasks_per_node = C.uint16_t(in.NtasksPerNode)
}
if in.NtasksPerSocket != 0 {
cStruct.ntasks_per_socket = C.uint16_t(in.NtasksPerSocket)
}
if in.NtasksPerCore != 0 {
cStruct.ntasks_per_core = C.uint16_t(in.NtasksPerCore)
}
if in.NtasksPerBoard != 0 {
cStruct.ntasks_per_board = C.uint16_t(in.NtasksPerBoard)
}
if in.PnMinCpus != 0 {
cStruct.pn_min_cpus = C.uint16_t(in.PnMinCpus)
}
if in.PnMinMemory != 0 {
cStruct.pn_min_memory = C.uint32_t(in.PnMinMemory)
}
if in.PnMinTmpDisk != 0 {
cStruct.pn_min_tmp_disk = C.uint32_t(in.PnMinTmpDisk)
}
if in.ReqSwitch != 0 {
cStruct.req_switch = C.uint32_t(in.ReqSwitch)
}
if in.StdErr != "" {
stdErrS := C.CString(in.StdErr)
defer C.free(unsafe.Pointer(stdErrS))
cStruct.std_err = stdErrS
}
if in.StdIn != "" {
stdInS := C.CString(in.StdIn)
defer C.free(unsafe.Pointer(stdInS))
cStruct.std_in = stdInS
}
if in.StdOut != "" {
stdOutS := C.CString(in.StdOut)
defer C.free(unsafe.Pointer(stdOutS))
cStruct.std_out = stdOutS
}
if in.Wait4Switch != 0 {
cStruct.wait4switch = C.uint32_t(in.Wait4Switch)
}
if in.Wckey != "" {
wckeyS := C.CString(in.Wckey)
defer C.free(unsafe.Pointer(wckeyS))
cStruct.wckey = wckeyS
}
cMsg := C.submit_job(&cStruct)
defer C.free_submit_response_msg(cMsg)
if cMsg == nil {
goMsg := hpcTH.SubmitJobResp{}
goMsg.SubmitResponseMsg[0].JobId = 1<<31 - 1
goMsg.SubmitResponseMsg[0].ErrorCode = uint32(C.slurm_get_errno())
return &goMsg, nil
}
goMsg := submitResponseMsgConvertCToGo(cMsg)
return &goMsg, nil
}
func submitResponseMsgConvertCToGo(cStruct *C.struct_submit_response_msg) hpcTH.SubmitJobResp {
var goStruct hpcTH.SubmitJobResp
submitRespMsg := hpcTH.SubmitResponseMsg{}
submitRespMsg.JobId = uint32(cStruct.job_id)
submitRespMsg.StepId = uint32(cStruct.step_id)
submitRespMsg.ErrorCode = uint32(cStruct.error_code)
goStruct.SubmitResponseMsg = append(goStruct.SubmitResponseMsg, &submitRespMsg)
return goStruct
}

View File

@ -0,0 +1,41 @@
// Code generated by goctl. DO NOT EDIT.
// Source: hpcTH.proto
package server
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/hpcTH"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/logic"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/svc"
)
type HpcTHServer struct {
svcCtx *svc.ServiceContext
hpcTH.UnimplementedHpcTHServer
}
func NewHpcTHServer(svcCtx *svc.ServiceContext) *HpcTHServer {
return &HpcTHServer{
svcCtx: svcCtx,
}
}
// ListJob list all jobs
func (s *HpcTHServer) ListJob(ctx context.Context, in *hpcTH.ListJobReq) (*hpcTH.ListJobResp, error) {
l := logic.NewListJobLogic(ctx, s.svcCtx)
return l.ListJob(in)
}
// ListHistoryJob list all history jobs
func (s *HpcTHServer) ListHistoryJob(ctx context.Context, in *hpcTH.ListHistoryJobReq) (*hpcTH.ListHistoryJobResp, error) {
l := logic.NewListHistoryJobLogic(ctx, s.svcCtx)
return l.ListHistoryJob(in)
}
// Submit job
func (s *HpcTHServer) SubmitJob(ctx context.Context, in *hpcTH.SubmitJobReq) (*hpcTH.SubmitJobResp, error) {
l := logic.NewSubmitJobLogic(ctx, s.svcCtx)
return l.SubmitJob(in)
}

View File

@ -0,0 +1,21 @@
package svc
import (
"github.com/zeromicro/go-zero/zrpc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmcoreclient"
"gitlink.org.cn/jcce-pcm/pcm-participant-slurm/rpc/internal/config"
)
type ServiceContext struct {
Config config.Config
Cron *cron.Cron
PcmCoreRpc pcmcoreclient.PcmCore
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Cron: cron.New(cron.WithSeconds()),
Config: c,
PcmCoreRpc: pcmcoreclient.NewPcmCore(zrpc.MustNewClient(c.PcmCoreRpcConf)),
}
}

287
pb/hpcTH.proto Normal file
View File

@ -0,0 +1,287 @@
syntax = "proto3";
package hpcTH;
option go_package = "/hpcTH";
/******************Job Start*************************/
message job{
string account = 1; // @gotags: copier:"Account"
string alloc_node = 2; // @gotags: copier:"AllocNode"
uint32 alloc_sid = 3; // @gotags: copier:"AllocSid"
uint32 array_job_id = 4; // @gotags: copier:"ArrayJobId"
uint32 array_task_id = 5; // @gotags: copier:"ArrayTaskId"
uint32 assoc_id = 6; // @gotags: copier:"AssocId"
uint32 batch_flag = 7; // @gotags: copier:"BatchFlag"
string batch_host = 8; // @gotags: copier:"BatchHost"
string batch_script = 9; // @gotags: copier:"BatchScript"
string command = 10; // @gotags: copier:"Command"
string comment = 11; // @gotags: copier:"Comment"
uint32 contiguous = 12; // @gotags: copier:"Contiguous"
uint32 cpus_per_task = 13; // @gotags: copier:"CpusPerTask"
string dependency = 14; // @gotags: copier:"Dependency"
uint32 derived_ec = 15; // @gotags: copier:"DerivedEc"
int64 eligible_time = 16; // @gotags: copier:"EligibleTime"
int64 end_time = 17; // @gotags: copier:"EndTime"
string exc_nodes = 18; // @gotags: copier:"ExcNodes"
int32 exc_node_inx = 19; // @gotags: copier:"ExcNodeInx"
uint32 exit_code = 20; // @gotags: copier:"ExitCode"
string features = 21; // @gotags: copier:"Features"
string gres = 22; // @gotags: copier:"Gres"
uint32 group_id = 23; // @gotags: copier:"GroupId"
uint32 job_id = 24; // @gotags: copier:"JobId"
uint32 job_state = 25; // @gotags: copier:"JobState"
string licenses = 26; // @gotags: copier:"Licenses"
uint32 max_cpus = 27; // @gotags: copier:"MaxCpus"
uint32 max_nodes = 28; // @gotags: copier:"MaxNodes"
uint32 boards_per_node = 29; // @gotags: copier:"BoardsPerNode"
uint32 sockets_per_board = 30; // @gotags: copier:"SocketsPerBoard"
uint32 sockets_per_node = 31; // @gotags: copier:"SocketsPerNode"
uint32 cores_per_socket = 32; // @gotags: copier:"CoresPerSocket"
uint32 threads_per_core = 33; // @gotags: copier:"ThreadsPerCore"
string name = 34; // @gotags: copier:"Name"
string network = 35; // @gotags: copier:"Network"
string nodes = 36; // @gotags: copier:"Nodes"
uint32 nice = 37; // @gotags: copier:"Nice"
int32 node_inx = 38; // @gotags: copier:"NodeInx"
uint32 ntasks_per_core = 39; // @gotags: copier:"NtasksPerCore"
uint32 ntasks_per_node = 40; // @gotags: copier:"NtasksPerNode"
uint32 ntasks_per_socket = 41; // @gotags: copier:"NtasksPerSocket"
uint32 ntasks_per_board = 42; // @gotags: copier:"NtasksPerBoard"
uint32 num_nodes = 43; // @gotags: copier:"NumNodes"
uint32 num_cpus = 44; // @gotags: copier:"NumCpus"
string partition = 45; // @gotags: copier:"Partition"
uint32 pn_min_memory = 46; // @gotags: copier:"PnMinMemory"
uint32 pn_min_cpus = 47; // @gotags: copier:"PnMinCpus"
uint32 pn_min_tmp_disk = 48; // @gotags: copier:"PnMinTmpDisk"
int64 pre_sus_time = 49; // @gotags: copier:"PreSusTime"
uint32 priority = 50; // @gotags: copier:"Priority"
uint32 profile = 51; // @gotags: copier:"Profile"
string qos = 52; // @gotags: copier:"Qos"
string req_nodes = 53; // @gotags: copier:"ReqNodes"
int32 req_node_inx = 54; // @gotags: copier:"ReqNodeInx"
uint32 req_switch = 55; // @gotags: copier:"ReqSwitch"
uint32 requeue = 56; // @gotags: copier:"Requeue"
int64 resize_time = 57; // @gotags: copier:"ResizeTime"
uint32 restart_cnt = 58; // @gotags: copier:"RestartCnt"
string resv_name = 59; // @gotags: copier:"ResvName"
uint32 shared = 60; // @gotags: copier:"Shared"
uint32 show_flags = 61; // @gotags: copier:"ShowFlags"
int64 start_time = 62; // @gotags: copier:"StartTime"
string state_desc = 63; // @gotags: copier:"StateDesc"
uint32 state_reason = 64; // @gotags: copier:"StateReason"
int64 submit_time = 65; // @gotags: copier:"SubmitTime"
int64 suspend_time = 66; // @gotags: copier:"SuspendTime"
uint32 time_limit = 67; // @gotags: copier:"TimeLimit"
uint32 time_min = 68; // @gotags: copier:"TimeMin"
uint32 user_id = 69; // @gotags: copier:"UserId"
int64 preempt_time = 70; // @gotags: copier:"PreemptTime"
uint32 wait4switch = 71; // @gotags: copier:"Wait4Switch"
string wckey = 72; // @gotags: copier:"Wckey"
string work_dir = 73; // @gotags: copier:"WorkDir"
}
message ListJobReq{
}
message ListJobResp{
uint32 code = 1; // @gotags: copier:"Code"
string msg = 2; // @gotags: copier:"Msg"
uint32 record_count = 3; // @gotags: copier:"RecordCount"
repeated job jobs = 4; // @gotags: copier:"Jobs"
}
/******************Job End*************************/
/******************History Job Start*************************/
message historyJob{
uint32 alloc_cpu = 1; // @gotags: copier:"AllocCPU"
uint32 alloc_nodes = 2; // @gotags: copier:"AllocNodes"
string account = 3; // @gotags: copier:"Account"
uint32 associd = 4; // @gotags: copier:"AssocId"
string blockid = 5; // @gotags: copier:"BlockId"
string cluster = 6; // @gotags: copier:"Cluster"
uint32 derived_ec = 7; // @gotags: copier:"DerivedEc"
string derived_es = 8; // @gotags: copier:"DerivedEs"
uint32 elapsed = 9; // @gotags: copier:"Elapsed"
int64 eligible = 10;// @gotags: copier:"Eligible"
int64 end = 11;// @gotags: copier:"End"
uint32 exitcode = 12;// @gotags: copier:"ExitCode"
uint32 gid = 13;// @gotags: copier:"Gid"
uint32 jobid = 14;// @gotags: copier:"JobId"
string jobname = 15;// @gotags: copier:"JobName"
uint32 lft = 16;// @gotags: copier:"Lft"
string partition = 17;// @gotags: copier:"Partition"
string nodes = 18;// @gotags: copier:"Nodes"
uint32 priority = 19;// @gotags: copier:"Priority"
uint32 qosid = 20;// @gotags: copier:"Qosid"
uint32 req_cpus = 21;// @gotags: copier:"ReqCpus"
uint32 req_mem = 22;// @gotags: copier:"ReqMem"
uint32 requid = 23;// @gotags: copier:"Requid"
uint32 resvid = 24;// @gotags: copier:"Resvid"
uint32 show_full = 25;// @gotags: copier:"ShowFull"
int64 start = 26;// @gotags: copier:"Start"
uint32 state = 27;// @gotags: copier:"State"
int64 submit = 28;// @gotags: copier:"Submit"
uint32 suspended = 29;// @gotags: copier:"Suspended"
uint32 sys_cpu_sec = 30;// @gotags: copier:"SysCpuSec"
uint32 sys_cpu_usec = 31;// @gotags: copier:"SysCpuUsec"
uint32 timelimit = 32;// @gotags: copier:"Timelimit"
uint32 tot_cpu_sec = 33;// @gotags: copier:"TotCpuSec"
uint32 tot_cpu_usec = 34;// @gotags: copier:"TotCpuUsec"
uint32 track_steps = 35;// @gotags: copier:"TrackSteps"
uint32 uid = 36;// @gotags: copier:"Uid"
string user = 37;// @gotags: copier:"User"
uint32 user_cpu_sec = 38;// @gotags: copier:"UserCpuSec"
uint32 user_cpu_usec = 39;// @gotags: copier:"UserCpuUsec"
string wckey = 40;// @gotags: copier:"Wckey"
uint32 wckeyid = 41;// @gotags: copier:"Wckeyid"
}
message ListHistoryJobReq{
}
message ListHistoryJobResp{
uint32 code = 1; // @gotags: copier:"Code"
string msg = 2; // @gotags: copier:"Msg"
uint32 record_count = 3; // @gotags: copier:"RecordCount"
repeated historyJob history_jobs = 4; // @gotags: copier:"HistoryJobs"
}
/******************History Job End*************************/
/******************Job(Submit) Start*************************/
message SubmitJobReq{
string account =1; // @gotags: copier:"account" /* charge to specified account */
string acctg_freq =2; // @gotags: copier:"acctg_freq" /* accounting polling intervals (seconds) */
string alloc_node=3; // @gotags: copier:"alloc_node" /* node making resource allocation request * NOTE: Normally set by slurm_submit* or * slurm_allocate* function */
uint32 alloc_resp_port=4; // @gotags: copier:"alloc_resp_port" /* port to send allocation confirmation to */
uint32 alloc_sid =5; // @gotags: copier:"alloc_sid" /* local sid making resource allocation request * NOTE: Normally set by slurm_submit* or * slurm_allocate* function * NOTE: Also used for update flags, see * ALLOC_SID_* flags */
uint32 argc =6; // @gotags: copier:"argc" /* number of arguments to the script */
repeated Argv argv = 7; // @gotags: copier:"Argv" /* arguments to the script */
string array_inx =8; // @gotags: copier:"array_inx" /* job array index values */ //void *array_bitmap; /* NOTE: Set by slurmctld */
int64 begin_time = 9; // @gotags: copier:"begin_time" /* delay initiation until this time */
uint32 ckpt_interval=10; // @gotags: copier:"ckpt_interval" /* periodically checkpoint this job */
string ckpt_dir =11; // @gotags: copier:"ckpt_dir" /* directory to store checkpoint images */
string comment =12; // @gotags: copier:"comment" /* arbitrary comment (used by Moab scheduler) */
uint32 contiguous=13; // @gotags: copier:"contiguous" /* 1 if job requires contiguous nodes,* 0 otherwise,default=0 */
string cpu_bind=14; // @gotags: copier:"cpu_bind" /* binding map for map/mask_cpu */
uint32 cpu_bind_type=15; // @gotags: copier:"cpu_bind_type" /* see cpu_bind_type_t */
string dependency =16; // @gotags: copier:"dependency" /* synchronize job execution with other jobs */
int64 end_time=17; // @gotags: copier:"end_time" /* time by which job must complete, used for * job update only now, possible deadline * scheduling in the future */
repeated Environment environment=18; // @gotags: copier:"Environment" /* environment variables to set for job, * name=value pairs, one per line */
uint32 env_size =19; // @gotags: copier:"env_size" /* element count in environment */
string exc_nodes =20; // @gotags: copier:"exc_nodes" /* comma separated list of nodes excluded * from job's allocation, default NONE */
string features =21; // @gotags: copier:"features" /* comma separated list of required features, * default NONE */
string gres =22; // @gotags: copier:"gres" /* comma separated list of required generic * resources, default NONE */
uint32 group_id =23; // @gotags: copier:"group_id" /* group to assume, if run as root. */
uint32 immediate=24; // @gotags: copier:"immediate" /* 1 if allocate to run or fail immediately, * 0 if to be queued awaiting resources */
uint32 job_id =25; // @gotags: copier:"job_id" /* job ID, default set by SLURM */
uint32 kill_on_node_fail=26; // @gotags: copier:"kill_on_node_fail" /* 1 if node failure to kill job, * 0 otherwise,default=1 */
string licenses=27; // @gotags: copier:"licenses" /* licenses required by the job */
uint32 mail_type=28; // @gotags: copier:"mail_type" /* see MAIL_JOB_ definitions above */
string mail_user =29; // @gotags: copier:"mail_user" /* user to receive notification */
string mem_bind =30; // @gotags: copier:"mem_bind" /* binding map for map/mask_cpu */
uint32 mem_bind_type=31; // @gotags: copier:"mem_bind_type" /* see mem_bind_type_t */
string name =32; // @gotags: copier:"name" /* name of the job, default "" */
string network=33; // @gotags: copier:"network" /* network use spec */
uint32 nice =34; // @gotags: copier:"nice" /* requested priority change, * NICE_OFFSET == no change */
uint32 num_tasks=35; // @gotags: copier:"num_tasks" /* number of tasks to be started, * for batch only */
uint32 open_mode=36; // @gotags: copier:"open_mode" /* out/err open mode truncate or append, * see OPEN_MODE_* */
uint32 other_port=37; // @gotags: copier:"other_port" /* port to send various notification msg to */
uint32 overcommit =38; // @gotags: copier:"overcommit" /* over subscribe resources, for batch only */
string partition=39; // @gotags: copier:"partition" /* name of requested partition, * default in SLURM config */
uint32 plane_size =40; // @gotags: copier:"plane_size" /* plane size when task_dist = SLURM_DIST_PLANE */
uint32 priority =41; // @gotags: copier:"priority" /* relative priority of the job, * explicitly set only for user root, * 0 == held (don't initiate) */
uint32 profile =42; // @gotags: copier:"profile" /* Level of acct_gather_profile {all | none} */
string qos =43; // @gotags: copier:"qos" /* Quality of Service */
string resp_host=44; // @gotags: copier:"resp_host" /* NOTE: Set by slurmctld */
string req_nodes=45; // @gotags: copier:"req_nodes" /* comma separated list of required nodes * default NONE */
uint32 requeue=46; // @gotags: copier:"requeue" /* enable or disable job requeue option */
string reservation=47; // @gotags: copier:"reservation" /* name of reservation to use */
string script=48; // @gotags: copier:"script" /* the actual job script, default NONE */
uint32 shared =49; // @gotags: copier:"shared" /* 1 if job can share nodes with other jobs, * 0 if job needs exclusive access to the node, * or NO_VAL to accept the system default. * SHARED_FORCE to eliminate user control. */ //char **spank_job_env; environment variables for job prolog/epilog // * scripts as set by SPANK plugins
uint32 spank_job_env_size=50; // @gotags: copier:"spank_job_env_size" /* element count in spank_env */
uint32 task_dist =51; // @gotags: copier:"task_dist" /* see enum task_dist_state */
uint32 time_limit =52; // @gotags: copier:"time_limit" /* maximum run time in minutes, default is * partition limit */
uint32 time_min =53; // @gotags: copier:"time_min" /* minimum run time in minutes, default is * time_limit */
uint32 user_id=54; // @gotags: copier:"user_id" /* set only if different from current UID, * can only be explicitly set by user root */
uint32 wait_all_nodes=55; // @gotags: copier:"wait_all_nodes" /* 0 to start job immediately after allocation * 1 to start job after all nodes booted * or NO_VAL to use system default */
uint32 warn_signal=56; // @gotags: copier:"warn_signal" /* signal to send when approaching end time */
uint32 warn_time=57; // @gotags: copier:"warn_time" /* time before end to send signal (seconds) */
string work_dir =58; // @gotags: copier:"work_dir" /* pathname of working directory */ /* job constraints: */
uint32 cpus_per_task=59; // @gotags: copier:"cpus_per_task" /* number of processors required for * each task */
uint32 min_cpus =60; // @gotags: copier:"min_cpus" /* minimum number of processors required, * default=0 */
uint32 max_cpus=61; // @gotags: copier:"max_cpus" /* maximum number of processors required, * default=0 */
uint32 min_nodes=62; // @gotags: copier:"min_nodes" /* minimum number of nodes required by job, * default=0 */
uint32 max_nodes=63; // @gotags: copier:"max_nodes" /* maximum number of nodes usable by job, * default=0 */
uint32 boards_per_node =64; // @gotags: copier:"boards_per_node" /* boards per node required by job */
uint32 sockets_per_board=65; // @gotags: copier:"sockets_per_board" /* sockets per board required by job */
uint32 sockets_per_node =66; // @gotags: copier:"sockets_per_node" /* sockets per node required by job */
uint32 cores_per_socket=67; // @gotags: copier:"cores_per_socket" /* cores per socket required by job */
uint32 threads_per_core=68; // @gotags: copier:"threads_per_core" /* threads per core required by job */
uint32 ntasks_per_node =69; // @gotags: copier:"ntasks_per_node" /* number of tasks to invoke on each node */
uint32 ntasks_per_socket=70; // @gotags: copier:"ntasks_per_socket" /* number of tasks to invoke on * each socket */
uint32 ntasks_per_core =71; // @gotags: copier:"ntasks_per_core" /* number of tasks to invoke on each core */
uint32 ntasks_per_board=72; // @gotags: copier:"ntasks_per_board" /* number of tasks to invoke on each board */
uint32 pn_min_cpus =73; // @gotags: copier:"pn_min_cpus" /* minimum # CPUs per node, default=0 */
uint32 pn_min_memory=74; // @gotags: copier:"pn_min_memory" /* minimum real memory per node OR * real memory per CPU | MEM_PER_CPU, * default=0 (no limit) */
uint32 pn_min_tmp_disk =75; // @gotags: copier:"pn_min_tmp_disk" /* minimum tmp disk per node, * default=0 */
/*
* The following parameters are only meaningful on a Blue Gene
* system at present. Some will be of value on other system. Don't remove these
* they are needed for LCRM and others that can't talk to the opaque data type
* select_jobinfo.
*/
//uint16_t geometry[HIGHEST_DIMENSIONS]; node count in various // * dimensions, e.g. X, Y, and Z
//uint16_t conn_type[HIGHEST_DIMENSIONS]; see enum connection_type
uint32 reboot=76; // @gotags: copier:"reboot" /* force node reboot before startup */
uint32 rotate=77; // @gotags: copier:"rotate" /* permit geometry rotation if set */
//char *blrtsimage; /* BlrtsImage for block */
//char *linuximage; /* LinuxImage for block */
//char *mloaderimage; /* MloaderImage for block */
//char *ramdiskimage; /* RamDiskImage for block */
/* End of Blue Gene specific values */
uint32 req_switch =78; // @gotags: copier:"req_switch" /* Minimum number of switches */ //dynamic_plugin_data_t *select_jobinfo; /* opaque data type, // * SLURM internal use only */
string std_err=79; // @gotags: copier:"std_err" /* pathname of stderr */
string std_in =80; // @gotags: copier:"std_in" /* pathname of stdin */
string std_out=81; // @gotags: copier:"std_out" /* pathname of stdout */
uint32 wait4switch=82; // @gotags: copier:"wait4switch" /* Maximum time to wait for minimum switches */
string wckey =83; // @gotags: copier:"wckey" /* wckey for job */
}
message SubmitJobResp{
repeated SubmitResponseMsg submit_response_msg = 1;
}
message SubmitResponseMsg{
uint32 job_id = 1;
uint32 step_id =2;
uint32 error_code=3;
}
message Argv{
string argv =1; // @gotags: copier:"argv"
}
message Environment{
string environment =1; // @gotags: copier:"environment"
}
/******************Job(Submit) End*************************/
// hpc Services for Tianhe
service hpcTH {
//ListJob list all jobs
rpc ListJob(ListJobReq) returns (ListJobResp);
//ListHistoryJob list all history jobs
rpc ListHistoryJob(ListHistoryJobReq) returns (ListHistoryJobResp);
//Submit job
rpc SubmitJob(SubmitJobReq) returns (SubmitJobResp);
}