[#138] v2/netmap: Update to neofs-api jindo release

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-09-08 13:19:22 +03:00 committed by Stanislav Bogatyrev
parent b19e3a48db
commit c0cc4a4374
6 changed files with 53 additions and 2 deletions

View file

@ -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)
}

View file

@ -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 {

Binary file not shown.

View file

@ -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)

View file

@ -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")

View file

@ -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