2022-12-23 17:35:35 +00:00
|
|
|
package frostfs
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/hex"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/morph/event"
|
2023-01-10 12:50:17 +00:00
|
|
|
frostfsEvent "github.com/TrueCloudLab/frostfs-node/pkg/morph/event/frostfs"
|
2021-09-06 15:01:15 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util/slice"
|
2020-07-24 13:54:03 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (np *Processor) handleDeposit(ev event.Event) {
|
2022-12-23 17:35:35 +00:00
|
|
|
deposit := ev.(frostfsEvent.Deposit)
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "deposit"),
|
2021-09-06 15:01:15 +00:00
|
|
|
zap.String("id", hex.EncodeToString(slice.CopyReverse(deposit.ID()))))
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processDeposit(&deposit) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2022-12-23 17:35:35 +00:00
|
|
|
np.log.Warn("frostfs processor worker pool drained",
|
2020-07-24 13:54:03 +00:00
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (np *Processor) handleWithdraw(ev event.Event) {
|
2022-12-23 17:35:35 +00:00
|
|
|
withdraw := ev.(frostfsEvent.Withdraw)
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "withdraw"),
|
2021-09-06 15:01:15 +00:00
|
|
|
zap.String("id", hex.EncodeToString(slice.CopyReverse(withdraw.ID()))))
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processWithdraw(&withdraw) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2022-12-23 17:35:35 +00:00
|
|
|
np.log.Warn("frostfs processor worker pool drained",
|
2020-07-24 13:54:03 +00:00
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (np *Processor) handleCheque(ev event.Event) {
|
2022-12-23 17:35:35 +00:00
|
|
|
cheque := ev.(frostfsEvent.Cheque)
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "cheque"),
|
|
|
|
zap.String("id", hex.EncodeToString(cheque.ID())))
|
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processCheque(&cheque) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2022-12-23 17:35:35 +00:00
|
|
|
np.log.Warn("frostfs processor worker pool drained",
|
2020-07-24 13:54:03 +00:00
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
2020-09-08 09:01:38 +00:00
|
|
|
|
|
|
|
func (np *Processor) handleConfig(ev event.Event) {
|
2022-12-23 17:35:35 +00:00
|
|
|
cfg := ev.(frostfsEvent.Config)
|
2020-09-08 09:01:38 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "set config"),
|
|
|
|
zap.String("key", hex.EncodeToString(cfg.Key())),
|
|
|
|
zap.String("value", hex.EncodeToString(cfg.Value())))
|
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processConfig(&cfg) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2022-12-23 17:35:35 +00:00
|
|
|
np.log.Warn("frostfs processor worker pool drained",
|
2020-09-08 09:01:38 +00:00
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
2021-05-31 18:14:30 +00:00
|
|
|
|
|
|
|
func (np *Processor) handleBind(ev event.Event) {
|
2022-12-23 17:35:35 +00:00
|
|
|
e := ev.(frostfsEvent.Bind)
|
2021-05-31 18:14:30 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "bind"),
|
|
|
|
)
|
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processBind(e) })
|
|
|
|
if err != nil {
|
|
|
|
// there system can be moved into controlled degradation stage
|
2022-12-23 17:35:35 +00:00
|
|
|
np.log.Warn("frostfs processor worker pool drained",
|
2021-05-31 18:14:30 +00:00
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (np *Processor) handleUnbind(ev event.Event) {
|
2022-12-23 17:35:35 +00:00
|
|
|
e := ev.(frostfsEvent.Unbind)
|
2021-05-31 18:14:30 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "unbind"),
|
|
|
|
)
|
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processBind(e) })
|
|
|
|
if err != nil {
|
|
|
|
// there system can be moved into controlled degradation stage
|
2022-12-23 17:35:35 +00:00
|
|
|
np.log.Warn("frostfs processor worker pool drained",
|
2021-05-31 18:14:30 +00:00
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|