[#20] Remove storage groups
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
d989c8d2a3
commit
022f818735
8 changed files with 0 additions and 269 deletions
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
BIN
storagegroup/grpc/types.pb.go
generated
BIN
storagegroup/grpc/types.pb.go
generated
Binary file not shown.
|
@ -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))
|
||||
}
|
|
@ -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))
|
||||
}
|
|
@ -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) },
|
||||
)
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue