From c0cc4a4374a6747303a65395760adbd60cd14df9 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 8 Sep 2020 13:19:22 +0300 Subject: [PATCH] [#138] v2/netmap: Update to neofs-api jindo release Signed-off-by: Alex Vanin --- v2/netmap/convert.go | 10 +++ v2/netmap/grpc/types.go | 7 ++ v2/netmap/grpc/types.pb.go | 166 +++++++++++++++++++++++++++---------- v2/netmap/marshal.go | 13 ++- v2/netmap/marshal_test.go | 1 + v2/netmap/types.go | 24 ++++++ 6 files changed, 173 insertions(+), 48 deletions(-) diff --git a/v2/netmap/convert.go b/v2/netmap/convert.go index caf7e33..e08d17c 100644 --- a/v2/netmap/convert.go +++ b/v2/netmap/convert.go @@ -54,6 +54,7 @@ func SelectorToGRPCMessage(s *Selector) *netmap.Selector { m.SetName(s.GetName()) m.SetCount(s.GetCount()) + m.SetClause(ClauseToGRPCMessage(s.GetClause())) m.SetFilter(s.GetFilter()) m.SetAttribute(s.GetAttribute()) @@ -69,6 +70,7 @@ func SelectorFromGRPCMessage(m *netmap.Selector) *Selector { s.SetName(m.GetName()) s.SetCount(m.GetCount()) + s.SetClause(ClauseFromGRPCMessage(m.GetClause())) s.SetFilter(m.GetFilter()) s.SetAttribute(m.GetAttribute()) @@ -160,6 +162,14 @@ func PlacementPolicyFromGRPCMessage(m *netmap.PlacementPolicy) *PlacementPolicy return p } +func ClauseToGRPCMessage(n Clause) netmap.Clause { + return netmap.Clause(n) +} + +func ClauseFromGRPCMessage(n netmap.Clause) Clause { + return Clause(n) +} + func OperationToGRPCMessage(n Operation) netmap.Operation { return netmap.Operation(n) } diff --git a/v2/netmap/grpc/types.go b/v2/netmap/grpc/types.go index a912cb2..e478d98 100644 --- a/v2/netmap/grpc/types.go +++ b/v2/netmap/grpc/types.go @@ -92,6 +92,13 @@ func (m *Selector) SetFilter(v string) { } } +// SetClause of placement selector. +func (m *Selector) SetClause(v Clause) { + if m != nil { + m.Clause = v + } +} + // SetCount of object replica. func (m *Replica) SetCount(v uint32) { if m != nil { diff --git a/v2/netmap/grpc/types.pb.go b/v2/netmap/grpc/types.pb.go index 5b0376f..a16be67 100644 --- a/v2/netmap/grpc/types.pb.go +++ b/v2/netmap/grpc/types.pb.go @@ -78,6 +78,40 @@ func (Operation) EnumDescriptor() ([]byte, []int) { return fileDescriptor_91a1332b2376641a, []int{0} } +// Selector modifier showing how the node set will be formed +// By default selector just groups by attribute into a bucket selecting nodes +// only by their hash distance. +type Clause int32 + +const ( + // No modifier defined. Will select nodes from bucket randomly. + Clause_CLAUSE_UNSPECIFIED Clause = 0 + // SAME will select only nodes having the same value of bucket attribute + Clause_SAME Clause = 1 + // DISTINCT will select nodes having different values of bucket attribute + Clause_DISTINCT Clause = 2 +) + +var Clause_name = map[int32]string{ + 0: "CLAUSE_UNSPECIFIED", + 1: "SAME", + 2: "DISTINCT", +} + +var Clause_value = map[string]int32{ + "CLAUSE_UNSPECIFIED": 0, + "SAME": 1, + "DISTINCT": 2, +} + +func (x Clause) String() string { + return proto.EnumName(Clause_name, int32(x)) +} + +func (Clause) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_91a1332b2376641a, []int{1} +} + // Represents the enumeration of various states of the NeoFS node. type NodeInfo_State int32 @@ -204,10 +238,12 @@ type Selector struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // How many nodes to select from bucket Count uint32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` + // Selector modifier showing how to form a bucket + Clause Clause `protobuf:"varint,3,opt,name=clause,proto3,enum=neo.fs.v2.netmap.Clause" json:"clause,omitempty"` // Attribute bucket to select from - Attribute string `protobuf:"bytes,3,opt,name=attribute,proto3" json:"attribute,omitempty"` + Attribute string `protobuf:"bytes,4,opt,name=attribute,proto3" json:"attribute,omitempty"` // Filter reference to select from - Filter string `protobuf:"bytes,4,opt,name=filter,proto3" json:"filter,omitempty"` + Filter string `protobuf:"bytes,5,opt,name=filter,proto3" json:"filter,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -260,6 +296,13 @@ func (m *Selector) GetCount() uint32 { return 0 } +func (m *Selector) GetClause() Clause { + if m != nil { + return m.Clause + } + return Clause_CLAUSE_UNSPECIFIED +} + func (m *Selector) GetAttribute() string { if m != nil { return m.Attribute @@ -555,6 +598,7 @@ func (m *NodeInfo_Attribute) GetParents() []string { func init() { proto.RegisterEnum("neo.fs.v2.netmap.Operation", Operation_name, Operation_value) + proto.RegisterEnum("neo.fs.v2.netmap.Clause", Clause_name, Clause_value) proto.RegisterEnum("neo.fs.v2.netmap.NodeInfo_State", NodeInfo_State_name, NodeInfo_State_value) proto.RegisterType((*Filter)(nil), "neo.fs.v2.netmap.Filter") proto.RegisterType((*Selector)(nil), "neo.fs.v2.netmap.Selector") @@ -567,47 +611,50 @@ func init() { func init() { proto.RegisterFile("v2/netmap/grpc/types.proto", fileDescriptor_91a1332b2376641a) } var fileDescriptor_91a1332b2376641a = []byte{ - // 635 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xee, 0x3a, 0xbf, 0x9e, 0xd2, 0xd6, 0x5a, 0x5a, 0x70, 0x03, 0x44, 0x51, 0xc4, 0xa1, 0x02, - 0xd5, 0x11, 0x41, 0x14, 0xa4, 0x9e, 0x52, 0xea, 0xa0, 0x88, 0xe2, 0x84, 0x4d, 0xb9, 0x70, 0x89, - 0x36, 0xce, 0x26, 0x98, 0x3a, 0xde, 0x95, 0xbd, 0x89, 0x94, 0x37, 0xe1, 0x05, 0xb8, 0xf0, 0x1a, - 0x5c, 0x38, 0xf2, 0x08, 0xa8, 0xdc, 0x79, 0x06, 0xe4, 0x75, 0xec, 0xa4, 0x04, 0x21, 0x4e, 0xb3, - 0x33, 0xfb, 0xf9, 0xfb, 0xbe, 0x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, 0x00, 0x00, + // 686 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xda, 0x40, + 0x10, 0x8e, 0x0d, 0x18, 0x98, 0xfc, 0x59, 0xdb, 0x24, 0x75, 0x68, 0x8b, 0x10, 0xea, 0x21, 0x4a, + 0x15, 0xd3, 0x52, 0x35, 0x8d, 0x94, 0x13, 0x01, 0x53, 0x59, 0x4d, 0x0c, 0x35, 0xe4, 0xd2, 0x0b, + 0x5a, 0xcc, 0x42, 0xad, 0x18, 0xaf, 0x65, 0x2f, 0x48, 0xbc, 0x49, 0x0f, 0xbd, 0xf6, 0xd2, 0xd7, + 0xe8, 0xa5, 0xc7, 0x3e, 0x42, 0x95, 0xde, 0xfb, 0x0c, 0x95, 0xd7, 0x3f, 0x90, 0x10, 0x55, 0x3d, + 0xcd, 0xce, 0xce, 0xe7, 0xef, 0xfb, 0x34, 0xb3, 0x63, 0x28, 0xcd, 0xeb, 0x35, 0x97, 0xb0, 0x29, + 0xf6, 0x6a, 0x13, 0xdf, 0xb3, 0x6a, 0x6c, 0xe1, 0x91, 0x40, 0xf5, 0x7c, 0xca, 0x28, 0x92, 0x5d, + 0x42, 0xd5, 0x71, 0xa0, 0xce, 0xeb, 0x6a, 0x04, 0xa9, 0x7e, 0x15, 0x40, 0x6a, 0xdb, 0x0e, 0x23, + 0x3e, 0x42, 0x90, 0x75, 0xf1, 0x94, 0x28, 0x42, 0x45, 0x38, 0x2a, 0x9a, 0xfc, 0x8c, 0x64, 0xc8, + 0xdc, 0x90, 0x85, 0x22, 0xf2, 0xab, 0xf0, 0x88, 0x5e, 0x80, 0x48, 0x3d, 0x25, 0x53, 0x11, 0x8e, + 0x76, 0xea, 0x4f, 0xd4, 0xfb, 0x7c, 0x6a, 0xc7, 0x23, 0x3e, 0x66, 0x36, 0x75, 0x4d, 0x91, 0x7a, + 0x68, 0x0f, 0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9a, 0x9c, 0x0d, 0xe3, 0x65, 0x5f, 0xce, 0xf1, 0xa8, 0xc9, 0x52, 0x18, 0x3b, 0xa6, 0x9c, + 0x47, 0x79, 0xc8, 0x34, 0x8c, 0x96, 0x5c, 0x38, 0x3e, 0x03, 0x29, 0x5a, 0x12, 0x74, 0x00, 0xa8, + 0x79, 0xd9, 0xb8, 0xee, 0x69, 0xf7, 0x24, 0x0a, 0x90, 0xed, 0x35, 0xae, 0x42, 0x87, 0x5b, 0x50, + 0x68, 0xe9, 0xbd, 0xbe, 0x6e, 0x34, 0xfb, 0xb2, 0x78, 0x31, 0xf8, 0x71, 0x5b, 0x16, 0x7e, 0xde, + 0x96, 0x85, 0x5f, 0xb7, 0x65, 0xe1, 0xf3, 0xef, 0xf2, 0xc6, 0xc7, 0xb7, 0x13, 0x9b, 0x7d, 0x9a, + 0x0d, 0x55, 0x8b, 0x4e, 0x6b, 0x6e, 0xe0, 0x59, 0xd6, 0xc9, 0x88, 0xcc, 0x6b, 0x2e, 0xa1, 0xe3, + 0xe0, 0x04, 0x7b, 0xf6, 0xc9, 0x84, 0xd6, 0xee, 0xfe, 0xbf, 0xce, 0xa3, 0xf3, 0x37, 0xf1, 0x91, + 0x41, 0x68, 0xbb, 0xa7, 0x36, 0xba, 0x7a, 0x38, 0x1b, 0x83, 0xdf, 0x0e, 0x25, 0xfe, 0x5f, 0x7b, + 0xfd, 0x37, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x69, 0xba, 0x7f, 0xf5, 0x04, 0x00, 0x00, } func (m *Filter) Marshal() (dAtA []byte, err error) { @@ -706,14 +753,19 @@ func (m *Selector) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Filter) i = encodeVarintTypes(dAtA, i, uint64(len(m.Filter))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.Attribute) > 0 { i -= len(m.Attribute) copy(dAtA[i:], m.Attribute) i = encodeVarintTypes(dAtA, i, uint64(len(m.Attribute))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 + } + if m.Clause != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Clause)) + i-- + dAtA[i] = 0x18 } if m.Count != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.Count)) @@ -1010,6 +1062,9 @@ func (m *Selector) Size() (n int) { if m.Count != 0 { n += 1 + sovTypes(uint64(m.Count)) } + if m.Clause != 0 { + n += 1 + sovTypes(uint64(m.Clause)) + } l = len(m.Attribute) if l > 0 { n += 1 + l + sovTypes(uint64(l)) @@ -1421,6 +1476,25 @@ func (m *Selector) Unmarshal(dAtA []byte) error { } } case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Clause", wireType) + } + m.Clause = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Clause |= Clause(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Attribute", wireType) } @@ -1452,7 +1526,7 @@ func (m *Selector) Unmarshal(dAtA []byte) error { } m.Attribute = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Filter", wireType) } diff --git a/v2/netmap/marshal.go b/v2/netmap/marshal.go index a38d8a2..2fada3e 100644 --- a/v2/netmap/marshal.go +++ b/v2/netmap/marshal.go @@ -13,8 +13,9 @@ const ( nameSelectorField = 1 countSelectorField = 2 - attributeSelectorField = 3 - filterSelectorField = 4 + clauseSelectorField = 3 + attributeSelectorField = 4 + filterSelectorField = 5 countReplicaField = 1 selectorReplicaField = 2 @@ -128,6 +129,13 @@ func (s *Selector) StableMarshal(buf []byte) ([]byte, error) { offset += n + n, err = proto.EnumMarshal(clauseSelectorField, buf[offset:], int32(s.clause)) + if err != nil { + return nil, err + } + + offset += n + n, err = proto.StringMarshal(attributeSelectorField, buf[offset:], s.attribute) if err != nil { return nil, err @@ -146,6 +154,7 @@ func (s *Selector) StableMarshal(buf []byte) ([]byte, error) { func (s *Selector) StableSize() (size int) { size += proto.StringSize(nameSelectorField, s.name) size += proto.UInt32Size(countSelectorField, s.count) + size += proto.EnumSize(countSelectorField, int32(s.clause)) size += proto.StringSize(attributeSelectorField, s.attribute) size += proto.StringSize(filterSelectorField, s.filter) diff --git a/v2/netmap/marshal_test.go b/v2/netmap/marshal_test.go index 7178a20..5a4ce6c 100644 --- a/v2/netmap/marshal_test.go +++ b/v2/netmap/marshal_test.go @@ -151,6 +151,7 @@ func generateSelector(name string) *netmap.Selector { s := new(netmap.Selector) s.SetName(name) s.SetAttribute("attribute") + s.SetClause(netmap.Distinct) s.SetCount(10) s.SetFilter("filter") diff --git a/v2/netmap/types.go b/v2/netmap/types.go index c16fa50..b91d6e5 100644 --- a/v2/netmap/types.go +++ b/v2/netmap/types.go @@ -11,6 +11,7 @@ type Filter struct { type Selector struct { name string count uint32 + clause Clause attribute string filter string } @@ -47,6 +48,9 @@ type NodeInfo struct { // NodeState of storage node. type NodeState uint32 +// Clause of placement selector. +type Clause uint32 + const ( UnspecifiedState NodeState = iota Online @@ -65,6 +69,12 @@ const ( AND ) +const ( + UnspecifiedClause Clause = iota + Same + Distinct +) + func (f *Filter) GetFilters() []*Filter { if f != nil { return f.filters @@ -162,6 +172,20 @@ func (s *Selector) SetAttribute(attribute string) { } } +func (s *Selector) GetClause() Clause { + if s != nil { + return s.clause + } + + return UnspecifiedClause +} + +func (s *Selector) SetClause(clause Clause) { + if s != nil { + s.clause = clause + } +} + func (s *Selector) GetCount() uint32 { if s != nil { return s.count