2020-07-24 13:54:03 +00:00
|
|
|
package balance
|
|
|
|
|
|
|
|
import (
|
2024-10-21 07:22:54 +00:00
|
|
|
"context"
|
2020-07-24 13:54:03 +00:00
|
|
|
"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)
|
2024-10-21 07:22:54 +00:00
|
|
|
bp.log.Info(context.Background(), 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
|
2024-10-21 07:22:54 +00:00
|
|
|
bp.log.Warn(context.Background(), logs.BalanceBalanceWorkerPoolDrained,
|
2020-07-24 13:54:03 +00:00
|
|
|
zap.Int("capacity", bp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|