2020-08-11 12:10:01 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
|
|
|
containerEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/container"
|
2020-08-11 12:10:01 +00:00
|
|
|
"github.com/mr-tron/base58"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (cp *Processor) handlePut(ev event.Event) {
|
2021-10-12 14:56:17 +00:00
|
|
|
put := ev.(putEvent)
|
2020-08-11 12:10:01 +00:00
|
|
|
|
|
|
|
id := sha256.Sum256(put.Container())
|
|
|
|
cp.log.Info("notification",
|
|
|
|
zap.String("type", "container put"),
|
|
|
|
zap.String("id", base58.Encode(id[:])))
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// send an event to the worker pool
|
2020-08-11 12:10:01 +00:00
|
|
|
|
2021-10-12 14:56:17 +00:00
|
|
|
err := cp.pool.Submit(func() { cp.processContainerPut(put) })
|
2020-08-11 12:10:01 +00:00
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2020-08-11 12:10:01 +00:00
|
|
|
cp.log.Warn("container processor worker pool drained",
|
|
|
|
zap.Int("capacity", cp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
2020-09-02 16:04:29 +00:00
|
|
|
|
|
|
|
func (cp *Processor) handleDelete(ev event.Event) {
|
2020-09-08 09:09:08 +00:00
|
|
|
del := ev.(containerEvent.Delete)
|
2020-09-02 16:04:29 +00:00
|
|
|
cp.log.Info("notification",
|
|
|
|
zap.String("type", "container delete"),
|
|
|
|
zap.String("id", base58.Encode(del.ContainerID())))
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// send an event to the worker pool
|
2020-09-02 16:04:29 +00:00
|
|
|
|
|
|
|
err := cp.pool.Submit(func() { cp.processContainerDelete(&del) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2020-09-02 16:04:29 +00:00
|
|
|
cp.log.Warn("container processor worker pool drained",
|
|
|
|
zap.Int("capacity", cp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
2021-05-19 12:18:07 +00:00
|
|
|
|
|
|
|
func (cp *Processor) handleSetEACL(ev event.Event) {
|
|
|
|
e := ev.(containerEvent.SetEACL)
|
|
|
|
|
|
|
|
cp.log.Info("notification",
|
|
|
|
zap.String("type", "set EACL"),
|
|
|
|
)
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// send an event to the worker pool
|
2021-05-19 12:18:07 +00:00
|
|
|
|
|
|
|
err := cp.pool.Submit(func() {
|
|
|
|
cp.processSetEACL(e)
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
// there system can be moved into controlled degradation stage
|
|
|
|
cp.log.Warn("container processor worker pool drained",
|
|
|
|
zap.Int("capacity", cp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|