forked from TrueCloudLab/frostfs-node
[#1556] Upgrade NeoFS SDK Go with changed container API
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f699e82ea7
commit
c165d1a9b5
36 changed files with 207 additions and 480 deletions
|
@ -45,7 +45,8 @@ type cfg struct {
|
|||
|
||||
obj *oid.ID
|
||||
|
||||
policy *netmap.PlacementPolicy
|
||||
policySet bool
|
||||
policy netmap.PlacementPolicy
|
||||
|
||||
builder Builder
|
||||
}
|
||||
|
@ -74,11 +75,11 @@ func NewTraverser(opts ...Option) (*Traverser, error) {
|
|||
|
||||
if cfg.builder == nil {
|
||||
return nil, fmt.Errorf("%s: %w", invalidOptsMsg, errNilBuilder)
|
||||
} else if cfg.policy == nil {
|
||||
} else if !cfg.policySet {
|
||||
return nil, fmt.Errorf("%s: %w", invalidOptsMsg, errNilPolicy)
|
||||
}
|
||||
|
||||
ns, err := cfg.builder.BuildPlacement(cfg.cnr, cfg.obj, *cfg.policy)
|
||||
ns, err := cfg.builder.BuildPlacement(cfg.cnr, cfg.obj, cfg.policy)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not build placement: %w", err)
|
||||
}
|
||||
|
@ -219,10 +220,11 @@ func UseBuilder(b Builder) Option {
|
|||
}
|
||||
|
||||
// ForContainer is a traversal container setting option.
|
||||
func ForContainer(cnr *container.Container) Option {
|
||||
func ForContainer(cnr container.Container) Option {
|
||||
return func(c *cfg) {
|
||||
c.policy = cnr.PlacementPolicy()
|
||||
c.cnr = container.CalculateID(cnr)
|
||||
c.policySet = true
|
||||
container.CalculateID(&c.cnr, cnr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ func copyVectors(v [][]netmap.NodeInfo) [][]netmap.NodeInfo {
|
|||
return vc
|
||||
}
|
||||
|
||||
func testPlacement(t *testing.T, ss, rs []int) ([][]netmap.NodeInfo, *container.Container) {
|
||||
func testPlacement(t *testing.T, ss, rs []int) ([][]netmap.NodeInfo, container.Container) {
|
||||
nodes := make([][]netmap.NodeInfo, 0, len(rs))
|
||||
replicas := make([]netmap.ReplicaDescriptor, 0, len(rs))
|
||||
num := uint32(0)
|
||||
|
@ -61,10 +61,13 @@ func testPlacement(t *testing.T, ss, rs []int) ([][]netmap.NodeInfo, *container.
|
|||
replicas = append(replicas, rd)
|
||||
}
|
||||
|
||||
policy := new(netmap.PlacementPolicy)
|
||||
var policy netmap.PlacementPolicy
|
||||
policy.AddReplicas(replicas...)
|
||||
|
||||
return nodes, container.New(container.WithPolicy(policy))
|
||||
var cnr container.Container
|
||||
cnr.SetPlacementPolicy(policy)
|
||||
|
||||
return nodes, cnr
|
||||
}
|
||||
|
||||
func assertSameAddress(t *testing.T, ni netmap.NodeInfo, addr network.AddressGroup) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue