forked from TrueCloudLab/frostfs-sdk-go
[#76] Add UNIQUE keyword
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
4f48f6c9e0
commit
fcbf96add6
17 changed files with 498 additions and 345 deletions
|
@ -181,6 +181,10 @@ func (m NetMap) ContainerNodes(p PlacementPolicy, pivot []byte) ([][]NodeInfo, e
|
|||
|
||||
result := make([][]NodeInfo, len(p.replicas))
|
||||
|
||||
// Note that the cached selectors are not used when the policy contains the UNIQUE flag.
|
||||
// This is necessary because each selection vector affects potentially the subsequent vectors
|
||||
// and thus we call getSelection in such case, in order to take into account nodes previously
|
||||
// marked as used by earlier replicas.
|
||||
for i := range p.replicas {
|
||||
sName := p.replicas[i].GetSelector()
|
||||
if sName == "" {
|
||||
|
@ -198,18 +202,39 @@ func (m NetMap) ContainerNodes(p PlacementPolicy, pivot []byte) ([][]NodeInfo, e
|
|||
}
|
||||
|
||||
for i := range p.selectors {
|
||||
result[i] = append(result[i], flattenNodes(c.selections[p.selectors[i].GetName()])...)
|
||||
if p.unique {
|
||||
nodes, err := c.getSelection(p.selectors[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[i] = append(result[i], flattenNodes(nodes)...)
|
||||
} else {
|
||||
result[i] = append(result[i], flattenNodes(c.selections[p.selectors[i].GetName()])...)
|
||||
}
|
||||
}
|
||||
|
||||
if p.unique {
|
||||
c.addUsedNodes(result[i]...)
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
nodes, ok := c.selections[sName]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("selector not found: REPLICA '%s'", sName)
|
||||
if p.unique {
|
||||
nodes, err := c.getSelection(*c.processedSelectors[sName])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[i] = append(result[i], flattenNodes(nodes)...)
|
||||
c.addUsedNodes(result[i]...)
|
||||
} else {
|
||||
nodes, ok := c.selections[sName]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("selector not found: REPLICA '%s'", sName)
|
||||
}
|
||||
result[i] = append(result[i], flattenNodes(nodes)...)
|
||||
}
|
||||
|
||||
result[i] = append(result[i], flattenNodes(nodes)...)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue