[#1129] policer: Refactor shortage

Drop override inside method.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-05-15 16:11:51 +03:00
parent 4ab6c404f7
commit 1cd8562db8
2 changed files with 11 additions and 14 deletions

View file

@ -64,7 +64,16 @@ func (p *Policer) processRepContainerObject(ctx context.Context, objInfo objectc
default: default:
} }
p.processRepNodes(ctx, c, objInfo, nn[i], policy.ReplicaDescriptor(i).NumberOfObjects(), checkedNodes) shortage := policy.ReplicaDescriptor(i).NumberOfObjects()
if objInfo.Type == objectSDK.TypeLock || objInfo.Type == objectSDK.TypeTombstone || objInfo.IsLinkingObject {
// all nodes of a container must store the `LOCK`, `TOMBSTONE` and linking objects
// for correct object removal protection:
// - `LOCK`, `TOMBSTONE` and linking objects are broadcast on their PUT requests;
// - `LOCK` object removal is a prohibited action in the GC.
shortage = uint32(len(nn[i]))
}
p.processRepNodes(ctx, c, objInfo, nn[i], shortage, checkedNodes)
} }
if !c.needLocalCopy && c.removeLocalCopy { if !c.needLocalCopy && c.removeLocalCopy {
@ -89,19 +98,9 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
nodes []netmap.NodeInfo, shortage uint32, checkedNodes nodeCache, nodes []netmap.NodeInfo, shortage uint32, checkedNodes nodeCache,
) { ) {
addr := objInfo.Address addr := objInfo.Address
typ := objInfo.Type
// Number of copies that are stored on maintenance nodes. // Number of copies that are stored on maintenance nodes.
var uncheckedCopies int var uncheckedCopies int
if typ == objectSDK.TypeLock || typ == objectSDK.TypeTombstone || objInfo.IsLinkingObject {
// all nodes of a container must store the `LOCK`, `TOMBSTONE` and linking objects
// for correct object removal protection:
// - `LOCK`, `TOMBSTONE` and linking objects are broadcast on their PUT requests;
// - `LOCK` object removal is a prohibited action in the GC.
shortage = uint32(len(nodes))
}
for i := 0; shortage > 0 && i < len(nodes); i++ { for i := 0; shortage > 0 && i < len(nodes); i++ {
select { select {
case <-ctx.Done(): case <-ctx.Done():

View file

@ -52,9 +52,7 @@ func (p *Policer) processECContainerRepObject(ctx context.Context, objInfo objec
default: default:
} }
rd := policy.ReplicaDescriptor(0) p.processRepNodes(ctx, c, objInfo, nn[0], uint32(len(nn[0])), checkedNodes)
// processNodes replaces rd.GetECDataCount() + rd.GetECParityCount() for len(nn[0]) for locks, tomstones and linking objects.
p.processRepNodes(ctx, c, objInfo, nn[0], rd.GetECDataCount()+rd.GetECParityCount(), checkedNodes)
if !c.needLocalCopy && c.removeLocalCopy { if !c.needLocalCopy && c.removeLocalCopy {
p.log.Info(logs.PolicerRedundantLocalObjectCopyDetected, p.log.Info(logs.PolicerRedundantLocalObjectCopyDetected,