[#1402] ir: Move GetSG interface

`auditor` does not need to request SG: processor will fetch that info before
audit context initialization.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-05-19 22:39:43 +03:00 committed by fyrchik
parent 6370c2e160
commit 7864959d0c
4 changed files with 25 additions and 20 deletions

View file

@ -13,7 +13,9 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/services/audit"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
storagegroupSDK "github.com/nspcc-dev/neofs-sdk-go/storagegroup"
"github.com/panjf2000/ants/v2"
"go.uber.org/zap"
)
@ -97,12 +99,27 @@ func (x *SearchSGDst) WriteIDList(ids []oid.ID) {
x.ids = ids
}
// GetSGPrm groups parameter of GetSG operation.
type GetSGPrm struct {
Context context.Context
OID oid.ID
CID cid.ID
NetMap netmap.NetMap
Container [][]netmap.NodeInfo
}
// SGSource is a storage group information source interface.
type SGSource interface {
// Lists storage group objects in the container. Formed list must be written to destination.
// ListSG must list storage group objects in the container. Formed list must be written to destination.
//
// Must return any error encountered which did not allow to form the list.
ListSG(*SearchSGDst, SearchSGPrm) error
// GetSG must return storage group object for the provided CID, OID,
// container and netmap state.
GetSG(GetSGPrm) (*storagegroupSDK.StorageGroup, error)
}
type epochAuditReporter struct {

View file

@ -62,12 +62,12 @@ func (c *ClientCache) Get(info clientcore.NodeInfo) (clientcore.Client, error) {
// Returns storage groups structure from received object.
//
// Returns an error of type apistatus.ObjectNotFound if storage group is missing.
func (c *ClientCache) GetSG(prm auditor.GetSGPrm) (*storagegroup.StorageGroup, error) {
func (c *ClientCache) GetSG(prm auditproc.GetSGPrm) (*storagegroup.StorageGroup, error) {
var sgAddress oid.Address
sgAddress.SetContainer(prm.CID)
sgAddress.SetObject(prm.OID)
return c.getSG(prm.Context, sgAddress, prm.NetMap, prm.Container)
return c.getSG(prm.Context, sgAddress, &prm.NetMap, prm.Container)
}
func (c *ClientCache) getSG(ctx context.Context, addr oid.Address, nm *netmap.NetMap, cn [][]netmap.NodeInfo) (*storagegroup.StorageGroup, error) {

View file

@ -13,7 +13,6 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/storagegroup"
"go.uber.org/atomic"
"go.uber.org/zap"
)
@ -85,24 +84,16 @@ type ContextPrm struct {
type commonCommunicatorPrm struct {
Context context.Context
Node netmap.NodeInfo
OID oid.ID
CID cid.ID
}
// GetSGPrm groups parameter of GetSG operation.
type GetSGPrm struct {
commonCommunicatorPrm
NetMap *netmap.NetMap
Container [][]netmap.NodeInfo
}
// GetHeaderPrm groups parameter of GetHeader operation.
type GetHeaderPrm struct {
commonCommunicatorPrm
Node netmap.NodeInfo
NodeIsRelay bool
}
@ -110,16 +101,12 @@ type GetHeaderPrm struct {
type GetRangeHashPrm struct {
commonCommunicatorPrm
Node netmap.NodeInfo
Range *object.Range
}
// ContainerCommunicator is an interface of
// component of communication with container nodes.
type ContainerCommunicator interface {
// GetSG must return storage group structure stored in object from container.
GetSG(GetSGPrm) (*storagegroup.StorageGroup, error)
// GetHeader must return object header from the container node.
GetHeader(GetHeaderPrm) (*object.Object, error)

View file

@ -5,6 +5,7 @@ import (
"encoding/hex"
"sync"
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/audit"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/nspcc-dev/neofs-node/pkg/util/rand"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@ -36,12 +37,12 @@ func (c *Context) executePoR() {
}
func (c *Context) checkStorageGroupPoR(ind int, sg oid.ID) {
var getSgPrm GetSGPrm
var getSgPrm audit.GetSGPrm
getSgPrm.Context = c.task.AuditContext()
getSgPrm.CID = c.task.ContainerID()
getSgPrm.OID = sg
getSgPrm.NetMap = c.task.NetworkMap()
getSgPrm.NetMap = *c.task.NetworkMap()
getSgPrm.Container = c.task.ContainerNodes()
storageGroup, err := c.cnrCom.GetSG(getSgPrm) // get storage group