frostfs-node/pkg/innerring/processors/balance/handlers.go

30 lines
865 B
Go
Raw Normal View History

2020-07-24 13:54:03 +00:00
package balance
import (
"encoding/hex"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
balanceEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/balance"
2020-07-24 13:54:03 +00:00
"go.uber.org/zap"
)
func (bp *Processor) handleLock(ev event.Event) {
lock := ev.(balanceEvent.Lock)
bp.log.Info(logs.Notification,
2020-07-24 13:54:03 +00:00
zap.String("type", "lock"),
zap.String("value", hex.EncodeToString(lock.ID())))
// send an event to the worker pool
2020-07-24 13:54:03 +00:00
err := processors.SubmitEvent(bp.pool, bp.metrics, "lock", func() bool {
return bp.processLock(&lock)
})
2020-07-24 13:54:03 +00:00
if err != nil {
// there system can be moved into controlled degradation stage
bp.log.Warn(logs.BalanceBalanceWorkerPoolDrained,
2020-07-24 13:54:03 +00:00
zap.Int("capacity", bp.pool.Cap()))
}
}