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
|
@ -26,7 +26,7 @@ import (
|
|||
func TestBuryObjectWithoutContainer(t *testing.T) {
|
||||
// Key space
|
||||
addr := oidtest.Address()
|
||||
objs := []objectcore.AddressWithType{
|
||||
objs := []objectcore.Info{
|
||||
{
|
||||
Address: addr,
|
||||
Type: objectSDK.TypeRegular,
|
||||
|
@ -78,6 +78,7 @@ func TestProcessObject(t *testing.T) {
|
|||
maintenanceNodes []int
|
||||
wantRemoveRedundant bool
|
||||
wantReplicateTo []int
|
||||
ecInfo *objectcore.ECInfo
|
||||
}{
|
||||
{
|
||||
desc: "1 copy already held by local node",
|
||||
|
@ -144,6 +145,47 @@ func TestProcessObject(t *testing.T) {
|
|||
objHolders: []int{1},
|
||||
maintenanceNodes: []int{2},
|
||||
},
|
||||
{
|
||||
desc: "lock object must be replicated to all EC nodes",
|
||||
objType: objectSDK.TypeLock,
|
||||
nodeCount: 3,
|
||||
policy: `EC 1.1`,
|
||||
placement: [][]int{{0, 1, 2}},
|
||||
wantReplicateTo: []int{1, 2},
|
||||
},
|
||||
{
|
||||
desc: "tombstone object must be replicated to all EC nodes",
|
||||
objType: objectSDK.TypeTombstone,
|
||||
nodeCount: 3,
|
||||
policy: `EC 1.1`,
|
||||
placement: [][]int{{0, 1, 2}},
|
||||
wantReplicateTo: []int{1, 2},
|
||||
},
|
||||
{
|
||||
desc: "EC chunk stored valid on current node",
|
||||
objType: objectSDK.TypeRegular,
|
||||
nodeCount: 2,
|
||||
policy: `EC 1.1`,
|
||||
placement: [][]int{{0}},
|
||||
ecInfo: &objectcore.ECInfo{
|
||||
ParentID: oidtest.ID(),
|
||||
Index: 1,
|
||||
Total: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "EC chunk must be replicated to other EC node",
|
||||
objType: objectSDK.TypeRegular,
|
||||
nodeCount: 2,
|
||||
policy: `EC 1.1`,
|
||||
placement: [][]int{{1}},
|
||||
wantReplicateTo: []int{1},
|
||||
ecInfo: &objectcore.ECInfo{
|
||||
ParentID: oidtest.ID(),
|
||||
Index: 1,
|
||||
Total: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i := range tests {
|
||||
|
@ -173,6 +215,9 @@ func TestProcessObject(t *testing.T) {
|
|||
if cnr.Equals(addr.Container()) && obj != nil && obj.Equals(addr.Object()) {
|
||||
return placementVectors, nil
|
||||
}
|
||||
if ti.ecInfo != nil && cnr.Equals(addr.Container()) && obj != nil && obj.Equals(ti.ecInfo.ParentID) {
|
||||
return placementVectors, nil
|
||||
}
|
||||
t.Errorf("unexpected placement build: cid=%v oid=%v", cnr, obj)
|
||||
return nil, errors.New("unexpected placement build")
|
||||
}
|
||||
|
@ -238,9 +283,10 @@ func TestProcessObject(t *testing.T) {
|
|||
WithPool(testPool(t)),
|
||||
)
|
||||
|
||||
addrWithType := objectcore.AddressWithType{
|
||||
addrWithType := objectcore.Info{
|
||||
Address: addr,
|
||||
Type: ti.objType,
|
||||
ECInfo: ti.ecInfo,
|
||||
}
|
||||
|
||||
err := p.processObject(context.Background(), addrWithType)
|
||||
|
@ -276,7 +322,7 @@ func TestProcessObjectError(t *testing.T) {
|
|||
WithPool(testPool(t)),
|
||||
)
|
||||
|
||||
addrWithType := objectcore.AddressWithType{
|
||||
addrWithType := objectcore.Info{
|
||||
Address: addr,
|
||||
}
|
||||
|
||||
|
@ -285,7 +331,7 @@ func TestProcessObjectError(t *testing.T) {
|
|||
|
||||
func TestIteratorContract(t *testing.T) {
|
||||
addr := oidtest.Address()
|
||||
objs := []objectcore.AddressWithType{{
|
||||
objs := []objectcore.Info{{
|
||||
Address: addr,
|
||||
Type: objectSDK.TypeRegular,
|
||||
}}
|
||||
|
@ -350,7 +396,7 @@ func testPool(t *testing.T) *ants.Pool {
|
|||
}
|
||||
|
||||
type nextResult struct {
|
||||
objs []objectcore.AddressWithType
|
||||
objs []objectcore.Info
|
||||
err error
|
||||
}
|
||||
|
||||
|
@ -361,7 +407,7 @@ type predefinedIterator struct {
|
|||
calls []string
|
||||
}
|
||||
|
||||
func (it *predefinedIterator) Next(ctx context.Context, size uint32) ([]objectcore.AddressWithType, error) {
|
||||
func (it *predefinedIterator) Next(ctx context.Context, size uint32) ([]objectcore.Info, error) {
|
||||
if it.pos == len(it.scenario) {
|
||||
close(it.finishCh)
|
||||
<-ctx.Done()
|
||||
|
@ -380,11 +426,11 @@ func (it *predefinedIterator) Rewind() {
|
|||
|
||||
// sliceKeySpaceIterator is a KeySpaceIterator backed by a slice.
|
||||
type sliceKeySpaceIterator struct {
|
||||
objs []objectcore.AddressWithType
|
||||
objs []objectcore.Info
|
||||
cur int
|
||||
}
|
||||
|
||||
func (it *sliceKeySpaceIterator) Next(_ context.Context, size uint32) ([]objectcore.AddressWithType, error) {
|
||||
func (it *sliceKeySpaceIterator) Next(_ context.Context, size uint32) ([]objectcore.Info, error) {
|
||||
if it.cur >= len(it.objs) {
|
||||
return nil, engine.ErrEndOfListing
|
||||
}
|
||||
|
@ -422,6 +468,6 @@ func (f announcedKeysFunc) IsLocalKey(k []byte) bool { return f(k) }
|
|||
// replicatorFunc is a Replicator backed by a function.
|
||||
type replicatorFunc func(context.Context, replicator.Task, replicator.TaskResult)
|
||||
|
||||
func (f replicatorFunc) HandleTask(ctx context.Context, task replicator.Task, res replicator.TaskResult) {
|
||||
func (f replicatorFunc) HandleReplicationTask(ctx context.Context, task replicator.Task, res replicator.TaskResult) {
|
||||
f(ctx, task, res)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue