forked from TrueCloudLab/frostfs-node
[#1064] putsvc: Add EC put
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
39da643354
commit
1c5e0f90aa
11 changed files with 452 additions and 23 deletions
11
pkg/core/container/ec.go
Normal file
11
pkg/core/container/ec.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/policy"
|
||||
containerSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||
)
|
||||
|
||||
// IsECContainer returns True if container has erasure coding policy.
|
||||
func IsECContainer(cnr containerSDK.Container) bool {
|
||||
return policy.IsECPlacement(cnr.PlacementPolicy())
|
||||
}
|
13
pkg/core/object/ec.go
Normal file
13
pkg/core/object/ec.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package object
|
||||
|
||||
import (
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
)
|
||||
|
||||
// IsECSupported returns True if EC supported for object.
|
||||
//
|
||||
// EC supported only for regular, not linking objects.
|
||||
func IsECSupported(obj *objectSDK.Object) bool {
|
||||
return obj.Type() == objectSDK.TypeRegular &&
|
||||
len(obj.Children()) == 0
|
||||
}
|
20
pkg/core/policy/ec.go
Normal file
20
pkg/core/policy/ec.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package policy
|
||||
|
||||
import (
|
||||
netmapSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||
)
|
||||
|
||||
// IsECPlacement returns True if policy is erasure coding policy.
|
||||
func IsECPlacement(policy netmapSDK.PlacementPolicy) bool {
|
||||
return policy.NumberOfReplicas() == 1 && policy.ReplicaDescriptor(0).GetECDataCount() > 0
|
||||
}
|
||||
|
||||
// ECDataCount returns EC data count for EC placement policy.
|
||||
func ECDataCount(policy netmapSDK.PlacementPolicy) int {
|
||||
return int(policy.ReplicaDescriptor(0).GetECDataCount())
|
||||
}
|
||||
|
||||
// ECParityCount returns EC parity count for EC placement policy.
|
||||
func ECParityCount(policy netmapSDK.PlacementPolicy) int {
|
||||
return int(policy.ReplicaDescriptor(0).GetECParityCount())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue