From 022f818735a7b3e44a9e74b21a8c8f7bffc57c6e Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 17 Aug 2023 11:06:43 +0300 Subject: [PATCH] [#20] Remove storage groups Signed-off-by: Evgenii Stratonikov --- storagegroup/convert.go | 59 ------------------------- storagegroup/grpc/types.go | 27 ------------ storagegroup/grpc/types.pb.go | Bin 8923 -> 0 bytes storagegroup/json.go | 14 ------ storagegroup/marshal.go | 54 ----------------------- storagegroup/message_test.go | 15 ------- storagegroup/test/generate.go | 21 --------- storagegroup/types.go | 79 ---------------------------------- 8 files changed, 269 deletions(-) delete mode 100644 storagegroup/convert.go delete mode 100644 storagegroup/grpc/types.go delete mode 100644 storagegroup/grpc/types.pb.go delete mode 100644 storagegroup/json.go delete mode 100644 storagegroup/marshal.go delete mode 100644 storagegroup/message_test.go delete mode 100644 storagegroup/test/generate.go delete mode 100644 storagegroup/types.go diff --git a/storagegroup/convert.go b/storagegroup/convert.go deleted file mode 100644 index 898d4932..00000000 --- a/storagegroup/convert.go +++ /dev/null @@ -1,59 +0,0 @@ -package storagegroup - -import ( - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs" - refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/grpc" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" - sg "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc" -) - -func (s *StorageGroup) ToGRPCMessage() grpc.Message { - m := new(sg.StorageGroup) - - if s != nil { - m = new(sg.StorageGroup) - - m.SetMembers(refs.ObjectIDListToGRPCMessage(s.members)) - //nolint:staticcheck - m.SetExpirationEpoch(s.exp) - m.SetValidationDataSize(s.size) - m.SetValidationHash(s.hash.ToGRPCMessage().(*refsGRPC.Checksum)) - } - - return m -} - -func (s *StorageGroup) FromGRPCMessage(m grpc.Message) error { - v, ok := m.(*sg.StorageGroup) - if !ok { - return message.NewUnexpectedMessageType(m, v) - } - - var err error - - hash := v.GetValidationHash() - if hash == nil { - s.hash = nil - } else { - if s.hash == nil { - s.hash = new(refs.Checksum) - } - - err = s.hash.FromGRPCMessage(hash) - if err != nil { - return err - } - } - - s.members, err = refs.ObjectIDListFromGRPCMessage(v.GetMembers()) - if err != nil { - return err - } - - //nolint:staticcheck - s.exp = v.GetExpirationEpoch() - s.size = v.GetValidationDataSize() - - return nil -} diff --git a/storagegroup/grpc/types.go b/storagegroup/grpc/types.go deleted file mode 100644 index 9be5c240..00000000 --- a/storagegroup/grpc/types.go +++ /dev/null @@ -1,27 +0,0 @@ -package storagegroup - -import ( - refs "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc" -) - -// SetValidationDataSize sets the total size of the payloads of the storage group. -func (m *StorageGroup) SetValidationDataSize(v uint64) { - m.ValidationDataSize = v -} - -// SetValidationHash sets total homomorphic hash of the storage group payloads. -func (m *StorageGroup) SetValidationHash(v *refs.Checksum) { - m.ValidationHash = v -} - -// SetExpirationEpoch sets number of the last epoch of the storage group lifetime. -// -// Deprecated: do not use, `expiration_epoch` field is deprecated in protocol. -func (m *StorageGroup) SetExpirationEpoch(v uint64) { - m.ExpirationEpoch = v -} - -// SetMembers sets list of the identifiers of the storage group members. -func (m *StorageGroup) SetMembers(v []*refs.ObjectID) { - m.Members = v -} diff --git a/storagegroup/grpc/types.pb.go b/storagegroup/grpc/types.pb.go deleted file mode 100644 index 75f5b46e7146728539bb93c07444537fd30323d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8923 zcmcIpZFAa468?;S#jHQ1AcbYX7;m`BRqfg&aaH_MwzHSJR0_*5V6BD3>V?3i{NL~C z?hzVc84g%tQKvz^Q+soW|aA}*mpZ^_YKV?Q5KJMUnOZ2ds97) zqinu6jpw7ibT!wB%PJjb?v3s-U0UWi{%jt_sj53Ql2AKSKXoT@l%$iy^}|WDcO7T? zD2TH0NAGse%E(^eBa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T}bK3+0oIoIy6fp(8QVu7A`$M!oi!n1-*MhD0HJ_X0N$2h3JwX5NZC&0!6AHt;QtYv4x86K4pEB}D5-9Z2+hHE$b{8G z+~w<14g?>k+T>uLZw!|tv62;G4x8+8s(X?^9v2FjaS03O>_D#bmCU02hJ5E~NvQ}Q za@-|D?OzF>Anu4;Y^)>WtmlA(1K+U{bl@cal&4+GErW*jNO;%Iu>p>n*zEEmlMg}j z_rk>n7+{Z8o8a(>2?&FIA|SUE1lbL;((Ie^ej)=e*idZD>=>K-thCGA>xsLvKlUXD z?2D;FGQo98($!*N*}a0Y_Yz(ag6_5uNpRShAu%&Y5FE0U*`!jh1fPUjDDXxQJZ7=A zS)`^)5fu0)H&XJpkhROkTBg{sFT!pU7BMMis(Ffp8&@PBxr@vqQD>z{C@Tyxl$G+p z;W9~3QF*~wi_wd`;c zYB|w*m4Qp@gwO|UrYqY@0w`Q!{;ZJ^f>N>NK$+U|2#2YiqEt!=uq zBwZX9Q^J4nR)jb@5P1x)_Z#P#rt;~wVUKZ*tR?uIi0^R=YUVE7jcxu9h*2f2jXZSnT7A0A>)NXYb~}HY zGSlrx)5W(bv!t`Rr1Z^-w2$?~%YwADj`}y4qCO=4;V*FtJvaG=MlEj8x!jDVGWL7s z2l#43{!@>GTjpddfVpy9#gywq`iQqrFPA_1x+ c^DZrX$)f_qm{JuyD-Oh}62*~15)aP*0GcrO4gdfE diff --git a/storagegroup/json.go b/storagegroup/json.go deleted file mode 100644 index b1228932..00000000 --- a/storagegroup/json.go +++ /dev/null @@ -1,14 +0,0 @@ -package storagegroup - -import ( - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" - storagegroup "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc" -) - -func (s *StorageGroup) MarshalJSON() ([]byte, error) { - return message.MarshalJSON(s) -} - -func (s *StorageGroup) UnmarshalJSON(data []byte) error { - return message.UnmarshalJSON(s, data, new(storagegroup.StorageGroup)) -} diff --git a/storagegroup/marshal.go b/storagegroup/marshal.go deleted file mode 100644 index 3f8171a9..00000000 --- a/storagegroup/marshal.go +++ /dev/null @@ -1,54 +0,0 @@ -package storagegroup - -import ( - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" - storagegroup "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto" -) - -const ( - sizeField = 1 - hashField = 2 - expirationField = 3 - objectIDsField = 4 -) - -// StableMarshal marshals unified storage group structure in a protobuf -// compatible way without field order shuffle. -func (s *StorageGroup) StableMarshal(buf []byte) []byte { - if s == nil { - return []byte{} - } - - if buf == nil { - buf = make([]byte, s.StableSize()) - } - - var offset int - - offset += proto.UInt64Marshal(sizeField, buf[offset:], s.size) - offset += proto.NestedStructureMarshal(hashField, buf[offset:], s.hash) - offset += proto.UInt64Marshal(expirationField, buf[offset:], s.exp) - refs.ObjectIDNestedListMarshal(objectIDsField, buf[offset:], s.members) - - return buf -} - -// StableSize of storage group structure marshalled by StableMarshal function. -func (s *StorageGroup) StableSize() (size int) { - if s == nil { - return 0 - } - - size += proto.UInt64Size(sizeField, s.size) - size += proto.NestedStructureSize(hashField, s.hash) - size += proto.UInt64Size(expirationField, s.exp) - size += refs.ObjectIDNestedListSize(objectIDsField, s.members) - - return size -} - -func (s *StorageGroup) Unmarshal(data []byte) error { - return message.Unmarshal(s, data, new(storagegroup.StorageGroup)) -} diff --git a/storagegroup/message_test.go b/storagegroup/message_test.go deleted file mode 100644 index e4ed3677..00000000 --- a/storagegroup/message_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package storagegroup_test - -import ( - "testing" - - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" - messagetest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message/test" - storagegrouptest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/test" -) - -func TestMessageConvert(t *testing.T) { - messagetest.TestRPCMessage(t, - func(empty bool) message.Message { return storagegrouptest.GenerateStorageGroup(empty) }, - ) -} diff --git a/storagegroup/test/generate.go b/storagegroup/test/generate.go deleted file mode 100644 index b53f199e..00000000 --- a/storagegroup/test/generate.go +++ /dev/null @@ -1,21 +0,0 @@ -package storagegrouptest - -import ( - refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup" -) - -func GenerateStorageGroup(empty bool) *storagegroup.StorageGroup { - m := new(storagegroup.StorageGroup) - - if !empty { - m.SetValidationDataSize(44) - //nolint:staticcheck - m.SetExpirationEpoch(55) - m.SetMembers(refstest.GenerateObjectIDs(false)) - } - - m.SetValidationHash(refstest.GenerateChecksum(empty)) - - return m -} diff --git a/storagegroup/types.go b/storagegroup/types.go deleted file mode 100644 index b5a3a5b4..00000000 --- a/storagegroup/types.go +++ /dev/null @@ -1,79 +0,0 @@ -package storagegroup - -import ( - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs" -) - -// StorageGroup is a unified structure of StorageGroup -// message from proto definition. -type StorageGroup struct { - size uint64 - - hash *refs.Checksum - - exp uint64 - - members []refs.ObjectID -} - -// GetValidationDataSize of unified storage group structure. -func (s *StorageGroup) GetValidationDataSize() uint64 { - if s != nil { - return s.size - } - - return 0 -} - -// SetValidationDataSize into unified storage group structure. -func (s *StorageGroup) SetValidationDataSize(v uint64) { - s.size = v -} - -// GetValidationHash of unified storage group structure. -func (s *StorageGroup) GetValidationHash() *refs.Checksum { - if s != nil { - return s.hash - } - - return nil -} - -// SetValidationHash into unified storage group structure. -func (s *StorageGroup) SetValidationHash(v *refs.Checksum) { - s.hash = v -} - -// GetExpirationEpoch of unified storage group structure. -// -// Deprecated: Do not use. -func (s *StorageGroup) GetExpirationEpoch() uint64 { - if s != nil { - return s.exp - } - - return 0 -} - -// SetExpirationEpoch into unified storage group structure. -// -// Deprecated: Do not use. -func (s *StorageGroup) SetExpirationEpoch(v uint64) { - s.exp = v -} - -// GetMembers of unified storage group structure. Members are objects of -// storage group. -func (s *StorageGroup) GetMembers() []refs.ObjectID { - if s != nil { - return s.members - } - - return nil -} - -// SetMembers into unified storage group structure. Members are objects of -// storage group. -func (s *StorageGroup) SetMembers(v []refs.ObjectID) { - s.members = v -}