forked from TrueCloudLab/frostfs-node
[#31] placement: Implement container placement traverser
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
44def45ff4
commit
e7925fbc1c
5 changed files with 337 additions and 1 deletions
32
pkg/services/object_manager/placement/netmap.go
Normal file
32
pkg/services/object_manager/placement/netmap.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package placement
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type netMapBuilder struct {
|
||||
nm *netmap.Netmap
|
||||
}
|
||||
|
||||
func (b *netMapBuilder) BuildPlacement(a *object.Address, p *netmap.PlacementPolicy) ([]netmap.Nodes, error) {
|
||||
aV2 := a.ToV2()
|
||||
|
||||
cn, err := b.nm.GetContainerNodes(p, aV2.GetContainerID().GetValue())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get container nodes")
|
||||
}
|
||||
|
||||
oid := aV2.GetObjectID()
|
||||
if oid == nil {
|
||||
return cn.Replicas(), nil
|
||||
}
|
||||
|
||||
on, err := b.nm.GetPlacementVectors(cn, oid.GetValue())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get placement vectors for object")
|
||||
}
|
||||
|
||||
return on, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue