forked from TrueCloudLab/frostfs-api-go
[#249] pkg/netmap: Add CBF field in placement context
If CBF value is not set, then netmap package uses default CBF value. However it modifies placement policy structure in `GetContainerNodes()` because policy passed as a pointer. Instead package can store CBF value in internal context and use it without policy modification. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
98284f0bfa
commit
c35e15a758
4 changed files with 18 additions and 6 deletions
|
@ -29,6 +29,9 @@ type Context struct {
|
|||
// weightFunc is a weighting function for determining node priority.
|
||||
// By default in combines favours low price and high capacity.
|
||||
weightFunc weightFunc
|
||||
// container backup factor is a factor for selector counters that expand
|
||||
// amount of chosen nodes.
|
||||
cbf uint32
|
||||
}
|
||||
|
||||
// Various validation errors.
|
||||
|
@ -56,6 +59,7 @@ func NewContext(nm *Netmap) *Context {
|
|||
numCache: make(map[*Filter]uint64),
|
||||
aggregator: newMeanIQRAgg,
|
||||
weightFunc: GetDefaultWeightFunc(nm.Nodes),
|
||||
cbf: defaultCBF,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +70,14 @@ func (c *Context) setPivot(pivot []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *Context) setCBF(cbf uint32) {
|
||||
if cbf == 0 {
|
||||
c.cbf = defaultCBF
|
||||
} else {
|
||||
c.cbf = cbf
|
||||
}
|
||||
}
|
||||
|
||||
// GetDefaultWeightFunc returns default weighting function.
|
||||
func GetDefaultWeightFunc(ns Nodes) weightFunc {
|
||||
mean := newMeanAgg()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue