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 | Bin 53572 -> 55693 bytes v2/netmap/marshal.go | 13 +++++++++++-- v2/netmap/marshal_test.go | 1 + v2/netmap/types.go | 24 ++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 2 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 5b0376fc5597a39ef852c444734b5729182c02ca..a16be672a814bb02ab2866b986f80867430e62d0 100644 GIT binary patch delta 5170 zcmaKwPl#k!6~>v#^kk|=#l(((h$e5EAQ@~r@4fop*x)!bLWg7+=pIC}i0{vRnTp+2 zv8sAf4aO(gMTj6TtGH5Jx=1KoOT>*kcdp$8T!;kR20Zus-KxxBa29W>-@W&I=X~co z=iI8l{O+-LSC4(rdb~bzC$3mbXVK}j99LsEi{|&IZ;mIgMfP8`xbLFLv~vy+8w2zFjSn=hi*X4A7b=23ngWsAjZoS!XRG@dM` zQ5NNA#ZSx_`^U8bd4Rb$H=UfE`!j|*o<;Yw`TeLI&llOGaC_~=`5P{}d6J#YWvY|5 z+r@NZSkJdxcJ|Knvk1(m@x+yT(GR`HAb}E9v+3#Dg;_Q!>*?vq`Chw);a6|IbmQL9 z?N{&JIl6oM=HU+xZ{J!&9z?Nlj&8hs8zzEXIjs=P;|HENPue^?b7dvhVGgD4Tit;3_^!#g*RAAxxU!7^33nVT$tnEzjljkyg>+P>ayKgebVe980K zymRT<%Y@#1cxn4NALGt$yOr)oJL}W-_gm{jI&*F7Tetp~uATiTwv#(Du^&D9FYzlI zgJHG##cTc<`!qONkI4<^{oE=jjvw&X29BA@0*x7)_<)2zW?FHi^G2N%Y$Fk*=`gs zyPm*!nZ*8&p>2$pap|AQ&_73dR)zoE8~JCM`)Atq&q2>W``RdBW zvg2R%Qva+wdNmZARgkGZ z*IoIYb3iz;7IGb{`u+e2qJE&56CE>68n@aMXePp;_n~x%H*Yj-EtLeUPdF^+r)5 z=z-iG$b=(%_B4FFCw)%7l9C?2>KH!4MIuklkdL9DG!-@(!4!g1O1gTF^fI05hy|;RcJ1?^b$SDh z4RUEm2$w2KPVZ zO$NngA_FCb>d}7A1`Q2_Z*fXWN?C?jq%lsHsxGJ1js(CPs*$=v47tclMP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2BlQWQgGkxn|a&6(I4$@?t;@i7~9v zZ&xr63!JLaZ=%iYG=!vR&~GY5uTL6mf`VI{lt?wWa=$``MZsL|fTToED{p|XV71<) zd`n?Kb&Jq!Ly}>Nx|;yiUBDOx1}g-^V64E?L+iqu=s5yi@W7TIT|0z!?AXT4z#e|K z8?U90=pD(54?R*%E`uH=J^5hGHW3FUVSItM1{dryR&JSO7;NU53O2wnWn@fLqom>J zILI~_Bj2_~p|^E*AZZWE5x1~o-o)gU7|#AEZ*8C@o^Mw3!#RSHW7)v5fjbH-!8jTS zr}i2{Z;>xR;Ru7!-z*AFWb(rTwOM?{&>nD5R_Iv`eXDFeX>L$S)(M7P#&0#xfN`WR zA{N{-Ou*^`Q`zar#wMzc$4)^)I3*F=F-hx*U9JWn$FE4`|23FV zy}-zNR#Vo||L71vbtJB);+lD2U>F*!7bCr$Bv|y51XU8 zVzQ>ca-qN0ZulX6txZ;ug-nmX9!Z1k&+$~i1i%L+jtrDQi?0RO9mfSb*8*T^EO-#< zVCmKee+aRwbD86@|GF%)U3dQDqqpzuPd~ogZ-4URMLwKg`1J3W_a|RoogaMBzrMfq c%RBqi-!IP}{_yBx|N76D(#H9XC!an1500(W;s5{u 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