2020-07-24 13:54:03 +00:00
|
|
|
package balance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/hex"
|
|
|
|
|
2023-04-12 14:35:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
2023-05-26 10:24:41 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors"
|
2023-03-07 13:38:26 +00:00
|
|
|
"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) {
|
2020-09-08 09:09:08 +00:00
|
|
|
lock := ev.(balanceEvent.Lock)
|
2023-04-13 12:51:36 +00:00
|
|
|
bp.log.Info(logs.Notification,
|
2020-07-24 13:54:03 +00:00
|
|
|
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
|
|
|
|
2023-05-26 10:24:41 +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 {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2023-04-12 14:35:10 +00:00
|
|
|
bp.log.Warn(logs.BalanceBalanceWorkerPoolDrained,
|
2020-07-24 13:54:03 +00:00
|
|
|
zap.Int("capacity", bp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|