fix:增加大屏数据代码到2.0分支

This commit is contained in:
qiwang 2023-04-24 19:47:09 +08:00
parent 5c81859ab0
commit ca851957cd
12 changed files with 216 additions and 114 deletions

View File

@ -13,12 +13,12 @@ type(
}
StorageScreenResp {
TotalSize uint32 `json:"totalSize" copier:"TotalSize"`
TotalSize int32 `json:"totalSize" copier:"TotalSize"`
AiCenterInfos []AiCenterInfos `json:"aiCenterInfos" copier:"AiCenterInfos"`
StorageUsed uint32 `json:"storageUsed" copier:"StorageUsed"`
StorageUsing uint32 `json:"storageUsing" copier:"StorageUsing"`
UsageRate uint32 `json:"usageRate" copier:"UsageRate"`
UsingRate uint32 `json:"usingRate" copier:"UsingRate"`
StorageUsed float32 `json:"storageUsed" copier:"StorageUsed"`
StorageUsing float32 `json:"storageUsing" copier:"StorageUsing"`
UsageRate float32 `json:"usageRate" copier:"UsageRate"`
UsingRate float32 `json:"usingRate" copier:"UsingRate"`
Code int32 `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
ErrorMsg string `json:"ErrorMsg,omitempty"`

View File

@ -1,7 +1,14 @@
package storage
import (
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/ceph"
"PCM/common/result"
"PCM/common/tool"
"PCM/common/xerr"
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/json"
"PCM/adaptor/PCM-CORE/api/internal/svc"
"PCM/adaptor/PCM-CORE/api/internal/types"
@ -25,6 +32,17 @@ func NewScreenStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Scr
func (l *ScreenStorageLogic) ScreenStorage(req *types.StorageScreenReq) (resp *types.StorageScreenResp, err error) {
// todo: add your logic here and delete this line
return
storageScreenReq := &ceph.StorageScreenReq{}
err = copier.CopyWithOption(storageScreenReq, req, copier.Option{Converters: tool.Converters})
StorageScreenResp, err := l.svcCtx.CephRpc.StorageScreen(l.ctx, storageScreenReq)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db storage list"), "Failed to get db storage list err : %v ,req:%+v", err, req)
}
marshal, err := json.Marshal(&StorageScreenResp)
if err != nil {
return nil, result.NewDefaultError(err.Error())
}
json.Unmarshal(marshal, &resp)
err = copier.CopyWithOption(&resp, &StorageScreenResp, copier.Option{Converters: tool.Converters})
return resp, nil
}

View File

@ -5,6 +5,7 @@ import (
"PCM/adaptor/PCM-CORE/api/internal/config"
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcacclient"
"PCM/adaptor/PCM-HPC/PCM-TH/rpc/hpcthclient"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/cephclient"
"github.com/go-redis/redis/v8"
"github.com/robfig/cron/v3"
"github.com/zeromicro/go-queue/kq"
@ -26,6 +27,7 @@ type ServiceContext struct {
ACRpc hpcacclient.HpcAC
THRpc hpcthclient.HpcTH
//OctopusRpc octopusclient.Octopus
CephRpc cephclient.Ceph
}
func NewServiceContext(c config.Config) *ServiceContext {

View File

@ -1827,12 +1827,12 @@ type StorageScreenReq struct {
}
type StorageScreenResp struct {
TotalSize uint32 `json:"totalSize" copier:"TotalSize"`
TotalSize int32 `json:"totalSize" copier:"TotalSize"`
AiCenterInfos []AiCenterInfos `json:"aiCenterInfos" copier:"AiCenterInfos"`
StorageUsed uint32 `json:"storageUsed" copier:"StorageUsed"`
StorageUsing uint32 `json:"storageUsing" copier:"StorageUsing"`
UsageRate uint32 `json:"usageRate" copier:"UsageRate"`
UsingRate uint32 `json:"usingRate" copier:"UsingRate"`
StorageUsed float32 `json:"storageUsed" copier:"StorageUsed"`
StorageUsing float32 `json:"storageUsing" copier:"StorageUsing"`
UsageRate float32 `json:"usageRate" copier:"UsageRate"`
UsingRate float32 `json:"usingRate" copier:"UsingRate"`
Code int32 `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
ErrorMsg string `json:"ErrorMsg,omitempty"`

View File

@ -64,28 +64,28 @@ type AiCenterInfos struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // @gotags: copier:"id"
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // @gotags: copier:"name"
Desc string `protobuf:"bytes,3,opt,name=desc,proto3" json:"desc,omitempty"` // @gotags: copier:"name"
Resource string `protobuf:"bytes,4,opt,name=resource,proto3" json:"resource,omitempty"`
TrainJob string `protobuf:"bytes,5,opt,name=trainJob,proto3" json:"trainJob,omitempty"`
ComputeScale int32 `protobuf:"varint,6,opt,name=computeScale,proto3" json:"computeScale,omitempty"`
StorageScale int32 `protobuf:"varint,7,opt,name=storageScale,proto3" json:"storageScale,omitempty"` // @gotags: copier:"storageScale"
Province string `protobuf:"bytes,8,opt,name=province,proto3" json:"province,omitempty"`
City string `protobuf:"bytes,9,opt,name=city,proto3" json:"city,omitempty"` // @gotags: copier:"city"
CoordinateX int32 `protobuf:"varint,10,opt,name=coordinateX,proto3" json:"coordinateX,omitempty"`
CoordinateY int32 `protobuf:"varint,11,opt,name=coordinateY,proto3" json:"coordinateY,omitempty"`
Type int32 `protobuf:"varint,12,opt,name=type,proto3" json:"type,omitempty"`
Weight int32 `protobuf:"varint,13,opt,name=weight,proto3" json:"weight,omitempty"`
ConnectionState int32 `protobuf:"varint,14,opt,name=connectionState,proto3" json:"connectionState,omitempty"` // @gotags: copier:"connectionState"
BusyState int32 `protobuf:"varint,15,opt,name=busyState,proto3" json:"busyState,omitempty"`
ImageUrl string `protobuf:"bytes,16,opt,name=imageUrl,proto3" json:"imageUrl,omitempty"`
AccDevices string `protobuf:"bytes,17,opt,name=accDevices,proto3" json:"accDevices,omitempty"`
MarketTime int64 `protobuf:"varint,18,opt,name=marketTime,proto3" json:"marketTime,omitempty"`
CreatedAt int64 `protobuf:"varint,19,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
AccessTime int32 `protobuf:"varint,20,opt,name=accessTime,proto3" json:"accessTime,omitempty"`
CardRunTime int32 `protobuf:"varint,21,opt,name=cardRunTime,proto3" json:"cardRunTime,omitempty"`
JobCount int32 `protobuf:"varint,22,opt,name=jobCount,proto3" json:"jobCount,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // @gotags: copier:"Id"
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // @gotags: copier:"Name"
Desc string `protobuf:"bytes,3,opt,name=desc,proto3" json:"desc,omitempty"` // @gotags: copier:"Desc"
Resource string `protobuf:"bytes,4,opt,name=resource,proto3" json:"resource,omitempty"` //@gotags: copier:"resource"
TrainJob string `protobuf:"bytes,5,opt,name=trainJob,proto3" json:"trainJob,omitempty"` //@gotags: copier:"TrainJob"
ComputeScale int32 `protobuf:"varint,6,opt,name=computeScale,proto3" json:"computeScale,omitempty"` //@gotags: copier:"ComputeScale"
StorageScale int32 `protobuf:"varint,7,opt,name=storageScale,proto3" json:"storageScale,omitempty"` //@gotags: copier:"StorageScale"
Province string `protobuf:"bytes,8,opt,name=province,proto3" json:"province,omitempty"` //@gotags: copier:"Province"
City string `protobuf:"bytes,9,opt,name=city,proto3" json:"city,omitempty"` //@gotags: copier:"City"
CoordinateX int32 `protobuf:"varint,10,opt,name=coordinateX,proto3" json:"coordinateX,omitempty"` //@gotags: copier:"CoordinateX"
CoordinateY int32 `protobuf:"varint,11,opt,name=coordinateY,proto3" json:"coordinateY,omitempty"` //@gotags: copier:"CoordinateY"
Type int32 `protobuf:"varint,12,opt,name=type,proto3" json:"type,omitempty"` //@gotags: copier:"Type"
Weight int32 `protobuf:"varint,13,opt,name=weight,proto3" json:"weight,omitempty"` //@gotags: copier:"Weight"
ConnectionState int32 `protobuf:"varint,14,opt,name=connectionState,proto3" json:"connectionState,omitempty"` //@gotags: copier:"ConnectionState"
BusyState int32 `protobuf:"varint,15,opt,name=busyState,proto3" json:"busyState,omitempty"` //@gotags: copier:"BusyState"
ImageUrl string `protobuf:"bytes,16,opt,name=imageUrl,proto3" json:"imageUrl,omitempty"` //@gotags: copier:"ImageUrl"
AccDevices string `protobuf:"bytes,17,opt,name=accDevices,proto3" json:"accDevices,omitempty"` //@gotags: copier:"AccDevices"
MarketTime int64 `protobuf:"varint,18,opt,name=marketTime,proto3" json:"marketTime,omitempty"` //@gotags: copier:"MarketTime"
CreatedAt int64 `protobuf:"varint,19,opt,name=createdAt,proto3" json:"createdAt,omitempty"` //@gotags: copier:"CreatedAt"
AccessTime int32 `protobuf:"varint,20,opt,name=accessTime,proto3" json:"accessTime,omitempty"` //@gotags: copier:"AccessTime"
CardRunTime int32 `protobuf:"varint,21,opt,name=cardRunTime,proto3" json:"cardRunTime,omitempty"` //@gotags: copier:"CardRunTime"
JobCount int32 `protobuf:"varint,22,opt,name=jobCount,proto3" json:"jobCount,omitempty"` //@gotags: copier:"JobCount"
}
func (x *AiCenterInfos) Reset() {
@ -279,12 +279,12 @@ type StorageScreenResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
TotalSize int32 `protobuf:"varint,1,opt,name=totalSize,proto3" json:"totalSize,omitempty"` // @gotags: copier:"totalSize"
AiCenterInfos []*AiCenterInfos `protobuf:"bytes,2,rep,name=aiCenterInfos,proto3" json:"aiCenterInfos,omitempty"` // @gotags: copier:"aiCenterInfos"
StorageUsed float32 `protobuf:"fixed32,3,opt,name=StorageUsed,proto3" json:"StorageUsed,omitempty"`
StorageUsing float32 `protobuf:"fixed32,4,opt,name=StorageUsing,proto3" json:"StorageUsing,omitempty"`
UsageRate float32 `protobuf:"fixed32,5,opt,name=UsageRate,proto3" json:"UsageRate,omitempty"`
UsingRate float32 `protobuf:"fixed32,6,opt,name=UsingRate,proto3" json:"UsingRate,omitempty"`
TotalSize int32 `protobuf:"varint,1,opt,name=totalSize,proto3" json:"totalSize,omitempty"` // @gotags: copier:"TotalSize"
AiCenterInfos []*AiCenterInfos `protobuf:"bytes,2,rep,name=aiCenterInfos,proto3" json:"aiCenterInfos,omitempty"` // @gotags: copier:"AiCenterInfos"
StorageUsed float32 `protobuf:"fixed32,3,opt,name=storageUsed,proto3" json:"storageUsed,omitempty"` // @gotags: copier:"StorageUsed"
StorageUsing float32 `protobuf:"fixed32,4,opt,name=storageUsing,proto3" json:"storageUsing,omitempty"` // @gotags: copier:"StorageUsing"
UsageRate float32 `protobuf:"fixed32,5,opt,name=usageRate,proto3" json:"usageRate,omitempty"` // @gotags: copier:"UsageRate"
UsingRate float32 `protobuf:"fixed32,6,opt,name=usingRate,proto3" json:"usingRate,omitempty"` // @gotags: copier:"UsingRate"
Code int32 `protobuf:"varint,7,opt,name=code,proto3" json:"code,omitempty"` // @gotags: copier:"Code"
Msg string `protobuf:"bytes,8,opt,name=msg,proto3" json:"msg,omitempty"` // @gotags: copier:"Msg"
ErrorMsg string `protobuf:"bytes,9,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"` // @gotags: copier:"ErrorMsg"
@ -438,15 +438,15 @@ var file_pcm_ceph_proto_rawDesc = []byte{
0x61, 0x69, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x02, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x41,
0x69, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x52, 0x0d, 0x61, 0x69,
0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x53,
0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x73,
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02,
0x52, 0x0b, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x65, 0x64, 0x12, 0x22, 0x0a,
0x0c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20,
0x01, 0x28, 0x02, 0x52, 0x0c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x69, 0x6e,
0x67, 0x12, 0x1c, 0x0a, 0x09, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x18, 0x05,
0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x12,
0x1c, 0x0a, 0x09, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x52, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01,
0x28, 0x02, 0x52, 0x09, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x52, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a,
0x52, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x65, 0x64, 0x12, 0x22, 0x0a,
0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20,
0x01, 0x28, 0x02, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x69, 0x6e,
0x67, 0x12, 0x1c, 0x0a, 0x09, 0x75, 0x73, 0x61, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x18, 0x05,
0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x75, 0x73, 0x61, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x12,
0x1c, 0x0a, 0x09, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x52, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01,
0x28, 0x02, 0x52, 0x09, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x52, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a,
0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64,
0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
0x6d, 0x73, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67,

View File

@ -1,10 +0,0 @@
Name: ceph.rpc
ListenOn: 0.0.0.0:2004
#Hosts:
# - 127.0.0.1:2379
#Key: octopus.rpc
#User: root
#Pass:
PengChengUrl: "http://grampus.openi.org.cn/openapi/v1/sharescreen/"

View File

@ -1,17 +1,15 @@
Name: pcmceph.rpc
ListenOn: 0.0.0.0:2005
Etcd:
Hosts:
- 10.101.15.170:31890
Key: pcmceph.rpc
User: root
Pass: I9wLvrRufj
#Hosts:
# - 127.0.0.1:2379
#Key: pcmceph.rpc
#User: root
#Pass:
ScreenUrl: "http://grampus.openi.org.cn/openapi/v1/sharescreen/"
NacosConfig:
DataId: pcm-ceph-rpc.yaml
Group: DEFAULT_GROUP
ServerConfigs:
# - IpAddr: 127.0.0.1
# Port: 8848
- IpAddr: 10.101.15.7
Port: 8848
ClientConfig:
NamespaceId: storage
TimeoutMs: 5000
NotLoadCacheAtStart: true
LogDir:
CacheDir:
LogLevel: debug

View File

@ -1,21 +1,52 @@
package config
import (
commonConfig "PCM/common/config"
"flag"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
zrpc.RpcServerConf
ScreenConfig
LogConf logx.LogConf
PcmCoreRpcConf zrpc.RpcClientConf
}
var configFile = flag.String("o", "adaptor/PCM-STORAGE/PCM-CEPH/rpc/etc/pcmceph.yaml", "the config file")
var Cfg = getConfig()
/*
func getConfig() Config {
var c Config
conf.MustLoad(*configFile, &c)
return c
}*/
func getConfig() Config {
var bootstrapConfig commonConfig.BootstrapConfig
conf.MustLoad(*configFile, &bootstrapConfig)
//解析业务配置
var c 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)
return c
}

View File

@ -96,9 +96,9 @@ func (l *StorageScreenLogic) StorageScreen(in *ceph.StorageScreenReq) (*ceph.Sto
StorageUsed = floatUsedStorageScale*1024 + 54.6
StorageUsing = floatUsingStorageScale*1024 + 54.6
resp.UsageRate = UsageRate
resp.UsageRate = UsingRate
resp.UsingRate = UsingRate
resp.StorageUsing = StorageUsing
resp.StorageUsing = StorageUsed
resp.StorageUsed = StorageUsed
resp.Code = 200
resp.Msg = "Success"
} else if statusCode != 200 {

View File

@ -1,13 +1,33 @@
package svc
import "PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/config"
import (
"PCM/adaptor/PCM-CORE/rpc/pcmcoreclient"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/config"
"github.com/robfig/cron/v3"
"github.com/zeromicro/go-zero/zrpc"
)
/*
type ServiceContext struct {
Config config.Config
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
}
}
*/
type ServiceContext struct {
Config config.Config
Config config.Config
Cron *cron.Cron
PcmCoreRpc pcmcoreclient.PcmCore
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
Config: c,
Cron: cron.New(cron.WithSeconds()),
PcmCoreRpc: pcmcoreclient.NewPcmCore(zrpc.MustNewClient(c.PcmCoreRpcConf)),
}
}

View File

@ -9,37 +9,37 @@ message StorageScreenReq{
}
message AiCenterInfos{
string id = 1; // @gotags: copier:"id"
string name = 2; // @gotags: copier:"name"
string desc = 3; // @gotags: copier:"name"
string resource = 4;
string trainJob = 5;
int32 computeScale = 6;
int32 storageScale = 7; // @gotags: copier:"storageScale"
string province =8;
string city = 9 ; // @gotags: copier:"city"
int32 coordinateX =10;
int32 coordinateY =11;
int32 type =12;
int32 weight =13;
int32 connectionState = 14; // @gotags: copier:"connectionState"
int32 busyState =15;
string imageUrl =16;
string accDevices =17;
int64 marketTime =18;
int64 createdAt =19;
int32 accessTime =20;
int32 cardRunTime =21;
int32 jobCount=22;
string id = 1; // @gotags: copier:"Id"
string name = 2; // @gotags: copier:"Name"
string desc = 3; // @gotags: copier:"Desc"
string resource = 4; //@gotags: copier:"resource"
string trainJob = 5; //@gotags: copier:"TrainJob"
int32 computeScale = 6; //@gotags: copier:"ComputeScale"
int32 storageScale = 7; //@gotags: copier:"StorageScale"
string province =8; //@gotags: copier:"Province"
string city = 9 ; //@gotags: copier:"City"
int32 coordinateX =10; //@gotags: copier:"CoordinateX"
int32 coordinateY =11; //@gotags: copier:"CoordinateY"
int32 type =12; //@gotags: copier:"Type"
int32 weight =13; //@gotags: copier:"Weight"
int32 connectionState = 14; //@gotags: copier:"ConnectionState"
int32 busyState =15; //@gotags: copier:"BusyState"
string imageUrl =16; //@gotags: copier:"ImageUrl"
string accDevices =17; //@gotags: copier:"AccDevices"
int64 marketTime =18; //@gotags: copier:"MarketTime"
int64 createdAt =19; //@gotags: copier:"CreatedAt"
int32 accessTime =20; //@gotags: copier:"AccessTime"
int32 cardRunTime =21; //@gotags: copier:"CardRunTime"
int32 jobCount=22; //@gotags: copier:"JobCount"
}
message StorageScreenResp{
int32 totalSize = 1; // @gotags: copier:"totalSize"
repeated AiCenterInfos aiCenterInfos = 2; // @gotags: copier:"aiCenterInfos"
float StorageUsed = 3;
float StorageUsing = 4;
float UsageRate =5;
float UsingRate =6;
int32 totalSize = 1; // @gotags: copier:"TotalSize"
repeated AiCenterInfos aiCenterInfos = 2; // @gotags: copier:"AiCenterInfos"
float storageUsed = 3; // @gotags: copier:"StorageUsed"
float storageUsing = 4; // @gotags: copier:"StorageUsing"
float usageRate =5; // @gotags: copier:"UsageRate"
float usingRate =6; // @gotags: copier:"UsingRate"
int32 code = 7; // @gotags: copier:"Code"
string msg = 8; // @gotags: copier:"Msg"
string error_msg =9;// @gotags: copier:"ErrorMsg"

View File

@ -1,15 +1,15 @@
package main
import (
"flag"
"fmt"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/ceph"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/config"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/server"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/svc"
commonConfig "PCM/common/config"
"PCM/common/interceptor/rpcserver"
"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"
"google.golang.org/grpc"
@ -21,9 +21,52 @@ var configFile = flag.String("f", "adaptor/PCM-STORAGE/PCM-CEPH/rpc/etc/pcmceph.
func main() {
flag.Parse()
var bootstrapConfig commonConfig.BootstrapConfig
//conf.MustLoad(*configFile, &c)
conf.MustLoad(*configFile, &bootstrapConfig)
//解析业务配置
var c config.Config
conf.MustLoad(*configFile, &c)
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)
//ctx.Cron.Start()
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
ceph.RegisterCephServer(grpcServer, server.NewCephServer(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()
/*ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
ceph.RegisterCephServer(grpcServer, server.NewCephServer(ctx))
@ -35,5 +78,5 @@ func main() {
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
s.Start()*/
}