2020-07-24 13:54:03 +00:00
|
|
|
package balance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/hex"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/morph/event"
|
|
|
|
balanceEvent "github.com/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) {
|
2020-09-08 09:09:08 +00:00
|
|
|
lock := ev.(balanceEvent.Lock)
|
2020-07-24 13:54:03 +00:00
|
|
|
bp.log.Info("notification",
|
|
|
|
zap.String("type", "lock"),
|
|
|
|
zap.String("value", hex.EncodeToString(lock.ID())))
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// send an event to the worker pool
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
err := bp.pool.Submit(func() { bp.processLock(&lock) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2020-07-24 13:54:03 +00:00
|
|
|
bp.log.Warn("balance worker pool drained",
|
|
|
|
zap.Int("capacity", bp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|