forked from TrueCloudLab/frostfs-node
[#1402] ir: Do not use map for combining SG ID and SG object
Also, add corresponding structure for that. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
ec07fda97b
commit
a153e040cb
4 changed files with 41 additions and 13 deletions
|
@ -4,9 +4,9 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/client"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/storagegroup"
|
||||
)
|
||||
|
||||
|
@ -46,3 +46,29 @@ type SGSource interface {
|
|||
// container and netmap state.
|
||||
GetSG(GetSGPrm) (*storagegroup.StorageGroup, error)
|
||||
}
|
||||
|
||||
// StorageGroup combines storage group object ID and its structure.
|
||||
type StorageGroup struct {
|
||||
id oid.ID
|
||||
sg storagegroup.StorageGroup
|
||||
}
|
||||
|
||||
// ID returns object ID of the storage group.
|
||||
func (s StorageGroup) ID() oid.ID {
|
||||
return s.id
|
||||
}
|
||||
|
||||
// SetID sets an object ID of the storage group.
|
||||
func (s *StorageGroup) SetID(id oid.ID) {
|
||||
s.id = id
|
||||
}
|
||||
|
||||
// StorageGroup returns the storage group descriptor.
|
||||
func (s StorageGroup) StorageGroup() storagegroup.StorageGroup {
|
||||
return s.sg
|
||||
}
|
||||
|
||||
// SetStorageGroup sets a storage group descriptor.
|
||||
func (s *StorageGroup) SetStorageGroup(sg storagegroup.StorageGroup) {
|
||||
s.sg = sg
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
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"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -172,8 +171,9 @@ func (ap *Processor) findStorageGroups(cnr cid.ID, shuffled netmapcore.Nodes) []
|
|||
}
|
||||
|
||||
func (ap *Processor) filterExpiredSG(cid cid.ID, sgIDs []oid.ID,
|
||||
cnr [][]netmap.NodeInfo, nm netmap.NetMap) map[oid.ID]storagegroupSDK.StorageGroup {
|
||||
sgs := make(map[oid.ID]storagegroupSDK.StorageGroup, len(sgIDs))
|
||||
cnr [][]netmap.NodeInfo, nm netmap.NetMap) []storagegroup.StorageGroup {
|
||||
sgs := make([]storagegroup.StorageGroup, 0, len(sgIDs))
|
||||
var coreSG storagegroup.StorageGroup
|
||||
|
||||
var getSGPrm storagegroup.GetSGPrm
|
||||
getSGPrm.CID = cid
|
||||
|
@ -202,7 +202,10 @@ func (ap *Processor) filterExpiredSG(cid cid.ID, sgIDs []oid.ID,
|
|||
|
||||
// filter expired epochs
|
||||
if sg.ExpirationEpoch() > ap.epochSrc.EpochCounter() {
|
||||
sgs[sgID] = *sg
|
||||
coreSG.SetID(sgID)
|
||||
coreSG.SetStorageGroup(*sg)
|
||||
|
||||
sgs = append(sgs, coreSG)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ func (c *Context) executePoR() {
|
|||
wg := new(sync.WaitGroup)
|
||||
sgs := c.task.StorageGroupList()
|
||||
|
||||
for id, sg := range sgs {
|
||||
for _, sg := range sgs {
|
||||
wg.Add(1)
|
||||
|
||||
if err := c.porWorkerPool.Submit(func() {
|
||||
c.checkStorageGroupPoR(id, sg)
|
||||
c.checkStorageGroupPoR(sg.ID(), sg.StorageGroup())
|
||||
wg.Done()
|
||||
}); err != nil {
|
||||
wg.Done()
|
||||
|
|
|
@ -3,11 +3,10 @@ package audit
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/storagegroup"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/container"
|
||||
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"
|
||||
)
|
||||
|
||||
// Task groups groups the container audit parameters.
|
||||
|
@ -24,7 +23,7 @@ type Task struct {
|
|||
|
||||
cnrNodes [][]netmap.NodeInfo
|
||||
|
||||
sgList map[oid.ID]storagegroupSDK.StorageGroup
|
||||
sgList []storagegroup.StorageGroup
|
||||
}
|
||||
|
||||
// WithReporter sets audit report writer.
|
||||
|
@ -112,7 +111,7 @@ func (t *Task) ContainerNodes() [][]netmap.NodeInfo {
|
|||
}
|
||||
|
||||
// WithStorageGroupList sets a list of storage groups from container under audit.
|
||||
func (t *Task) WithStorageGroupList(sgList map[oid.ID]storagegroupSDK.StorageGroup) *Task {
|
||||
func (t *Task) WithStorageGroupList(sgList []storagegroup.StorageGroup) *Task {
|
||||
if t != nil {
|
||||
t.sgList = sgList
|
||||
}
|
||||
|
@ -121,6 +120,6 @@ func (t *Task) WithStorageGroupList(sgList map[oid.ID]storagegroupSDK.StorageGro
|
|||
}
|
||||
|
||||
// StorageGroupList returns list of storage groups from container under audit.
|
||||
func (t *Task) StorageGroupList() map[oid.ID]storagegroupSDK.StorageGroup {
|
||||
func (t *Task) StorageGroupList() []storagegroup.StorageGroup {
|
||||
return t.sgList
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue