From 425d48f68b11ffdd848edad7eb49230139a0209d Mon Sep 17 00:00:00 2001 From: aarifullin Date: Wed, 27 Mar 2024 14:43:23 +0300 Subject: [PATCH] [#211] netmap: Introduce ReplicaDescriptor method * Make ReplicaNumberByIndex deprecated. * Introduce ReplicaDescriptor method that access i-th replica directly. * Introduce new getters for ReplicaDescriptor. Signed-off-by: Airat Arifullin --- netmap/policy.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/netmap/policy.go b/netmap/policy.go index 3ab77c2..bbc8aba 100644 --- a/netmap/policy.go +++ b/netmap/policy.go @@ -139,6 +139,14 @@ func (r *ReplicaDescriptor) SetNumberOfObjects(c uint32) { r.m.SetCount(c) } +func (r ReplicaDescriptor) SetECDataCount(v uint32) { + r.m.SetECDataCount(v) +} + +func (r ReplicaDescriptor) SetECParityCount(v uint32) { + r.m.SetECParityCount(v) +} + // NumberOfObjects returns number set using SetNumberOfObjects. // // Zero ReplicaDescriptor has zero number of objects. @@ -146,6 +154,19 @@ func (r ReplicaDescriptor) NumberOfObjects() uint32 { return r.m.GetCount() } +func (r ReplicaDescriptor) GetECDataCount() uint32 { + return r.m.GetECDataCount() +} + +func (r ReplicaDescriptor) GetECParityCount() uint32 { + return r.m.GetECParityCount() +} + +// TotalECPartCount returns total sum of ECDataCount and ECParityCount. +func (r ReplicaDescriptor) TotalECPartCount() uint32 { + return r.m.GetECDataCount() + r.m.GetECParityCount() +} + // SetSelectorName sets name of the related Selector. // // Zero ReplicaDescriptor references to the root bucket's selector: it contains @@ -179,10 +200,19 @@ func (p PlacementPolicy) NumberOfReplicas() int { // descriptor. Index MUST be in range [0; NumberOfReplicas()). // // Zero PlacementPolicy has no replicas. +// +// Deprecated: Use PlacementPolicy.ReplicaDescriptor(int).NumberOfObjects() instead. func (p PlacementPolicy) ReplicaNumberByIndex(i int) uint32 { return p.replicas[i].GetCount() } +// ReplicaDescriptor returns i-th replica descriptor. Index MUST be in range [0; NumberOfReplicas()). +func (p PlacementPolicy) ReplicaDescriptor(i int) ReplicaDescriptor { + return ReplicaDescriptor{ + m: p.replicas[i], + } +} + // SetContainerBackupFactor sets container backup factor: it controls how deep // FrostFS will search for nodes alternatives to include into container's nodes subset. //