forked from TrueCloudLab/frostfs-node
[#355] innerring: Produce container size estimation notifications
There are two notifications: - start estimation notification produced at the beginning of the epoch, - stop estimation notifications should be produced before basic audit settlement starts. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
6848a816f9
commit
5b550bff22
5 changed files with 62 additions and 7 deletions
|
@ -4,13 +4,26 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/alphabet"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/timers"
|
||||
container "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type (
|
||||
epochState interface {
|
||||
EpochCounter() uint64
|
||||
}
|
||||
|
||||
epochTimerArgs struct {
|
||||
l *zap.Logger
|
||||
|
||||
nm *netmap.Processor // to handle new epoch tick
|
||||
|
||||
epochDuration uint32 // in blocks
|
||||
cnrWrapper *container.Wrapper // to invoke stop container estimation
|
||||
epoch epochState // to specify which epoch to stop
|
||||
|
||||
epochDuration uint32 // in blocks
|
||||
stopEstimationDMul uint32 // X: X/Y of epoch in blocks
|
||||
stopEstimationDDiv uint32 // Y: X/Y of epoch in blocks
|
||||
}
|
||||
|
||||
emitTimerArgs struct {
|
||||
|
@ -48,6 +61,25 @@ func newEpochTimer(args *epochTimerArgs) *timers.BlockTimer {
|
|||
},
|
||||
)
|
||||
|
||||
// sub-timer for epoch timer to tick stop container estimation events at
|
||||
// some block in epoch
|
||||
epochTimer.OnDelta(
|
||||
args.stopEstimationDMul,
|
||||
args.stopEstimationDDiv,
|
||||
func() {
|
||||
epochN := args.epoch.EpochCounter()
|
||||
if epochN == 0 { // estimates are invalid in genesis epoch
|
||||
return
|
||||
}
|
||||
|
||||
err := args.cnrWrapper.StopEstimation(epochN - 1)
|
||||
if err != nil {
|
||||
args.l.Warn("can't stop epoch estimation",
|
||||
zap.Uint64("epoch", epochN),
|
||||
zap.String("error", err.Error()))
|
||||
}
|
||||
})
|
||||
|
||||
return epochTimer
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue