package netmap import ( "encoding/hex" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" timerEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/timers" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event" netmapEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/netmap" subnetevents "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/subnet" "go.uber.org/zap" ) func (np *Processor) HandleNewEpochTick(ev event.Event) { _ = ev.(timerEvent.NewEpochTick) np.log.Info(logs.NetmapTick, zap.String("type", "epoch")) // send an event to the worker pool err := np.pool.Submit(func() { np.processNewEpochTick() }) if err != nil { // there system can be moved into controlled degradation stage np.log.Warn(logs.NetmapNetmapWorkerPoolDrained, zap.Int("capacity", np.pool.Cap())) } } func (np *Processor) handleNewEpoch(ev event.Event) { epochEvent := ev.(netmapEvent.NewEpoch) np.log.Info(logs.NetmapNotification, zap.String("type", "new epoch"), zap.Uint64("value", epochEvent.EpochNumber())) // send an event to the worker pool err := np.pool.Submit(func() { np.processNewEpoch(epochEvent) }) if err != nil { // there system can be moved into controlled degradation stage np.log.Warn(logs.NetmapNetmapWorkerPoolDrained, zap.Int("capacity", np.pool.Cap())) } } func (np *Processor) handleAddPeer(ev event.Event) { newPeer := ev.(netmapEvent.AddPeer) np.log.Info(logs.NetmapNotification, zap.String("type", "add peer"), ) // send an event to the worker pool err := np.pool.Submit(func() { np.processAddPeer(newPeer) }) if err != nil { // there system can be moved into controlled degradation stage np.log.Warn(logs.NetmapNetmapWorkerPoolDrained, zap.Int("capacity", np.pool.Cap())) } } func (np *Processor) handleUpdateState(ev event.Event) { updPeer := ev.(netmapEvent.UpdatePeer) np.log.Info(logs.NetmapNotification, zap.String("type", "update peer state"), zap.String("key", hex.EncodeToString(updPeer.PublicKey().Bytes()))) // send event to the worker pool err := np.pool.Submit(func() { np.processUpdatePeer(updPeer) }) if err != nil { // there system can be moved into controlled degradation stage np.log.Warn(logs.NetmapNetmapWorkerPoolDrained, zap.Int("capacity", np.pool.Cap())) } } func (np *Processor) handleCleanupTick(ev event.Event) { if !np.netmapSnapshot.enabled { np.log.Debug(logs.NetmapNetmapCleanUpRoutineIsDisabled518) return } cleanup := ev.(netmapCleanupTick) np.log.Info(logs.NetmapTick, zap.String("type", "netmap cleaner")) // send event to the worker pool err := np.pool.Submit(func() { np.processNetmapCleanupTick(cleanup) }) if err != nil { // there system can be moved into controlled degradation stage np.log.Warn(logs.NetmapNetmapWorkerPoolDrained, zap.Int("capacity", np.pool.Cap())) } } func (np *Processor) handleRemoveNode(ev event.Event) { removeNode := ev.(subnetevents.RemoveNode) np.log.Info(logs.NetmapNotification, zap.String("type", "remove node from subnet"), zap.String("subnetID", hex.EncodeToString(removeNode.SubnetworkID())), zap.String("key", hex.EncodeToString(removeNode.Node())), ) err := np.pool.Submit(func() { np.processRemoveSubnetNode(removeNode) }) if err != nil { // there system can be moved into controlled degradation stage np.log.Warn(logs.NetmapNetmapWorkerPoolDrained, zap.Int("capacity", np.pool.Cap())) } }