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
|
@ -35,6 +35,11 @@ type context struct {
|
|||
|
||||
// container backup factor
|
||||
cbf uint32
|
||||
|
||||
// nodes already used in previous selections, which is needed when the placement
|
||||
// policy uses the UNIQUE flag. Nodes marked as used are not used in subsequent
|
||||
// base selections.
|
||||
usedNodes map[uint64]bool
|
||||
}
|
||||
|
||||
// Various validation errors.
|
||||
|
@ -58,6 +63,7 @@ func newContext(nm NetMap) *context {
|
|||
|
||||
numCache: make(map[string]uint64),
|
||||
weightFunc: defaultWeightFunc(nm.nodes),
|
||||
usedNodes: make(map[uint64]bool),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +82,12 @@ func (c *context) setCBF(cbf uint32) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *context) addUsedNodes(ns ...NodeInfo) {
|
||||
for _, n := range ns {
|
||||
c.usedNodes[n.hash] = true
|
||||
}
|
||||
}
|
||||
|
||||
func defaultWeightFunc(ns nodes) weightFunc {
|
||||
mean := newMeanAgg()
|
||||
min := newMinAgg()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue