| @@ -8,3 +8,4 @@ User: "zhijiang" | |||
| Password: "111111a" | |||
| OrgId: "313ae32df03bc116255e6808949fcf57" | |||
| Layout: "2006-01-02 15:04:05" | |||
| EndPoint: https://api01.hpccube.com:65106 | |||
| @@ -1,7 +1,7 @@ | |||
| // Code generated by protoc-gen-go-grpc. DO NOT EDIT. | |||
| // versions: | |||
| // - protoc-gen-go-grpc v1.2.0 | |||
| // - protoc v3.12.4 | |||
| // - protoc v3.21.12 | |||
| // source: hpcAC.proto | |||
| package hpcAC | |||
| @@ -30,10 +30,21 @@ type HpcACClient interface { | |||
| SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error) | |||
| // ListJobManager list all job managers | |||
| ListJobManager(ctx context.Context, in *JobManagerReq, opts ...grpc.CallOption) (*ListJobManagerResp, error) | |||
| <<<<<<< HEAD | |||
| // GetJobDetail get job detail | |||
| GetJobDetail(ctx context.Context, in *JobDetailReq, opts ...grpc.CallOption) (*GetJobDetailResp, error) | |||
| // DeleteJob delete job | |||
| DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...grpc.CallOption) (*DeleteJobResp, error) | |||
| ======= | |||
| // FileContent 查看文件内容 | |||
| FileContent(ctx context.Context, in *FileDataReq, opts ...grpc.CallOption) (*FileContentResp, error) | |||
| // SelectQueueByUser 查询用户可访问队列列表 | |||
| SelectQueueByUser(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueResp, error) | |||
| // QueryQueueDetails 查询队列资源详细信息 | |||
| QueryQueueDetails(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueDetailsResp, error) | |||
| // /QueryUserQuotasLimit 查询用户资源限制信息 | |||
| QueryUserQuotasLimit(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*UserQuotasLimitResp, error) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| } | |||
| type hpcACClient struct { | |||
| @@ -80,18 +91,48 @@ func (c *hpcACClient) ListJobManager(ctx context.Context, in *JobManagerReq, opt | |||
| return out, nil | |||
| } | |||
| <<<<<<< HEAD | |||
| func (c *hpcACClient) GetJobDetail(ctx context.Context, in *JobDetailReq, opts ...grpc.CallOption) (*GetJobDetailResp, error) { | |||
| out := new(GetJobDetailResp) | |||
| err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetJobDetail", in, out, opts...) | |||
| ======= | |||
| func (c *hpcACClient) FileContent(ctx context.Context, in *FileDataReq, opts ...grpc.CallOption) (*FileContentResp, error) { | |||
| out := new(FileContentResp) | |||
| err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/FileContent", in, out, opts...) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return out, nil | |||
| } | |||
| <<<<<<< HEAD | |||
| func (c *hpcACClient) DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...grpc.CallOption) (*DeleteJobResp, error) { | |||
| out := new(DeleteJobResp) | |||
| err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/DeleteJob", in, out, opts...) | |||
| ======= | |||
| func (c *hpcACClient) SelectQueueByUser(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueResp, error) { | |||
| out := new(QueueResp) | |||
| err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/SelectQueueByUser", in, out, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return out, nil | |||
| } | |||
| func (c *hpcACClient) QueryQueueDetails(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueDetailsResp, error) { | |||
| out := new(QueueDetailsResp) | |||
| err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/QueryQueueDetails", in, out, opts...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return out, nil | |||
| } | |||
| func (c *hpcACClient) QueryUserQuotasLimit(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*UserQuotasLimitResp, error) { | |||
| out := new(UserQuotasLimitResp) | |||
| err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/QueryUserQuotasLimit", in, out, opts...) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -110,10 +151,21 @@ type HpcACServer interface { | |||
| SubmitJob(context.Context, *SubmitJobReq) (*SubmitJobResp, error) | |||
| // ListJobManager list all job managers | |||
| ListJobManager(context.Context, *JobManagerReq) (*ListJobManagerResp, error) | |||
| <<<<<<< HEAD | |||
| // GetJobDetail get job detail | |||
| GetJobDetail(context.Context, *JobDetailReq) (*GetJobDetailResp, error) | |||
| // DeleteJob delete job | |||
| DeleteJob(context.Context, *DeleteJobReq) (*DeleteJobResp, error) | |||
| ======= | |||
| // FileContent 查看文件内容 | |||
| FileContent(context.Context, *FileDataReq) (*FileContentResp, error) | |||
| // SelectQueueByUser 查询用户可访问队列列表 | |||
| SelectQueueByUser(context.Context, *QueueReq) (*QueueResp, error) | |||
| // QueryQueueDetails 查询队列资源详细信息 | |||
| QueryQueueDetails(context.Context, *QueueReq) (*QueueDetailsResp, error) | |||
| // /QueryUserQuotasLimit 查询用户资源限制信息 | |||
| QueryUserQuotasLimit(context.Context, *QueueReq) (*UserQuotasLimitResp, error) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| mustEmbedUnimplementedHpcACServer() | |||
| } | |||
| @@ -133,11 +185,25 @@ func (UnimplementedHpcACServer) SubmitJob(context.Context, *SubmitJobReq) (*Subm | |||
| func (UnimplementedHpcACServer) ListJobManager(context.Context, *JobManagerReq) (*ListJobManagerResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method ListJobManager not implemented") | |||
| } | |||
| <<<<<<< HEAD | |||
| func (UnimplementedHpcACServer) GetJobDetail(context.Context, *JobDetailReq) (*GetJobDetailResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method GetJobDetail not implemented") | |||
| } | |||
| func (UnimplementedHpcACServer) DeleteJob(context.Context, *DeleteJobReq) (*DeleteJobResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method DeleteJob not implemented") | |||
| ======= | |||
| func (UnimplementedHpcACServer) FileContent(context.Context, *FileDataReq) (*FileContentResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method FileContent not implemented") | |||
| } | |||
| func (UnimplementedHpcACServer) SelectQueueByUser(context.Context, *QueueReq) (*QueueResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method SelectQueueByUser not implemented") | |||
| } | |||
| func (UnimplementedHpcACServer) QueryQueueDetails(context.Context, *QueueReq) (*QueueDetailsResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method QueryQueueDetails not implemented") | |||
| } | |||
| func (UnimplementedHpcACServer) QueryUserQuotasLimit(context.Context, *QueueReq) (*UserQuotasLimitResp, error) { | |||
| return nil, status.Errorf(codes.Unimplemented, "method QueryUserQuotasLimit not implemented") | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| } | |||
| func (UnimplementedHpcACServer) mustEmbedUnimplementedHpcACServer() {} | |||
| @@ -224,12 +290,18 @@ func _HpcAC_ListJobManager_Handler(srv interface{}, ctx context.Context, dec fun | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| <<<<<<< HEAD | |||
| func _HpcAC_GetJobDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(JobDetailReq) | |||
| ======= | |||
| func _HpcAC_FileContent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(FileDataReq) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| <<<<<<< HEAD | |||
| return srv.(HpcACServer).GetJobDetail(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| @@ -238,16 +310,32 @@ func _HpcAC_GetJobDetail_Handler(srv interface{}, ctx context.Context, dec func( | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(HpcACServer).GetJobDetail(ctx, req.(*JobDetailReq)) | |||
| ======= | |||
| return srv.(HpcACServer).FileContent(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: "/hpcAC.hpcAC/FileContent", | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(HpcACServer).FileContent(ctx, req.(*FileDataReq)) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| <<<<<<< HEAD | |||
| func _HpcAC_DeleteJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(DeleteJobReq) | |||
| ======= | |||
| func _HpcAC_SelectQueueByUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(QueueReq) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| <<<<<<< HEAD | |||
| return srv.(HpcACServer).DeleteJob(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| @@ -256,6 +344,52 @@ func _HpcAC_DeleteJob_Handler(srv interface{}, ctx context.Context, dec func(int | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(HpcACServer).DeleteJob(ctx, req.(*DeleteJobReq)) | |||
| ======= | |||
| return srv.(HpcACServer).SelectQueueByUser(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: "/hpcAC.hpcAC/SelectQueueByUser", | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(HpcACServer).SelectQueueByUser(ctx, req.(*QueueReq)) | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| func _HpcAC_QueryQueueDetails_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(QueueReq) | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| return srv.(HpcACServer).QueryQueueDetails(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: "/hpcAC.hpcAC/QueryQueueDetails", | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(HpcACServer).QueryQueueDetails(ctx, req.(*QueueReq)) | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| func _HpcAC_QueryUserQuotasLimit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | |||
| in := new(QueueReq) | |||
| if err := dec(in); err != nil { | |||
| return nil, err | |||
| } | |||
| if interceptor == nil { | |||
| return srv.(HpcACServer).QueryUserQuotasLimit(ctx, in) | |||
| } | |||
| info := &grpc.UnaryServerInfo{ | |||
| Server: srv, | |||
| FullMethod: "/hpcAC.hpcAC/QueryUserQuotasLimit", | |||
| } | |||
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { | |||
| return srv.(HpcACServer).QueryUserQuotasLimit(ctx, req.(*QueueReq)) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| } | |||
| return interceptor(ctx, in, info, handler) | |||
| } | |||
| @@ -284,12 +418,29 @@ var HpcAC_ServiceDesc = grpc.ServiceDesc{ | |||
| Handler: _HpcAC_ListJobManager_Handler, | |||
| }, | |||
| { | |||
| <<<<<<< HEAD | |||
| MethodName: "GetJobDetail", | |||
| Handler: _HpcAC_GetJobDetail_Handler, | |||
| }, | |||
| { | |||
| MethodName: "DeleteJob", | |||
| Handler: _HpcAC_DeleteJob_Handler, | |||
| ======= | |||
| MethodName: "FileContent", | |||
| Handler: _HpcAC_FileContent_Handler, | |||
| }, | |||
| { | |||
| MethodName: "SelectQueueByUser", | |||
| Handler: _HpcAC_SelectQueueByUser_Handler, | |||
| }, | |||
| { | |||
| MethodName: "QueryQueueDetails", | |||
| Handler: _HpcAC_QueryQueueDetails_Handler, | |||
| }, | |||
| { | |||
| MethodName: "QueryUserQuotasLimit", | |||
| Handler: _HpcAC_QueryUserQuotasLimit_Handler, | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| }, | |||
| }, | |||
| Streams: []grpc.StreamDesc{}, | |||
| @@ -13,6 +13,7 @@ import ( | |||
| ) | |||
| type ( | |||
| <<<<<<< HEAD | |||
| DeleteJobReq = hpcAC.DeleteJobReq | |||
| DeleteJobResp = hpcAC.DeleteJobResp | |||
| GetJobDetailResp = hpcAC.GetJobDetailResp | |||
| @@ -32,6 +33,30 @@ type ( | |||
| MapAppJobInfo = hpcAC.MapAppJobInfo | |||
| SubmitJobReq = hpcAC.SubmitJobReq | |||
| SubmitJobResp = hpcAC.SubmitJobResp | |||
| ======= | |||
| FileContentResp = hpcAC.FileContentResp | |||
| FileDataReq = hpcAC.FileDataReq | |||
| FileDataResp = hpcAC.FileDataResp | |||
| HistoryJob = hpcAC.HistoryJob | |||
| Job = hpcAC.Job | |||
| JobManager = hpcAC.JobManager | |||
| JobManagerReq = hpcAC.JobManagerReq | |||
| ListHistoryJobReq = hpcAC.ListHistoryJobReq | |||
| ListHistoryJobResp = hpcAC.ListHistoryJobResp | |||
| ListJobManagerResp = hpcAC.ListJobManagerResp | |||
| ListJobReq = hpcAC.ListJobReq | |||
| ListJobResp = hpcAC.ListJobResp | |||
| MapAppJobInfo = hpcAC.MapAppJobInfo | |||
| QueueData = hpcAC.QueueData | |||
| QueueDetailsData = hpcAC.QueueDetailsData | |||
| QueueDetailsResp = hpcAC.QueueDetailsResp | |||
| QueueReq = hpcAC.QueueReq | |||
| QueueResp = hpcAC.QueueResp | |||
| SubmitJobReq = hpcAC.SubmitJobReq | |||
| SubmitJobResp = hpcAC.SubmitJobResp | |||
| UserQuotasLimitData = hpcAC.UserQuotasLimitData | |||
| UserQuotasLimitResp = hpcAC.UserQuotasLimitResp | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| HpcAC interface { | |||
| // ListJob list all jobs | |||
| @@ -42,10 +67,21 @@ type ( | |||
| SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error) | |||
| // ListJobManager list all job managers | |||
| ListJobManager(ctx context.Context, in *JobManagerReq, opts ...grpc.CallOption) (*ListJobManagerResp, error) | |||
| <<<<<<< HEAD | |||
| // GetJobDetail get job detail | |||
| GetJobDetail(ctx context.Context, in *JobDetailReq, opts ...grpc.CallOption) (*GetJobDetailResp, error) | |||
| // DeleteJob delete job | |||
| DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...grpc.CallOption) (*DeleteJobResp, error) | |||
| ======= | |||
| // FileContent 查看文件内容 | |||
| FileContent(ctx context.Context, in *FileDataReq, opts ...grpc.CallOption) (*FileContentResp, error) | |||
| // SelectQueueByUser 查询用户可访问队列列表 | |||
| SelectQueueByUser(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueResp, error) | |||
| // QueryQueueDetails 查询队列资源详细信息 | |||
| QueryQueueDetails(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueDetailsResp, error) | |||
| // QueryUserQuotasLimit 查询用户资源限制信息 | |||
| QueryUserQuotasLimit(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*UserQuotasLimitResp, error) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| } | |||
| defaultHpcAC struct { | |||
| @@ -83,6 +119,7 @@ func (m *defaultHpcAC) ListJobManager(ctx context.Context, in *JobManagerReq, op | |||
| return client.ListJobManager(ctx, in, opts...) | |||
| } | |||
| <<<<<<< HEAD | |||
| // GetJobDetail get job detail | |||
| func (m *defaultHpcAC) GetJobDetail(ctx context.Context, in *JobDetailReq, opts ...grpc.CallOption) (*GetJobDetailResp, error) { | |||
| client := hpcAC.NewHpcACClient(m.cli.Conn()) | |||
| @@ -93,4 +130,28 @@ func (m *defaultHpcAC) GetJobDetail(ctx context.Context, in *JobDetailReq, opts | |||
| func (m *defaultHpcAC) DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...grpc.CallOption) (*DeleteJobResp, error) { | |||
| client := hpcAC.NewHpcACClient(m.cli.Conn()) | |||
| return client.DeleteJob(ctx, in, opts...) | |||
| ======= | |||
| // FileContent 查看文件内容 | |||
| func (m *defaultHpcAC) FileContent(ctx context.Context, in *FileDataReq, opts ...grpc.CallOption) (*FileContentResp, error) { | |||
| client := hpcAC.NewHpcACClient(m.cli.Conn()) | |||
| return client.FileContent(ctx, in, opts...) | |||
| } | |||
| // SelectQueueByUser 查询用户可访问队列列表 | |||
| func (m *defaultHpcAC) SelectQueueByUser(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueResp, error) { | |||
| client := hpcAC.NewHpcACClient(m.cli.Conn()) | |||
| return client.SelectQueueByUser(ctx, in, opts...) | |||
| } | |||
| // QueryQueueDetails 查询队列资源详细信息 | |||
| func (m *defaultHpcAC) QueryQueueDetails(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueDetailsResp, error) { | |||
| client := hpcAC.NewHpcACClient(m.cli.Conn()) | |||
| return client.QueryQueueDetails(ctx, in, opts...) | |||
| } | |||
| // QueryUserQuotasLimit 查询用户资源限制信息 | |||
| func (m *defaultHpcAC) QueryUserQuotasLimit(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*UserQuotasLimitResp, error) { | |||
| client := hpcAC.NewHpcACClient(m.cli.Conn()) | |||
| return client.QueryUserQuotasLimit(ctx, in, opts...) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| } | |||
| @@ -9,4 +9,5 @@ type ShuguangConf struct { | |||
| Password string `json:"Password"` | |||
| OrgId string `json:"OrgId"` | |||
| Layout string `json:"Layout"` | |||
| EndPoint string `json:"EndPoint"` | |||
| } | |||
| @@ -0,0 +1,43 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/util" | |||
| "PCM/common/tool/httpclient" | |||
| "context" | |||
| "strconv" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/svc" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type FileContentLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewFileContentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FileContentLogic { | |||
| return &FileContentLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| // FileContent 查看文件内容 | |||
| func (l *FileContentLogic) FileContent(in *hpcAC.FileDataReq) (*hpcAC.FileContentResp, error) { | |||
| var resp hpcAC.FileContentResp | |||
| url := "/hpc/openapi/v2/file/content" | |||
| triggerNum := strconv.FormatInt(int64(in.TriggerNum), 10) | |||
| queryParams := map[string]string{ | |||
| "hostName": in.HostName, | |||
| "dirPath": in.DirPath, | |||
| "triggerNum": triggerNum, | |||
| "rollDirection": in.RollDirection, | |||
| } | |||
| _, err := util.Post(&l.ctx, url, httpclient.ApplicationFromUrlencoded, nil, nil, nil, nil, &queryParams, &resp) | |||
| return &resp, err | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/svc" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/util" | |||
| "context" | |||
| "fmt" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type QueryQueueDetailsLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewQueryQueueDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryQueueDetailsLogic { | |||
| return &QueryQueueDetailsLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| // QueryQueueDetails 查询队列资源详细信息 | |||
| func (l *QueryQueueDetailsLogic) QueryQueueDetails(in *hpcAC.QueueReq) (*hpcAC.QueueDetailsResp, error) { | |||
| resp := hpcAC.QueueDetailsResp{} | |||
| url := fmt.Sprintf("/hpc/openapi/v2/userquotas/queues?strJobManagerID=%s", in.StrJobManagerID) | |||
| _, err := util.Get(&l.ctx, url, nil, nil, &resp) | |||
| return &resp, err | |||
| } | |||
| @@ -0,0 +1,35 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/util" | |||
| "context" | |||
| "fmt" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/svc" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type QueryUserQuotasLimitLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewQueryUserQuotasLimitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryUserQuotasLimitLogic { | |||
| return &QueryUserQuotasLimitLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| // QueryUserQuotasLimit 查询用户资源限制信息 | |||
| func (l *QueryUserQuotasLimitLogic) QueryUserQuotasLimit(in *hpcAC.QueueReq) (*hpcAC.UserQuotasLimitResp, error) { | |||
| resp := hpcAC.UserQuotasLimitResp{} | |||
| url := fmt.Sprintf("hpc/openapi/v2/userquotas/userlimit?strJobManagerID=%s", in.StrJobManagerID) | |||
| _, err := util.Get(&l.ctx, url, nil, nil, &resp) | |||
| return &resp, err | |||
| } | |||
| @@ -0,0 +1,35 @@ | |||
| package logic | |||
| import ( | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/util" | |||
| "context" | |||
| "fmt" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/svc" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| ) | |||
| type SelectQueueByUserLogic struct { | |||
| ctx context.Context | |||
| svcCtx *svc.ServiceContext | |||
| logx.Logger | |||
| } | |||
| func NewSelectQueueByUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SelectQueueByUserLogic { | |||
| return &SelectQueueByUserLogic{ | |||
| ctx: ctx, | |||
| svcCtx: svcCtx, | |||
| Logger: logx.WithContext(ctx), | |||
| } | |||
| } | |||
| // SelectQueueByUser 查询用户可访问队列列表 | |||
| func (l *SelectQueueByUserLogic) SelectQueueByUser(in *hpcAC.QueueReq) (*hpcAC.QueueResp, error) { | |||
| resp := hpcAC.QueueResp{} | |||
| url := fmt.Sprintf("/hpc/openapi/v2/queuenames/users/%s/?strJobManagerID=%s", in.User, in.StrJobManagerID) | |||
| _, err := util.Get(&l.ctx, url, nil, nil, &resp) | |||
| return &resp, err | |||
| } | |||
| @@ -46,6 +46,7 @@ func (s *HpcACServer) ListJobManager(ctx context.Context, in *hpcAC.JobManagerRe | |||
| return l.ListJobManager(in) | |||
| } | |||
| <<<<<<< HEAD | |||
| // GetJobDetail get job detail | |||
| func (s *HpcACServer) GetJobDetail(ctx context.Context, in *hpcAC.JobDetailReq) (*hpcAC.GetJobDetailResp, error) { | |||
| l := logic.NewGetJobDetailLogic(ctx, s.svcCtx) | |||
| @@ -56,4 +57,28 @@ func (s *HpcACServer) GetJobDetail(ctx context.Context, in *hpcAC.JobDetailReq) | |||
| func (s *HpcACServer) DeleteJob(ctx context.Context, in *hpcAC.DeleteJobReq) (*hpcAC.DeleteJobResp, error) { | |||
| l := logic.NewDeleteJobLogic(ctx, s.svcCtx) | |||
| return l.DeleteJob(in) | |||
| ======= | |||
| // FileContent 查看文件内容 | |||
| func (s *HpcACServer) FileContent(ctx context.Context, in *hpcAC.FileDataReq) (*hpcAC.FileContentResp, error) { | |||
| l := logic.NewFileContentLogic(ctx, s.svcCtx) | |||
| return l.FileContent(in) | |||
| } | |||
| // SelectQueueByUser 查询用户可访问队列列表 | |||
| func (s *HpcACServer) SelectQueueByUser(ctx context.Context, in *hpcAC.QueueReq) (*hpcAC.QueueResp, error) { | |||
| l := logic.NewSelectQueueByUserLogic(ctx, s.svcCtx) | |||
| return l.SelectQueueByUser(in) | |||
| } | |||
| // QueryQueueDetails 查询队列资源详细信息 | |||
| func (s *HpcACServer) QueryQueueDetails(ctx context.Context, in *hpcAC.QueueReq) (*hpcAC.QueueDetailsResp, error) { | |||
| l := logic.NewQueryQueueDetailsLogic(ctx, s.svcCtx) | |||
| return l.QueryQueueDetails(in) | |||
| } | |||
| // QueryUserQuotasLimit 查询用户资源限制信息 | |||
| func (s *HpcACServer) QueryUserQuotasLimit(ctx context.Context, in *hpcAC.QueueReq) (*hpcAC.UserQuotasLimitResp, error) { | |||
| l := logic.NewQueryUserQuotasLimitLogic(ctx, s.svcCtx) | |||
| return l.QueryUserQuotasLimit(in) | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| } | |||
| @@ -0,0 +1,168 @@ | |||
| package util | |||
| import ( | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/config" | |||
| "PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/svc" | |||
| "PCM/common/tool/httpclient" | |||
| "context" | |||
| "errors" | |||
| "github.com/go-resty/resty/v2" | |||
| "github.com/zeromicro/go-zero/core/conf" | |||
| "github.com/zeromicro/go-zero/core/logx" | |||
| "runtime" | |||
| ) | |||
| // NewRequest 构造一个请求 | |||
| func NewRequest(cli *resty.Client) (*resty.Request, error) { | |||
| //TODO 获取AC的token | |||
| var token string | |||
| if GetTokenState(Gtoken) { | |||
| token = Gtoken | |||
| } else { | |||
| token = GetToken() | |||
| Gtoken = token | |||
| } | |||
| cli.SetHeader("token", token).SetBaseURL(getBaseUrl()) | |||
| return cli.R(), nil | |||
| } | |||
| var baseUrl string | |||
| func getBaseUrl() string { | |||
| if len(baseUrl) > 0 { | |||
| return baseUrl | |||
| } | |||
| var cf config.Config | |||
| conf.MustLoad(*configFile, &cf) | |||
| ctx := svc.NewServiceContext(cf) | |||
| baseUrl := ctx.Config.ShuguangConf.EndPoint | |||
| return baseUrl | |||
| } | |||
| // Get 方法 | |||
| func Get(ctx *context.Context, url string, pathParams *map[string]string, queryParams *map[string]string, resultData interface{}) (*resty.Response, error) { | |||
| // 获取上层调用者PC,文件名,所在行 | |||
| funcName := GetCallFunc() | |||
| client := httpclient.NewHttpsClient() | |||
| req, err := NewRequest(client) | |||
| if err != nil { | |||
| logx.WithContext(*ctx).Errorf("AC", "Func: %s, Get Request URL : %s, Init Request Client err: %s", funcName, url, err.Error()) | |||
| return nil, err | |||
| } | |||
| req = req. | |||
| SetHeader(httpclient.ContentType, httpclient.ApplicationJson). | |||
| SetResult(resultData) | |||
| if pathParams != nil { | |||
| req.SetPathParams(*pathParams) | |||
| } | |||
| if queryParams != nil { | |||
| req.SetQueryParams(*queryParams) | |||
| } | |||
| result, err := req.Get(url) | |||
| return ResponseWithLog(funcName, req, result, err) | |||
| } | |||
| // Delete 方法 | |||
| func Delete(ctx *context.Context, url string, pathParams *map[string]string, body *string, resultData interface{}) (*resty.Response, error) { | |||
| // 获取上层调用者PC,文件名,所在行 | |||
| funcName := GetCallFunc() | |||
| client := httpclient.NewHttpsClient() | |||
| req, err := NewRequest(client) | |||
| if err != nil { | |||
| logx.WithContext(*ctx).Errorf("AC", "Func: %s, Delete Request URL : %s, Init Request Client err: %s", funcName, url, err.Error()) | |||
| return nil, err | |||
| } | |||
| req = req. | |||
| SetHeader(httpclient.ContentType, httpclient.ApplicationJson). | |||
| SetResult(resultData) | |||
| if body != nil { | |||
| req.SetBody(*body) | |||
| } | |||
| if pathParams != nil { | |||
| req.SetPathParams(*pathParams) | |||
| } | |||
| result, err := req.Delete(url) | |||
| return ResponseWithLog(funcName, req, result, err) | |||
| } | |||
| // Post | |||
| func Post(ctx *context.Context, url string, contentType string, | |||
| pathParams *map[string]string, fileParams *map[string]string, queryParams *map[string]string, | |||
| body *string, formData *map[string]string, resultData interface{}) (*resty.Response, error) { | |||
| // 获取上层调用者PC,文件名,所在行 | |||
| funcName := GetCallFunc() | |||
| client := httpclient.NewHttpsClient() | |||
| req, err := NewRequest(client) | |||
| if err != nil { | |||
| logx.WithContext(*ctx).Errorf("AC", "Func: %s, Post Request URL : %s, Init Request Client err: %s", funcName, url, err.Error()) | |||
| return nil, err | |||
| } | |||
| req = req. | |||
| SetHeader(httpclient.ContentType, contentType). | |||
| SetResult(resultData) | |||
| if body != nil { | |||
| req.SetBody(*body) | |||
| } | |||
| if pathParams != nil { | |||
| req.SetPathParams(*pathParams) | |||
| } | |||
| if fileParams != nil { | |||
| req.SetFiles(*fileParams) | |||
| } | |||
| if queryParams != nil { | |||
| req.SetQueryParams(*queryParams) | |||
| } | |||
| if formData != nil { | |||
| req.SetFormData(*formData) | |||
| } | |||
| result, err := req.Post(url) | |||
| return ResponseWithLog(funcName, req, result, err) | |||
| } | |||
| // 获取调用方法 | |||
| func GetCallFunc() string { | |||
| // 获取上层调用者PC,文件名,所在行 | |||
| var funcName string | |||
| pc, _, _, ok := runtime.Caller(2) | |||
| if !ok { | |||
| // 不ok,函数栈用尽了 | |||
| funcName = "-" | |||
| } else { | |||
| // 根据PC获取函数名 | |||
| funcName = runtime.FuncForPC(pc).Name() | |||
| } | |||
| return funcName | |||
| } | |||
| // 提取错误信息并记录日志 | |||
| func ResponseWithLog(funcName string, req *resty.Request, result *resty.Response, err error) (*resty.Response, error) { | |||
| // 请求错误 | |||
| if err != nil { | |||
| logx.WithContext(context.TODO()).Errorf("AC", "Func %s, URL %s, Request Error: %s", funcName, req.RawRequest.URL, err.Error()) | |||
| return result, err | |||
| } | |||
| // 接口报错 | |||
| if 200 != result.StatusCode() { | |||
| logx.WithContext(context.TODO()).Errorf("AC", "Func %s, URL %s, Response: %s", funcName, req.RawRequest.URL, string(result.Body())) | |||
| return result, errors.New("response StatusCode != 200") | |||
| } | |||
| logx.WithContext(context.TODO()).Debugf("AC", "Func %s, URL %s, Response: %s", funcName, req.RawRequest.URL, string(result.Body())) | |||
| return result, nil | |||
| } | |||
| @@ -7,8 +7,8 @@ option go_package = "/hpcAC"; | |||
| message JobManager{ | |||
| string job_manager_type = 1; // @gotags: copier:"JobManagerType", json:"JobManagerType" | |||
| string job_manager_addr = 2; // @gotags: copier:"JobManagerAddr", json:"JobManagerAddr" | |||
| int64 id = 3; // @gotags: copier:"ID", json:"id" | |||
| string text = 4; // @gotags: copier:"Text", json:"text" | |||
| int64 id = 3; // @gotags: copier:"ID", json:"id" | |||
| string text = 4; // @gotags: copier:"Text", json:"text" | |||
| string job_manager_port = 5; // @gotags: copier:"JobManagerPort", json:"JobManagerPort" | |||
| } | |||
| @@ -16,9 +16,9 @@ message JobManagerReq{ | |||
| } | |||
| message ListJobManagerResp{ | |||
| string code = 1; // @gotags: copier:"Code", json:"code" | |||
| string msg = 2; // @gotags: copier:"Msg", json:"msg" | |||
| repeated JobManager job_managers = 3; // @gotags: copier:"JobManagers", json:"data" | |||
| string code = 1; // @gotags: copier:"Code", json:"code" | |||
| string msg = 2; // @gotags: copier:"Msg", json:"msg" | |||
| repeated JobManager job_managers = 3; // @gotags: copier:"JobManagers", json:"data" | |||
| } | |||
| /******************Cluster End*************************/ | |||
| @@ -173,69 +173,69 @@ message DeleteJobResp{ | |||
| /******************Job Start*************************/ | |||
| message job{ | |||
| string job_id = 1; // @gotags: copier:"JobId" | |||
| string job_name = 2; // @gotags: copier:"Name" | |||
| string job_status = 3; // @gotags: copier:"JobState" | |||
| string queue = 4; // @gotags: copier:"Partition" | |||
| string user = 5; // @gotags: copier:"UserId" | |||
| string node_used = 6; // @gotags: copier:"ExcNodes" | |||
| int32 proc_num_used = 7; // @gotags: copier:"NumCpus" | |||
| string job_start_time = 8; // @gotags: copier:"StartTime" | |||
| string job_run_time = 9; // @gotags: copier:"JobRunTime" | |||
| string job_manager_id = 10; // @gotags: copier:"JobmanagerId" | |||
| string job_id = 1; // @gotags: copier:"JobId" | |||
| string job_name = 2; // @gotags: copier:"Name" | |||
| string job_status = 3; // @gotags: copier:"JobState" | |||
| string queue = 4; // @gotags: copier:"Partition" | |||
| string user = 5; // @gotags: copier:"UserId" | |||
| string node_used = 6; // @gotags: copier:"ExcNodes" | |||
| int32 proc_num_used = 7; // @gotags: copier:"NumCpus" | |||
| string job_start_time = 8; // @gotags: copier:"StartTime" | |||
| string job_run_time = 9; // @gotags: copier:"JobRunTime" | |||
| string job_manager_id = 10; // @gotags: copier:"JobmanagerId" | |||
| string job_manager_name = 11; // @gotags: copier:"JobmanagerName" | |||
| string job_manager_type = 12; // @gotags: copier:"JobmanagerType" | |||
| string error_path = 13; // @gotags: copier:"ErrorPath" | |||
| string output_path = 14; // @gotags: copier:"OutputPath" | |||
| string work_dir = 15; // @gotags: copier:"WorkDir" | |||
| string reason = 16; // @gotags: copier:"Reason" | |||
| string app_type = 17; // @gotags: copier:"AppType" | |||
| string error_path = 13; // @gotags: copier:"ErrorPath" | |||
| string output_path = 14; // @gotags: copier:"OutputPath" | |||
| string work_dir = 15; // @gotags: copier:"WorkDir" | |||
| string reason = 16; // @gotags: copier:"Reason" | |||
| string app_type = 17; // @gotags: copier:"AppType" | |||
| } | |||
| message ListJobReq{ | |||
| } | |||
| message ListJobResp{ | |||
| uint32 code = 1; // @gotags: copier:"Code" | |||
| string msg = 2; // @gotags: copier:"Msg" | |||
| 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" | |||
| repeated job jobs = 4; // @gotags: copier:"Jobs" | |||
| } | |||
| /******************Job End*************************/ | |||
| /******************History Job Start*************************/ | |||
| message historyJob{ | |||
| string acct_time = 1; // @gotags: copier:"AcctTime" | |||
| string app_type = 2; // @gotags: copier:"AppType" | |||
| string job_end_time = 3; // @gotags: copier:"End" | |||
| string job_exec_host = 4; // @gotags: copier:"Nodes" | |||
| int32 job_exit_status = 5; // @gotags: copier:"ExitCode" | |||
| int64 job_id = 6; // @gotags: copier:"JobId" | |||
| string job_name = 7; // @gotags: copier:"JobName" | |||
| string job_queue_time = 8; // @gotags: copier:"JobQueueTime" | |||
| string job_start_time = 9; // @gotags: copier:"Start" | |||
| string job_state = 10; // @gotags: copier:"State" | |||
| string acct_time = 1; // @gotags: copier:"AcctTime" | |||
| string app_type = 2; // @gotags: copier:"AppType" | |||
| string job_end_time = 3; // @gotags: copier:"End" | |||
| string job_exec_host = 4; // @gotags: copier:"Nodes" | |||
| int32 job_exit_status = 5; // @gotags: copier:"ExitCode" | |||
| int64 job_id = 6; // @gotags: copier:"JobId" | |||
| string job_name = 7; // @gotags: copier:"JobName" | |||
| string job_queue_time = 8; // @gotags: copier:"JobQueueTime" | |||
| string job_start_time = 9; // @gotags: copier:"Start" | |||
| string job_state = 10; // @gotags: copier:"State" | |||
| string job_walltime_used = 11; // @gotags: copier:"JobWalltimeUsed" | |||
| int64 job_manager_id = 12; // @gotags: copier:"JobManagerId" | |||
| int32 node_ct = 13; // @gotags: copier:"AllocNodes" | |||
| string queue = 14; // @gotags: copier:"Partition" | |||
| string user_name = 15; // @gotags: copier:"User" | |||
| string workdir = 16; // @gotags: copier:"WorkDir" | |||
| int64 job_manager_id = 12; // @gotags: copier:"JobManagerId" | |||
| int32 node_ct = 13; // @gotags: copier:"AllocNodes" | |||
| string queue = 14; // @gotags: copier:"Partition" | |||
| string user_name = 15; // @gotags: copier:"User" | |||
| string workdir = 16; // @gotags: copier:"WorkDir" | |||
| } | |||
| message ListHistoryJobReq{ | |||
| string startTime = 1;// @gotags: copier:"StartTime" | |||
| string endTime = 2;// @gotags: copier:"EndTime" | |||
| string timeType = 3;// @gotags: copier:"TimeType" | |||
| int32 start = 4;// @gotags: copier:"Start" | |||
| int32 limit = 5;// @gotags: copier:"Limit" | |||
| string startTime = 1;// @gotags: copier:"StartTime" | |||
| string endTime = 2;// @gotags: copier:"EndTime" | |||
| string timeType = 3;// @gotags: copier:"TimeType" | |||
| int32 start = 4;// @gotags: copier:"Start" | |||
| int32 limit = 5;// @gotags: copier:"Limit" | |||
| int32 isQueryByQueueTime = 6;// @gotags: copier:"IsQueryByQueueTime" | |||
| } | |||
| message ListHistoryJobResp{ | |||
| uint32 code = 1; // @gotags: copier:"Code" | |||
| string msg = 2; // @gotags: copier:"Msg" | |||
| 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" | |||
| } | |||
| @@ -277,6 +277,110 @@ message MapAppJobInfo{ | |||
| } | |||
| /******************Job(Submit) End*************************/ | |||
| message FileContentResp{ | |||
| string code = 1; // @gotags: copier:"Code" //状态码 示例:0 | |||
| string msg = 2; // @gotags: copier:"Msg" //信息 示例:success | |||
| FileDataResp data = 3; // @gotags: copier:"Data" //对象数据 | |||
| } | |||
| message FileDataReq{ | |||
| string hostName = 1; // @gotags: copier:"HostName" //服务器hostname 示例:127.0.0.1 | |||
| string dirPath = 2; // @gotags: copier:"DirPath" //服务器文件绝对路径 示例:/public/home/test/BASE/STDIN_1210_114429/std.out.22 | |||
| int32 triggerNum = 3; // @gotags: copier:"TriggerNum" //翻页次数,第一次打开传1,文件每超过1000行,该参数累加1(类似分页,每页显示1000行数据) 示例:1 | |||
| string rollDirection = 4; // @gotags: copier:"RollDirection" //文件查看方向,传参UP,从文件尾向上看;传参DOWN,从文件头向下看 示例:UP | |||
| } | |||
| message FileDataResp{ | |||
| int32 allLineTotal = 1; // @gotags: copier:"AllLineTotal" //文件总行数 示例:100 | |||
| string success = 2; // @gotags: copier:"Success" //请求是否成功 示例:true | |||
| int32 totalTriggerTimes = 3; // @gotags: copier:"TotalTriggerTimes" //总次数(类似分页总页数) 示例:1 | |||
| string errmsg = 4; // @gotags: copier:"Errmsg" //错误信息 示例:false | |||
| string data = 5; // @gotags: copier:"Data" //返回的文件内容 示例:start time is: 2021-10-14 | |||
| } | |||
| message QueueReq{ | |||
| string user = 1; // @gotags: copier:"User" //用户 示例:test | |||
| string strJobManagerID = 2; // @gotags: copier:"StrJobManagerID" //调度器ID 示例:1626190154 | |||
| } | |||
| message QueueResp{ | |||
| string code = 1; // @gotags: copier:"Code" //状态码 示例:0 | |||
| string msg = 2; // @gotags: copier:"Msg" //信息 示例:success | |||
| repeated QueueData data = 3; // @gotags: copier:"Data" //队列数组 | |||
| } | |||
| message QueueData{ | |||
| string aclHosts = 1; // @gotags: copier:"aclHosts" //可用节点,多个节点用逗号隔开 示例:node1,node2 | |||
| string id = 2; // @gotags: copier:"id" //队列名称 示例:debug | |||
| string text = 3; // @gotags: copier:"text" //队列名称 示例:debug | |||
| string queNodes = 4; // @gotags: copier:"queNodes" //队列节点总数 示例:3 | |||
| string queMinNodect = 5; // @gotags: copier:"queMinNodect" //队列最小节点数 示例:1 | |||
| string queMaxNgpus = 6; // @gotags: copier:"queMaxNgpus" //队列最大GPU卡数 示例:0 | |||
| string queMaxPPN = 7; // @gotags: copier:"queMaxPPN" //使用该队列作业最大CPU核心数 示例:4 | |||
| string queChargeRate = 8; // @gotags: copier:"queChargeRate" //费率 示例:1 | |||
| string queMaxNcpus = 9; // @gotags: copier:"queMaxNcpus" //用户最大可用核心数 示例:4 | |||
| string queMaxNdcus = 10; // @gotags: copier:"queMaxNdcus" //队列总DCU卡数 示例:0 | |||
| string queueName = 11; // @gotags: copier:"queueName" //队列名称 示例:debug | |||
| string queMinNcpus = 12; // @gotags: copier:"queMinNcpus" //队列最小CPU核数 示例:1 | |||
| string queFreeNodes = 13; // @gotags: copier:"queFreeNodes" //队列空闲节点数 示例:1 | |||
| string queMaxNodect = 14; // @gotags: copier:"queMaxNodect" //队列作业最大节点数 示例:1 | |||
| string queMaxGpuPN = 15; // @gotags: copier:"queMaxGpuPN" //队列单作业最大GPU卡数 示例:0 | |||
| string queMaxWalltime = 16; // @gotags: copier:"queMaxWalltime" //队列最大运行时间 示例:unlimit | |||
| string queMaxDcuPN = 17; // @gotags: copier:"queMaxDcuPN" //队列单作业最大DCU卡数 示例:0 | |||
| } | |||
| message QueueDetailsResp{ | |||
| string code = 1; // @gotags: copier:"Code" //状态码 示例:0 | |||
| string msg = 2; // @gotags: copier:"Msg" //信息 示例:success | |||
| repeated QueueDetailsData data = 3; // @gotags: copier:"Data" //队列数组 | |||
| } | |||
| message QueueDetailsData{ | |||
| int32 queNodes = 1; // @gotags: copier:"queNodes" //队列节点总数 示例:3 | |||
| int32 queMinNodect = 2; // @gotags: copier:"queMinNodect" //队列最小节点数 示例:1 | |||
| int32 queMaxNgpus = 3; // @gotags: copier:"queMaxNgpus" //队列最大GPU卡数 示例:0 | |||
| int32 queMaxPPN = 4; // @gotags: copier:"queMaxPPN" //使用该队列作业最大CPU核心数 示例:4 | |||
| float queChargeRate = 5; // @gotags: copier:"queChargeRate" //费率 示例:1 | |||
| int32 queMaxNcpus = 6; // @gotags: copier:"queMaxNcpus" //用户最大可用核心数 示例:4 | |||
| int32 queMaxNdcus = 7; // @gotags: copier:"queMaxNdcus" //队列总DCU卡数 示例:0 | |||
| string queueName = 8; // @gotags: copier:"queueName" //队列名称 示例:debug | |||
| int32 queMinNcpus = 9; // @gotags: copier:"queMinNcpus" //队列最小CPU核数 示例:1 | |||
| int32 queFreeNodes = 10; // @gotags: copier:"queFreeNodes" //队列空闲节点数 示例:1 | |||
| int32 queMaxNodect = 11; // @gotags: copier:"queMaxNodect" //队列作业最大节点数 示例:1 | |||
| int32 queMaxGpuPN = 12; // @gotags: copier:"queMaxGpuPN" //队列单作业最大GPU卡数 示例:0 | |||
| int32 queMaxWalltime = 13; // @gotags: copier:"queMaxWalltime" //队列最大运行时间 示例:unlimit | |||
| int32 queMaxDcuPN = 14; // @gotags: copier:"queMaxDcuPN" //队列单作业最大DCU卡数 示例:0 | |||
| } | |||
| message UserQuotasLimitResp{ | |||
| string code = 1; // @gotags: copier:"Code" //状态码 示例:0 | |||
| string msg = 2; // @gotags: copier:"Msg" //信息 示例:success | |||
| UserQuotasLimitData data = 3; // @gotags: copier:"Data" //队列数组 | |||
| } | |||
| message UserQuotasLimitData{ | |||
| string userName = 1; // @gotags: copier:"userName" //用户名称 | |||
| string accountName = 2; // @gotags: copier:"accountName" //用户所关联的默认的账号名 | |||
| int64 userMaxCpu = 3; // @gotags: copier:"userMaxCpu" //用户最大CPU核数,单位:个,如果未做限制,则值为-1 | |||
| int64 userMaxDcu = 4; // @gotags: copier:"userMaxDcu" //用户最大DCU卡数,单位:个,如果未做限制,则值为-1 | |||
| int64 userMaxGpu = 5; // @gotags: copier:"userMaxGpu" //用户最大GPU卡数,单位:个,如果未做限制,则值为-1 | |||
| int64 userMaxMlu = 6; // @gotags: copier:"userMaxMlu" //用户最大MLU卡数,单位:个,如果未做限制,则值为-1 | |||
| int64 userMaxMem = 7; // @gotags: copier:"userMaxMem" //用户最大内存,单位:m,如果未做限制,则值为-1 | |||
| int64 userMaxNode = 8; // @gotags: copier:"userMaxNode" //用户最大节点数,单位:个,如果未做限制,则值为-1 | |||
| int64 userMaxSubmitJob = 9; // @gotags: copier:"userMaxSubmitJob" //用户最大提交作业数,单位:个,如果未做限制,则值为-1 | |||
| int64 userMaxRunJob = 10; // @gotags: copier:"userMaxRunJob" //用户最大运行作业数,单位:个,如果未做限制,则值为-1 | |||
| int64 accountMaxCpu = 11; // @gotags: copier:"accountMaxCpu" //账户最大CPU核数,单位:个,如果未做限制,则值为-1 | |||
| int64 accountMaxDcu = 12; // @gotags: copier:"accountMaxDcu" //账户最大DCU卡数,单位:个,如果未做限制,则值为-1 | |||
| int64 accountMaxGpu = 13; // @gotags: copier:"accountMaxGpu" //账户最大GPU卡数,单位:个,如果未做限制,则值为-1 | |||
| int64 accountMaxMlu = 14; // @gotags: copier:"accountMaxMlu" //账户最大MLU卡数,单位:个,如果未做限制,则值为-1 | |||
| int64 accountMaxMem = 15; // @gotags: copier:"accountMaxMem" //账户最大内存,单位:m,如果未做限制,则值为-1 | |||
| int64 accountMaxNode = 16; // @gotags: copier:"accountMaxNode" //账户最大节点数,单位:个,如果未做限制,则值为-1 | |||
| int64 accountMaxSubmitJob = 17; // @gotags: copier:"accountMaxSubmitJob" //账户最大提交作业数,单位:个,如果未做限制,则值为-1 | |||
| int64 accountMaxRunJob = 18; // @gotags: copier:"accountMaxRunJob" //账户最大运行作业数,单位:个,如果未做限制,则值为-1 | |||
| int64 userMinCpu = 19; // @gotags: copier:"userMinCpu" //用户最小CPU核数,单位:个,如果未做限制,则值为-1 | |||
| int64 userMinNode = 20; // @gotags: copier:"userMinNode" //用户最小节点数,单位:个,如果未做限制,则值为-1 | |||
| int64 maxWallTime = 21; // @gotags: copier:"maxWallTime" //用户关联的glod账号的机时,机时单位:s,如果未做限制,则值为-1 | |||
| } | |||
| // HPC Services for AC | |||
| service hpcAC { | |||
| @@ -293,9 +397,23 @@ service hpcAC { | |||
| // ListJobManager list all job managers | |||
| rpc ListJobManager(JobManagerReq) returns (ListJobManagerResp); | |||
| <<<<<<< HEAD | |||
| // GetJobDetail get job detail | |||
| rpc GetJobDetail(JobDetailReq) returns (GetJobDetailResp); | |||
| // DeleteJob delete job | |||
| rpc DeleteJob(DeleteJobReq) returns (DeleteJobResp); | |||
| ======= | |||
| //FileContent 查看文件内容 | |||
| rpc FileContent(FileDataReq) returns (FileContentResp); | |||
| //SelectQueueByUser 查询用户可访问队列列表 | |||
| rpc SelectQueueByUser(QueueReq) returns(QueueResp); | |||
| //QueryQueueDetails 查询队列资源详细信息 | |||
| rpc QueryQueueDetails(QueueReq) returns(QueueDetailsResp); | |||
| ///QueryUserQuotasLimit 查询用户资源限制信息 | |||
| rpc QueryUserQuotasLimit(QueueReq) returns(UserQuotasLimitResp); | |||
| >>>>>>> ff7628a455a0eb264866e5bde762cd1c671eb8f3 | |||
| } | |||
| @@ -0,0 +1,54 @@ | |||
| package httpclient | |||
| import ( | |||
| "crypto/tls" | |||
| "github.com/go-resty/resty/v2" | |||
| "time" | |||
| ) | |||
| const ( | |||
| ContentType = "Content-Type" | |||
| ApplicationJson = "application/json" | |||
| MutipartFormData = "multipart/form-data; boundary=<calculated when request is sent>" | |||
| ApplicationFromUrlencoded = "application/x-www-from-urlencoded" | |||
| ) | |||
| var httpClient *resty.Client = nil | |||
| var httpsClient *resty.Client = nil | |||
| func NewHttpClient() *resty.Client { | |||
| if httpClient != nil { | |||
| return httpClient | |||
| } | |||
| httpClient = resty.New() | |||
| httpClient.SetTimeout(5 * time.Second) | |||
| httpClient.SetRetryCount(3) | |||
| //debug := config.GetConfig("httpclient.debug") | |||
| debug := "ture" | |||
| if len(debug) > 0 && debug == "ON" { | |||
| httpClient.SetDebug(true) | |||
| } | |||
| return httpClient | |||
| } | |||
| func NewHttpsClient() *resty.Client { | |||
| if httpsClient != nil { | |||
| return httpsClient | |||
| } | |||
| c := resty.New() | |||
| c.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) | |||
| c.SetTimeout(5 * time.Second) | |||
| c.SetRetryCount(3) | |||
| //debug := config.GetConfig("httpclient.debug") | |||
| debug := "ture" | |||
| if len(debug) > 0 && debug == "ON" { | |||
| c.SetDebug(true) | |||
| } | |||
| httpsClient = c | |||
| return c | |||
| } | |||
| @@ -4,7 +4,7 @@ go 1.19 | |||
| require ( | |||
| github.com/bitly/go-simplejson v0.5.0 | |||
| github.com/go-sql-driver/mysql v1.7.0 | |||
| github.com/go-resty/resty/v2 v2.7.0 | |||
| github.com/jinzhu/copier v0.3.5 | |||
| github.com/pkg/errors v0.9.1 | |||
| github.com/shopspring/decimal v1.3.1 | |||
| @@ -14,6 +14,7 @@ require ( | |||
| google.golang.org/protobuf v1.28.1 | |||
| gorm.io/driver/mysql v1.4.7 | |||
| gorm.io/gorm v1.24.5 | |||
| k8s.io/api v0.22.9 | |||
| sigs.k8s.io/yaml v1.2.0 | |||
| ) | |||
| @@ -31,6 +32,7 @@ require ( | |||
| github.com/go-logr/logr v1.2.3 // indirect | |||
| github.com/go-logr/stdr v1.2.2 // indirect | |||
| github.com/go-redis/redis/v8 v8.11.5 // indirect | |||
| github.com/go-sql-driver/mysql v1.7.0 // indirect | |||
| github.com/gogo/protobuf v1.3.2 // indirect | |||
| github.com/golang-jwt/jwt/v4 v4.4.3 // indirect | |||
| github.com/golang/mock v1.6.0 // indirect | |||
| @@ -84,7 +86,6 @@ require ( | |||
| gopkg.in/inf.v0 v0.9.1 // indirect | |||
| gopkg.in/yaml.v2 v2.4.0 // indirect | |||
| gopkg.in/yaml.v3 v3.0.1 // indirect | |||
| k8s.io/api v0.22.9 // indirect | |||
| k8s.io/apimachinery v0.22.9 // indirect | |||
| k8s.io/client-go v0.22.9 // indirect | |||
| k8s.io/klog/v2 v2.80.1 // indirect | |||
| @@ -371,6 +371,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 | |||
| github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= | |||
| github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= | |||
| github.com/ClickHouse/clickhouse-go/v2 v2.0.14/go.mod h1:iq2DUGgpA4BBki2CVwrF8x43zqBjdgHtbexkFkh5a6M= | |||
| github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= | |||
| github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= | |||
| github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= | |||
| github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= | |||
| @@ -489,6 +490,8 @@ github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL9 | |||
| github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= | |||
| github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= | |||
| github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= | |||
| github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= | |||
| github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= | |||
| github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= | |||
| github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= | |||
| github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= | |||
| @@ -967,6 +970,7 @@ golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT | |||
| golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |||
| golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |||
| golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |||
| golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |||
| golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |||
| golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |||
| golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= | |||