2021-10-27 10:00:35 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2022-06-07 08:25:34 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
2021-10-27 10:00:35 +00:00
|
|
|
)
|
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
func newFilter(name string, k, v string, op netmap.Operation, fs ...Filter) (f Filter) {
|
2021-10-27 10:00:35 +00:00
|
|
|
f.SetName(name)
|
2022-06-07 08:25:34 +00:00
|
|
|
f.m.SetKey(k)
|
|
|
|
f.m.SetOp(op)
|
|
|
|
f.m.SetValue(v)
|
|
|
|
inner := make([]netmap.Filter, len(fs))
|
|
|
|
for i := range fs {
|
|
|
|
inner[i] = fs[i].m
|
|
|
|
}
|
|
|
|
f.m.SetFilters(inner)
|
2021-10-27 10:00:35 +00:00
|
|
|
return f
|
|
|
|
}
|
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
func newSelector(name string, attr string, count uint32, filter string, clause func(*Selector)) (s Selector) {
|
2021-10-27 10:00:35 +00:00
|
|
|
s.SetName(name)
|
2022-06-07 08:25:34 +00:00
|
|
|
s.SelectByBucketAttribute(attr)
|
|
|
|
s.SetNodeAmount(count)
|
|
|
|
clause(&s)
|
|
|
|
s.SetFilterName(filter)
|
2021-10-27 10:00:35 +00:00
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
func newPlacementPolicy(bf uint32, rs []ReplicaDescriptor, ss []Selector, fs []Filter) (p PlacementPolicy) {
|
2021-10-27 10:00:35 +00:00
|
|
|
p.SetContainerBackupFactor(bf)
|
2022-06-07 08:25:34 +00:00
|
|
|
p.AddReplicas(rs...)
|
|
|
|
p.AddSelectors(ss...)
|
|
|
|
p.AddFilters(fs...)
|
2021-10-27 10:00:35 +00:00
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
func newReplica(c uint32, s string) (r ReplicaDescriptor) {
|
|
|
|
r.SetAmount(c)
|
|
|
|
r.SetSelectorName(s)
|
2021-10-27 10:00:35 +00:00
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
func nodeInfoFromAttributes(props ...string) (n NodeInfo) {
|
|
|
|
for i := 0; i < len(props); i += 2 {
|
|
|
|
n.SetAttribute(props[i], props[i+1])
|
2021-10-27 10:00:35 +00:00
|
|
|
}
|
|
|
|
|
2022-06-07 08:25:34 +00:00
|
|
|
return
|
2021-10-27 10:00:35 +00:00
|
|
|
}
|