forked from TrueCloudLab/frostfs-api-go
[#189] sdk/netmap: Get rid of the use of v2 types in the placement code
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
40d7c9cd93
commit
9834ed4e68
9 changed files with 195 additions and 225 deletions
|
@ -1,21 +1,17 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
)
|
||||
|
||||
func newFilter(name string, k, v string, op netmap.Operation, fs ...*netmap.Filter) *netmap.Filter {
|
||||
f := new(netmap.Filter)
|
||||
func newFilter(name string, k, v string, op Operation, fs ...*Filter) *Filter {
|
||||
f := NewFilter()
|
||||
f.SetName(name)
|
||||
f.SetKey(k)
|
||||
f.SetOp(op)
|
||||
f.SetOperation(op)
|
||||
f.SetValue(v)
|
||||
f.SetFilters(fs)
|
||||
f.SetInnerFilters(fs...)
|
||||
return f
|
||||
}
|
||||
|
||||
func newSelector(name string, attr string, c netmap.Clause, count uint32, filter string) *netmap.Selector {
|
||||
s := new(netmap.Selector)
|
||||
func newSelector(name string, attr string, c Clause, count uint32, filter string) *Selector {
|
||||
s := NewSelector()
|
||||
s.SetName(name)
|
||||
s.SetAttribute(attr)
|
||||
s.SetCount(count)
|
||||
|
@ -24,32 +20,32 @@ func newSelector(name string, attr string, c netmap.Clause, count uint32, filter
|
|||
return s
|
||||
}
|
||||
|
||||
func newPlacementPolicy(bf uint32, rs []*netmap.Replica, ss []*netmap.Selector, fs []*netmap.Filter) *netmap.PlacementPolicy {
|
||||
p := new(netmap.PlacementPolicy)
|
||||
func newPlacementPolicy(bf uint32, rs []*Replica, ss []*Selector, fs []*Filter) *PlacementPolicy {
|
||||
p := NewPlacementPolicy()
|
||||
p.SetContainerBackupFactor(bf)
|
||||
p.SetReplicas(rs)
|
||||
p.SetSelectors(ss)
|
||||
p.SetFilters(fs)
|
||||
p.SetReplicas(rs...)
|
||||
p.SetSelectors(ss...)
|
||||
p.SetFilters(fs...)
|
||||
return p
|
||||
}
|
||||
|
||||
func newReplica(c uint32, s string) *netmap.Replica {
|
||||
r := new(netmap.Replica)
|
||||
func newReplica(c uint32, s string) *Replica {
|
||||
r := NewReplica()
|
||||
r.SetCount(c)
|
||||
r.SetSelector(s)
|
||||
return r
|
||||
}
|
||||
|
||||
func nodeInfoFromAttributes(props ...string) netmap.NodeInfo {
|
||||
attrs := make([]*netmap.Attribute, len(props)/2)
|
||||
func nodeInfoFromAttributes(props ...string) NodeInfo {
|
||||
attrs := make([]*NodeAttribute, len(props)/2)
|
||||
for i := range attrs {
|
||||
attrs[i] = new(netmap.Attribute)
|
||||
attrs[i] = NewNodeAttribute()
|
||||
attrs[i].SetKey(props[i*2])
|
||||
attrs[i].SetValue(props[i*2+1])
|
||||
}
|
||||
var n netmap.NodeInfo
|
||||
n.SetAttributes(attrs)
|
||||
return n
|
||||
n := NewNodeInfo()
|
||||
n.SetAttributes(attrs...)
|
||||
return *n
|
||||
}
|
||||
|
||||
func getTestNode(props ...string) *Node {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue