forked from TrueCloudLab/frostfs-api-go
[#248] netmap: fulfill backup factor for default attribute
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
42657aaf11
commit
5d9ef5feec
3 changed files with 70 additions and 1 deletions
|
@ -48,6 +48,7 @@ func GetNodesCount(_ *PlacementPolicy, s *Selector) (int, int) {
|
|||
}
|
||||
|
||||
// getSelection returns nodes grouped by s.attribute.
|
||||
// Last argument specifies if more buckets can be used to fullfill CBF.
|
||||
func (c *Context) getSelection(p *PlacementPolicy, s *Selector) ([]Nodes, error) {
|
||||
bucketCount, nodesInBucket := GetNodesCount(p, s)
|
||||
buckets := c.getSelectionBase(s)
|
||||
|
@ -99,6 +100,17 @@ func (c *Context) getSelection(p *PlacementPolicy, s *Selector) ([]Nodes, error)
|
|||
hrw.SortSliceByWeightIndex(nodes, weights, c.pivotHash)
|
||||
}
|
||||
|
||||
if s.Attribute() == "" {
|
||||
nodes, fallback = nodes[:bucketCount], nodes[bucketCount:]
|
||||
for i := range fallback {
|
||||
index := i % bucketCount
|
||||
if len(nodes[index]) >= maxNodesInBucket {
|
||||
break
|
||||
}
|
||||
nodes[index] = append(nodes[index], fallback[i]...)
|
||||
}
|
||||
}
|
||||
|
||||
return nodes[:bucketCount], nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue