forked from TrueCloudLab/frostfs-api-go
[#138] v2/netmap: Update to neofs-api jindo release
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
b19e3a48db
commit
c0cc4a4374
6 changed files with 53 additions and 2 deletions
|
@ -54,6 +54,7 @@ func SelectorToGRPCMessage(s *Selector) *netmap.Selector {
|
||||||
|
|
||||||
m.SetName(s.GetName())
|
m.SetName(s.GetName())
|
||||||
m.SetCount(s.GetCount())
|
m.SetCount(s.GetCount())
|
||||||
|
m.SetClause(ClauseToGRPCMessage(s.GetClause()))
|
||||||
m.SetFilter(s.GetFilter())
|
m.SetFilter(s.GetFilter())
|
||||||
m.SetAttribute(s.GetAttribute())
|
m.SetAttribute(s.GetAttribute())
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ func SelectorFromGRPCMessage(m *netmap.Selector) *Selector {
|
||||||
|
|
||||||
s.SetName(m.GetName())
|
s.SetName(m.GetName())
|
||||||
s.SetCount(m.GetCount())
|
s.SetCount(m.GetCount())
|
||||||
|
s.SetClause(ClauseFromGRPCMessage(m.GetClause()))
|
||||||
s.SetFilter(m.GetFilter())
|
s.SetFilter(m.GetFilter())
|
||||||
s.SetAttribute(m.GetAttribute())
|
s.SetAttribute(m.GetAttribute())
|
||||||
|
|
||||||
|
@ -160,6 +162,14 @@ func PlacementPolicyFromGRPCMessage(m *netmap.PlacementPolicy) *PlacementPolicy
|
||||||
return p
|
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 {
|
func OperationToGRPCMessage(n Operation) netmap.Operation {
|
||||||
return netmap.Operation(n)
|
return netmap.Operation(n)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
// SetCount of object replica.
|
||||||
func (m *Replica) SetCount(v uint32) {
|
func (m *Replica) SetCount(v uint32) {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
|
|
Binary file not shown.
|
@ -13,8 +13,9 @@ const (
|
||||||
|
|
||||||
nameSelectorField = 1
|
nameSelectorField = 1
|
||||||
countSelectorField = 2
|
countSelectorField = 2
|
||||||
attributeSelectorField = 3
|
clauseSelectorField = 3
|
||||||
filterSelectorField = 4
|
attributeSelectorField = 4
|
||||||
|
filterSelectorField = 5
|
||||||
|
|
||||||
countReplicaField = 1
|
countReplicaField = 1
|
||||||
selectorReplicaField = 2
|
selectorReplicaField = 2
|
||||||
|
@ -128,6 +129,13 @@ func (s *Selector) StableMarshal(buf []byte) ([]byte, error) {
|
||||||
|
|
||||||
offset += n
|
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)
|
n, err = proto.StringMarshal(attributeSelectorField, buf[offset:], s.attribute)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -146,6 +154,7 @@ func (s *Selector) StableMarshal(buf []byte) ([]byte, error) {
|
||||||
func (s *Selector) StableSize() (size int) {
|
func (s *Selector) StableSize() (size int) {
|
||||||
size += proto.StringSize(nameSelectorField, s.name)
|
size += proto.StringSize(nameSelectorField, s.name)
|
||||||
size += proto.UInt32Size(countSelectorField, s.count)
|
size += proto.UInt32Size(countSelectorField, s.count)
|
||||||
|
size += proto.EnumSize(countSelectorField, int32(s.clause))
|
||||||
size += proto.StringSize(attributeSelectorField, s.attribute)
|
size += proto.StringSize(attributeSelectorField, s.attribute)
|
||||||
size += proto.StringSize(filterSelectorField, s.filter)
|
size += proto.StringSize(filterSelectorField, s.filter)
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,7 @@ func generateSelector(name string) *netmap.Selector {
|
||||||
s := new(netmap.Selector)
|
s := new(netmap.Selector)
|
||||||
s.SetName(name)
|
s.SetName(name)
|
||||||
s.SetAttribute("attribute")
|
s.SetAttribute("attribute")
|
||||||
|
s.SetClause(netmap.Distinct)
|
||||||
s.SetCount(10)
|
s.SetCount(10)
|
||||||
s.SetFilter("filter")
|
s.SetFilter("filter")
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ type Filter struct {
|
||||||
type Selector struct {
|
type Selector struct {
|
||||||
name string
|
name string
|
||||||
count uint32
|
count uint32
|
||||||
|
clause Clause
|
||||||
attribute string
|
attribute string
|
||||||
filter string
|
filter string
|
||||||
}
|
}
|
||||||
|
@ -47,6 +48,9 @@ type NodeInfo struct {
|
||||||
// NodeState of storage node.
|
// NodeState of storage node.
|
||||||
type NodeState uint32
|
type NodeState uint32
|
||||||
|
|
||||||
|
// Clause of placement selector.
|
||||||
|
type Clause uint32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UnspecifiedState NodeState = iota
|
UnspecifiedState NodeState = iota
|
||||||
Online
|
Online
|
||||||
|
@ -65,6 +69,12 @@ const (
|
||||||
AND
|
AND
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
UnspecifiedClause Clause = iota
|
||||||
|
Same
|
||||||
|
Distinct
|
||||||
|
)
|
||||||
|
|
||||||
func (f *Filter) GetFilters() []*Filter {
|
func (f *Filter) GetFilters() []*Filter {
|
||||||
if f != nil {
|
if f != nil {
|
||||||
return f.filters
|
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 {
|
func (s *Selector) GetCount() uint32 {
|
||||||
if s != nil {
|
if s != nil {
|
||||||
return s.count
|
return s.count
|
||||||
|
|
Loading…
Reference in a new issue