netmap: Introduce Replica method #211
5 changed files with 44 additions and 5 deletions
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.frostfs.info/TrueCloudLab/frostfs-sdk-go
|
|||
go 1.20
|
||||
|
||||
require (
|
||||
aarifullin marked this conversation as resolved
Outdated
|
||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240319122301-1772b921826b
|
||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240327095603-491a47e7fe24
|
||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230307110621-19a8ef2d02fb
|
||||
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0
|
||||
git.frostfs.info/TrueCloudLab/hrw v1.2.1
|
||||
|
|
4
go.sum
4
go.sum
|
@ -31,8 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
|
|||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240319122301-1772b921826b h1:PoGgzbf+uU+aPJb8etqAqaeoImLYRickZyf/nQ7+vcY=
|
||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240319122301-1772b921826b/go.mod h1:OBDSr+DqV1z4VDouoX3YMleNc4DPBVBWTG3WDT2PK1o=
|
||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240327095603-491a47e7fe24 h1:uIkl0mKWwDICUZTbNWZ38HLYDBI9rMgdAhYQWZ0C9iQ=
|
||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240327095603-491a47e7fe24/go.mod h1:OBDSr+DqV1z4VDouoX3YMleNc4DPBVBWTG3WDT2PK1o=
|
||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230307110621-19a8ef2d02fb h1:S/TrbOOu9qEXZRZ9/Ddw7crnxbBUQLo68PSzQWYrc9M=
|
||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230307110621-19a8ef2d02fb/go.mod h1:nkR5gaGeez3Zv2SE7aceP0YwxG2FzIB5cGKpQO2vV2o=
|
||||
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 h1:FxqFDhQYYgpe41qsIHVOcdzSVCB8JNSfPG7Uk4r2oSk=
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -44,12 +44,12 @@ func (c *Constructor) Split(obj *objectSDK.Object, key *ecdsa.PrivateKey) ([]*ob
|
|||
}
|
||||
|
||||
func setIDWithSignature(obj *objectSDK.Object, key *ecdsa.PrivateKey) error {
|
||||
objectSDK.CalculateAndSetPayloadChecksum(obj)
|
||||
fyrchik
commented
Is there some test that fails with the old behaviour? The change seems pretty important, could you write such test? Is there some test that fails with the old behaviour? The change seems pretty important, could you write such test?
dstepanov-yadro
commented
To check: create parts, then validate header by To check: create parts, then validate header by `CheckHeaderVerificationFields`
aarifullin
commented
I added header verification in I added header verification in `TestSplitMaxShardCount` for both cases. Is that okay?
It seems it is better to verify it not with separte unit-test for `setIDWithSignature` but when parts are created!
|
||||
|
||||
if err := objectSDK.CalculateAndSetID(obj); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
objectSDK.CalculateAndSetPayloadChecksum(obj)
|
||||
|
||||
if key == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package erasurecode_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/erasurecode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -23,6 +24,10 @@ func TestSplitMaxShardCount(t *testing.T) {
|
|||
parts, err := c.Split(original, &pk.PrivateKey)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, parts, erasurecode.MaxShardCount)
|
||||
|
||||
for _, part := range parts {
|
||||
require.NoError(t, objectSDK.CheckHeaderVerificationFields(part))
|
||||
}
|
||||
})
|
||||
t.Run("data + parity", func(t *testing.T) {
|
||||
c, err := erasurecode.NewConstructor(1, erasurecode.MaxShardCount-1)
|
||||
|
@ -31,6 +36,10 @@ func TestSplitMaxShardCount(t *testing.T) {
|
|||
parts, err := c.Split(original, &pk.PrivateKey)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, parts, erasurecode.MaxShardCount)
|
||||
|
||||
for _, part := range parts {
|
||||
require.NoError(t, objectSDK.CheckHeaderVerificationFields(part))
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue
This will be fixed as soon as #70 is merged
It is merged.