Browse Source

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

pull/9/head
qiwang 2 years ago
parent
commit
5bb8fdb0f9
6 changed files with 219 additions and 55 deletions
  1. +148
    -44
      adaptor/PCM-STORAGE/PCM-CEPH/rpc/ceph/pcm-ceph.pb.go
  2. +1
    -0
      adaptor/PCM-STORAGE/PCM-CEPH/rpc/cephclient/ceph.go
  3. +41
    -4
      adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/storagescreenlogic.go
  4. +14
    -6
      adaptor/PCM-STORAGE/PCM-CEPH/rpc/pb/pcm-ceph.proto
  5. +1
    -1
      adaptor/PCM-STORAGE/PCM-CEPH/rpc/pcmceph.go
  6. +14
    -0
      common/tool/http.go

+ 148
- 44
adaptor/PCM-STORAGE/PCM-CEPH/rpc/ceph/pcm-ceph.pb.go View File

@@ -64,8 +64,8 @@ type StorageArg struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields


StorageScale string `protobuf:"bytes,1,opt,name=storageScale,proto3" json:"storageScale,omitempty"` // @gotags: copier:"storageScale"
ConnectionState string `protobuf:"bytes,2,opt,name=connectionState,proto3" json:"connectionState,omitempty"` // @gotags: copier:"connectionState"
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"
} }


func (x *StorageArg) Reset() { func (x *StorageArg) Reset() {
@@ -100,17 +100,96 @@ func (*StorageArg) Descriptor() ([]byte, []int) {
return file_pcm_ceph_proto_rawDescGZIP(), []int{1} return file_pcm_ceph_proto_rawDescGZIP(), []int{1}
} }


func (x *StorageArg) GetStorageScale() string {
func (x *StorageArg) GetTotalSize() int32 {
if x != nil {
return x.TotalSize
}
return 0
}

func (x *StorageArg) GetAiCenterInfos() []*AiCenterInfos {
if x != nil {
return x.AiCenterInfos
}
return nil
}

type AiCenterInfos struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields

StorageScale int32 `protobuf:"varint,1,opt,name=storageScale,proto3" json:"storageScale,omitempty"` // @gotags: copier:"storageScale"
ConnectionState int32 `protobuf:"varint,2,opt,name=connectionState,proto3" json:"connectionState,omitempty"` // @gotags: copier:"connectionState"
Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` // @gotags: copier:"id"
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` // @gotags: copier:"name"
City string `protobuf:"bytes,5,opt,name=city,proto3" json:"city,omitempty"` // @gotags: copier:"city"
}

func (x *AiCenterInfos) Reset() {
*x = AiCenterInfos{}
if protoimpl.UnsafeEnabled {
mi := &file_pcm_ceph_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}

func (x *AiCenterInfos) String() string {
return protoimpl.X.MessageStringOf(x)
}

func (*AiCenterInfos) ProtoMessage() {}

func (x *AiCenterInfos) ProtoReflect() protoreflect.Message {
mi := &file_pcm_ceph_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}

// Deprecated: Use AiCenterInfos.ProtoReflect.Descriptor instead.
func (*AiCenterInfos) Descriptor() ([]byte, []int) {
return file_pcm_ceph_proto_rawDescGZIP(), []int{2}
}

func (x *AiCenterInfos) GetStorageScale() int32 {
if x != nil { if x != nil {
return x.StorageScale return x.StorageScale
} }
return ""
return 0
} }


func (x *StorageArg) GetConnectionState() string {
func (x *AiCenterInfos) GetConnectionState() int32 {
if x != nil { if x != nil {
return x.ConnectionState return x.ConnectionState
} }
return 0
}

func (x *AiCenterInfos) GetId() string {
if x != nil {
return x.Id
}
return ""
}

func (x *AiCenterInfos) GetName() string {
if x != nil {
return x.Name
}
return ""
}

func (x *AiCenterInfos) GetCity() string {
if x != nil {
return x.City
}
return "" return ""
} }


@@ -119,7 +198,7 @@ type StorageScreenResp struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields


StorageArg *StorageArg `protobuf:"bytes,1,opt,name=storageArg,proto3" json:"storageArg,omitempty"` // @gotags: copier:"Datasets"
StorageArg *StorageArg `protobuf:"bytes,1,opt,name=storageArg,proto3" json:"storageArg,omitempty"` // @gotags: copier:"StorageArg"
Code int32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"` // @gotags: copier:"Code" Code int32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"` // @gotags: copier:"Code"
Msg string `protobuf:"bytes,3,opt,name=msg,proto3" json:"msg,omitempty"` // @gotags: copier:"Msg" Msg string `protobuf:"bytes,3,opt,name=msg,proto3" json:"msg,omitempty"` // @gotags: copier:"Msg"
ErrorMsg string `protobuf:"bytes,4,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"` // @gotags: copier:"ErrorMsg" ErrorMsg string `protobuf:"bytes,4,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"` // @gotags: copier:"ErrorMsg"
@@ -128,7 +207,7 @@ type StorageScreenResp struct {
func (x *StorageScreenResp) Reset() { func (x *StorageScreenResp) Reset() {
*x = StorageScreenResp{} *x = StorageScreenResp{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_pcm_ceph_proto_msgTypes[2]
mi := &file_pcm_ceph_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -141,7 +220,7 @@ func (x *StorageScreenResp) String() string {
func (*StorageScreenResp) ProtoMessage() {} func (*StorageScreenResp) ProtoMessage() {}


func (x *StorageScreenResp) ProtoReflect() protoreflect.Message { func (x *StorageScreenResp) ProtoReflect() protoreflect.Message {
mi := &file_pcm_ceph_proto_msgTypes[2]
mi := &file_pcm_ceph_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -154,7 +233,7 @@ func (x *StorageScreenResp) ProtoReflect() protoreflect.Message {


// Deprecated: Use StorageScreenResp.ProtoReflect.Descriptor instead. // Deprecated: Use StorageScreenResp.ProtoReflect.Descriptor instead.
func (*StorageScreenResp) Descriptor() ([]byte, []int) { func (*StorageScreenResp) Descriptor() ([]byte, []int) {
return file_pcm_ceph_proto_rawDescGZIP(), []int{2}
return file_pcm_ceph_proto_rawDescGZIP(), []int{3}
} }


func (x *StorageScreenResp) GetStorageArg() *StorageArg { func (x *StorageScreenResp) GetStorageArg() *StorageArg {
@@ -189,29 +268,40 @@ var File_pcm_ceph_proto protoreflect.FileDescriptor


var file_pcm_ceph_proto_rawDesc = []byte{ var file_pcm_ceph_proto_rawDesc = []byte{
0x0a, 0x0e, 0x70, 0x63, 0x6d, 0x2d, 0x63, 0x65, 0x70, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x0a, 0x0e, 0x70, 0x63, 0x6d, 0x2d, 0x63, 0x65, 0x70, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x22, 0x12, 0x0a, 0x10, 0x73, 0x74,
0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x22, 0x5a,
0x0a, 0x0a, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x12, 0x22, 0x0a, 0x0c,
0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x61, 0x6c, 0x65,
0x12, 0x28, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74,
0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x8c, 0x01, 0x0a, 0x11, 0x73,
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70,
0x12, 0x34, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e,
0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x72,
0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73,
0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x1b, 0x0a, 0x09,
0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x32, 0x50, 0x0a, 0x04, 0x43, 0x65, 0x70,
0x68, 0x12, 0x48, 0x0a, 0x0d, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65,
0x65, 0x6e, 0x12, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x73, 0x74,
0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1b,
0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67,
0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x42, 0x07, 0x5a, 0x05, 0x2f,
0x63, 0x65, 0x70, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x12, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x22, 0x12, 0x0a, 0x10, 0x53, 0x74,
0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x22, 0x69,
0x0a, 0x0a, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x12, 0x1c, 0x0a, 0x09,
0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x3d, 0x0a, 0x0d, 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, 0x22, 0x95, 0x01, 0x0a, 0x0d, 0x41, 0x69,
0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73,
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x05, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x12,
0x28, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61,
0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a,
0x04, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x74,
0x79, 0x22, 0x8c, 0x01, 0x0a, 0x11, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72,
0x65, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x34, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x72, 0x61,
0x67, 0x65, 0x41, 0x72, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x74, 0x65,
0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x72,
0x67, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x12, 0x12, 0x0a,
0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64,
0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
0x6d, 0x73, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67,
0x32, 0x50, 0x0a, 0x04, 0x43, 0x65, 0x70, 0x68, 0x12, 0x48, 0x0a, 0x0d, 0x73, 0x74, 0x6f, 0x72,
0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x12, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70,
0x6c, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65,
0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65,
0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65,
0x73, 0x70, 0x42, 0x07, 0x5a, 0x05, 0x2f, 0x63, 0x65, 0x70, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
} }


var ( var (
@@ -226,21 +316,23 @@ func file_pcm_ceph_proto_rawDescGZIP() []byte {
return file_pcm_ceph_proto_rawDescData return file_pcm_ceph_proto_rawDescData
} }


var file_pcm_ceph_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_pcm_ceph_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_pcm_ceph_proto_goTypes = []interface{}{ var file_pcm_ceph_proto_goTypes = []interface{}{
(*StorageScreenReq)(nil), // 0: template.storageScreenReq
(*StorageScreenReq)(nil), // 0: template.StorageScreenReq
(*StorageArg)(nil), // 1: template.StorageArg (*StorageArg)(nil), // 1: template.StorageArg
(*StorageScreenResp)(nil), // 2: template.storageScreenResp
(*AiCenterInfos)(nil), // 2: template.AiCenterInfos
(*StorageScreenResp)(nil), // 3: template.StorageScreenResp
} }
var file_pcm_ceph_proto_depIdxs = []int32{ var file_pcm_ceph_proto_depIdxs = []int32{
1, // 0: template.storageScreenResp.storageArg:type_name -> template.StorageArg
0, // 1: template.Ceph.storageScreen:input_type -> template.storageScreenReq
2, // 2: template.Ceph.storageScreen:output_type -> template.storageScreenResp
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
2, // 0: template.StorageArg.aiCenterInfos:type_name -> template.AiCenterInfos
1, // 1: template.StorageScreenResp.storageArg:type_name -> template.StorageArg
0, // 2: template.Ceph.storageScreen:input_type -> template.StorageScreenReq
3, // 3: template.Ceph.storageScreen:output_type -> template.StorageScreenResp
3, // [3:4] is the sub-list for method output_type
2, // [2:3] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
} }


func init() { file_pcm_ceph_proto_init() } func init() { file_pcm_ceph_proto_init() }
@@ -274,6 +366,18 @@ func file_pcm_ceph_proto_init() {
} }
} }
file_pcm_ceph_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_pcm_ceph_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AiCenterInfos); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pcm_ceph_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StorageScreenResp); i { switch v := v.(*StorageScreenResp); i {
case 0: case 0:
return &v.state return &v.state
@@ -292,7 +396,7 @@ func file_pcm_ceph_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pcm_ceph_proto_rawDesc, RawDescriptor: file_pcm_ceph_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 3,
NumMessages: 4,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },


+ 1
- 0
adaptor/PCM-STORAGE/PCM-CEPH/rpc/cephclient/ceph.go View File

@@ -13,6 +13,7 @@ import (
) )


type ( type (
AiCenterInfos = ceph.AiCenterInfos
StorageArg = ceph.StorageArg StorageArg = ceph.StorageArg
StorageScreenReq = ceph.StorageScreenReq StorageScreenReq = ceph.StorageScreenReq
StorageScreenResp = ceph.StorageScreenResp StorageScreenResp = ceph.StorageScreenResp


+ 41
- 4
adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/storagescreenlogic.go View File

@@ -4,6 +4,7 @@ import (
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/config" "PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/config"
"PCM/common/tool" "PCM/common/tool"
"context" "context"
"fmt"
"k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/json"
"strings" "strings"


@@ -19,6 +20,35 @@ type StorageScreenLogic struct {
logx.Logger logx.Logger
} }


type StorageArg struct {
totalSize int32
aiCenterInfos []AiCenterInfos
}

type AiCenterInfos struct {
id string
name string
desc string
resource string
trainJob string
computeScale int32
storageScale int32
province string
city string
coordinateX int32
coordinateY int32
weight int32
connectionState int32
busyState int32
imageUrl string
accDevices string
marketTime int64
createdAt int64
accessTime int32
cardRunTime int32
jobCount int32
}

func NewStorageScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StorageScreenLogic { func NewStorageScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StorageScreenLogic {
return &StorageScreenLogic{ return &StorageScreenLogic{
ctx: ctx, ctx: ctx,
@@ -31,15 +61,23 @@ func NewStorageScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sto
func (l *StorageScreenLogic) StorageScreen(in *ceph.StorageScreenReq) (*ceph.StorageScreenResp, error) { func (l *StorageScreenLogic) StorageScreen(in *ceph.StorageScreenReq) (*ceph.StorageScreenResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
var resp ceph.StorageScreenResp var resp ceph.StorageScreenResp
var storageArg StorageArg
screenConfig := config.Cfg screenConfig := config.Cfg
screenUrl := screenConfig.ScreenConfig.ScreenUrl screenUrl := screenConfig.ScreenConfig.ScreenUrl
token := ""
statusCode, body, err := tool.HttpClientWithBodyAndCode(tool.GET, screenUrl, strings.NewReader(``), token)
statusCode, body, err := tool.HttpClientWithScreen(tool.GET, screenUrl+"aicenter?sortBy=weight&orderBy=asc", strings.NewReader(``))
if err != nil { if err != nil {
return nil, err return nil, err
} }
if statusCode == 200 { if statusCode == 200 {
json.Unmarshal(body, &resp)
err := json.Unmarshal([]byte(body), &storageArg)
if err == nil {
fmt.Println(storageArg.totalSize)
fmt.Println(storageArg.aiCenterInfos)
} else {
fmt.Println(storageArg.aiCenterInfos)

}
//json.Unmarshal(body, &resp)
resp.Code = 200 resp.Code = 200
resp.Msg = "Success" resp.Msg = "Success"
} else if statusCode != 200 { } else if statusCode != 200 {
@@ -47,6 +85,5 @@ func (l *StorageScreenLogic) StorageScreen(in *ceph.StorageScreenReq) (*ceph.Sto
resp.Code = 400 resp.Code = 400
resp.Msg = "Failure" resp.Msg = "Failure"
} }

return &ceph.StorageScreenResp{}, nil return &ceph.StorageScreenResp{}, nil
} }

+ 14
- 6
adaptor/PCM-STORAGE/PCM-CEPH/rpc/pb/pcm-ceph.proto View File

@@ -4,17 +4,25 @@ package template;
option go_package = "/ceph"; option go_package = "/ceph";


/******************auth Start*************************/ /******************auth Start*************************/
message storageScreenReq{
message StorageScreenReq{


} }


message StorageArg{ message StorageArg{
string storageScale = 1; // @gotags: copier:"storageScale"
string connectionState = 2; // @gotags: copier:"connectionState"
int32 totalSize = 1; // @gotags: copier:"totalSize"
repeated AiCenterInfos aiCenterInfos = 2; // @gotags: copier:"aiCenterInfos"
} }


message storageScreenResp{
StorageArg storageArg =1; // @gotags: copier:"Datasets"
message AiCenterInfos{
int32 storageScale = 1; // @gotags: copier:"storageScale"
int32 connectionState = 2; // @gotags: copier:"connectionState"
string id = 3; // @gotags: copier:"id"
string name = 4; // @gotags: copier:"name"
string city = 5 ; // @gotags: copier:"city"
}

message StorageScreenResp{
StorageArg storageArg =1; // @gotags: copier:"StorageArg"
int32 code = 2; // @gotags: copier:"Code" int32 code = 2; // @gotags: copier:"Code"
string msg = 3; // @gotags: copier:"Msg" string msg = 3; // @gotags: copier:"Msg"
string error_msg =4;// @gotags: copier:"ErrorMsg" string error_msg =4;// @gotags: copier:"ErrorMsg"
@@ -22,5 +30,5 @@ message storageScreenResp{


service Ceph { service Ceph {


rpc storageScreen(storageScreenReq) returns (storageScreenResp);
rpc storageScreen(StorageScreenReq) returns (StorageScreenResp);
} }

+ 1
- 1
adaptor/PCM-STORAGE/PCM-CEPH/rpc/pcmceph.go View File

@@ -26,7 +26,7 @@ func main() {
ctx := svc.NewServiceContext(c) ctx := svc.NewServiceContext(c)


s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
ceph.RegisterModelArtsServer(grpcServer, server.NewModelArtsServer(ctx))
ceph.RegisterCephServer(grpcServer, server.NewCephServer(ctx))


if c.Mode == service.DevMode || c.Mode == service.TestMode { if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer) reflection.Register(grpcServer)


+ 14
- 0
common/tool/http.go View File

@@ -175,3 +175,17 @@ func HttpClientWithBodyAndCode(method string, url string, payload io.Reader, tok


return res.StatusCode, body, err return res.StatusCode, body, err
} }

func HttpClientWithScreen(method string, url string, payload io.Reader) (int, []byte, error) {
request, err := http.NewRequest(method, url, payload)

client := &http.Client{}
res, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)

return res.StatusCode, body, err
}

Loading…
Cancel
Save