forked from TrueCloudLab/frostfs-node
[#1129] policer: Add EC chunk replication
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
af57d5a6a1
commit
d45d086acd
15 changed files with 263 additions and 62 deletions
|
@ -18,19 +18,15 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (p *Policer) processObject(ctx context.Context, addrWithType objectcore.AddressWithType) error {
|
||||
addr := addrWithType.Address
|
||||
idCnr := addr.Container()
|
||||
idObj := addr.Object()
|
||||
|
||||
cnr, err := p.cnrSrc.Get(idCnr)
|
||||
func (p *Policer) processObject(ctx context.Context, objInfo objectcore.Info) error {
|
||||
cnr, err := p.cnrSrc.Get(objInfo.Address.Container())
|
||||
if err != nil {
|
||||
if client.IsErrContainerNotFound(err) {
|
||||
existed, errWasRemoved := containercore.WasRemoved(p.cnrSrc, idCnr)
|
||||
existed, errWasRemoved := containercore.WasRemoved(p.cnrSrc, objInfo.Address.Container())
|
||||
if errWasRemoved != nil {
|
||||
return fmt.Errorf("%s: %w", logs.PolicerCouldNotConfirmContainerRemoval, errWasRemoved)
|
||||
} else if existed {
|
||||
err := p.buryFn(ctx, addrWithType.Address)
|
||||
err := p.buryFn(ctx, objInfo.Address)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", logs.PolicerCouldNotInhumeObjectWithMissingContainer, err)
|
||||
}
|
||||
|
@ -41,11 +37,16 @@ func (p *Policer) processObject(ctx context.Context, addrWithType objectcore.Add
|
|||
}
|
||||
|
||||
policy := cnr.Value.PlacementPolicy()
|
||||
if policycore.IsECPlacement(policy) {
|
||||
// EC not supported yet by policer
|
||||
return nil
|
||||
}
|
||||
|
||||
if policycore.IsECPlacement(policy) {
|
||||
return p.processECContainerObject(ctx, objInfo, policy)
|
||||
}
|
||||
return p.processRepContainerObject(ctx, objInfo, policy)
|
||||
}
|
||||
|
||||
func (p *Policer) processRepContainerObject(ctx context.Context, objInfo objectcore.Info, policy netmap.PlacementPolicy) error {
|
||||
idObj := objInfo.Address.Object()
|
||||
idCnr := objInfo.Address.Container()
|
||||
nn, err := p.placementBuilder.BuildPlacement(idCnr, &idObj, policy)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", logs.PolicerCouldNotBuildPlacementVectorForObject, err)
|
||||
|
@ -68,15 +69,15 @@ func (p *Policer) processObject(ctx context.Context, addrWithType objectcore.Add
|
|||
default:
|
||||
}
|
||||
|
||||
p.processNodes(ctx, c, addrWithType, nn[i], policy.ReplicaDescriptor(i).NumberOfObjects(), checkedNodes)
|
||||
p.processRepNodes(ctx, c, objInfo, nn[i], policy.ReplicaDescriptor(i).NumberOfObjects(), checkedNodes)
|
||||
}
|
||||
|
||||
if !c.needLocalCopy && c.removeLocalCopy {
|
||||
p.log.Info(logs.PolicerRedundantLocalObjectCopyDetected,
|
||||
zap.Stringer("object", addr),
|
||||
zap.Stringer("object", objInfo.Address),
|
||||
)
|
||||
|
||||
p.cbRedundantCopy(ctx, addr)
|
||||
p.cbRedundantCopy(ctx, objInfo.Address)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -89,16 +90,16 @@ type placementRequirements struct {
|
|||
removeLocalCopy bool
|
||||
}
|
||||
|
||||
func (p *Policer) processNodes(ctx context.Context, requirements *placementRequirements, addrWithType objectcore.AddressWithType,
|
||||
func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRequirements, objInfo objectcore.Info,
|
||||
nodes []netmap.NodeInfo, shortage uint32, checkedNodes nodeCache,
|
||||
) {
|
||||
addr := addrWithType.Address
|
||||
typ := addrWithType.Type
|
||||
addr := objInfo.Address
|
||||
typ := objInfo.Type
|
||||
|
||||
// Number of copies that are stored on maintenance nodes.
|
||||
var uncheckedCopies int
|
||||
|
||||
if typ == objectSDK.TypeLock || typ == objectSDK.TypeTombstone || addrWithType.IsLinkingObject {
|
||||
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;
|
||||
|
@ -196,7 +197,7 @@ func (p *Policer) handleProcessNodesResult(ctx context.Context, addr oid.Address
|
|||
Nodes: nodes,
|
||||
}
|
||||
|
||||
p.replicator.HandleTask(ctx, task, checkedNodes)
|
||||
p.replicator.HandleReplicationTask(ctx, task, checkedNodes)
|
||||
|
||||
case uncheckedCopies > 0:
|
||||
// If we have more copies than needed, but some of them are from the maintenance nodes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue