From 3d7d074af4377ce14a328996260c6abfbc3659e3 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 15 Feb 2021 15:02:22 +0300 Subject: [PATCH] [#377] shard: Support batch Inhume operation Replace single target address in `InhumePrm` with the list of addresses. Change corresponding parameter in `WithTarget` and `MarkAsGarbage` methods to variadic. Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/engine/inhume.go | 2 +- pkg/local_object_storage/shard/inhume.go | 14 +++++++------- pkg/local_object_storage/shard/inhume_test.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/local_object_storage/engine/inhume.go b/pkg/local_object_storage/engine/inhume.go index 24fca3b39..d82f0e64a 100644 --- a/pkg/local_object_storage/engine/inhume.go +++ b/pkg/local_object_storage/engine/inhume.go @@ -32,7 +32,7 @@ var errInhumeFailure = errors.New("inhume operation failed") // Inhume calls metabase. Inhume method to mark object as removed. It won't be // removed physically from shard until `Delete` operation. func (e *StorageEngine) Inhume(prm *InhumePrm) (*InhumeRes, error) { - shPrm := new(shard.InhumePrm).WithTarget(prm.addr, prm.tombstone) + shPrm := new(shard.InhumePrm).WithTarget(prm.tombstone, prm.addr) res := e.inhume(prm.addr, shPrm, true) if res == nil { diff --git a/pkg/local_object_storage/shard/inhume.go b/pkg/local_object_storage/shard/inhume.go index 0246a4775..b81901ebd 100644 --- a/pkg/local_object_storage/shard/inhume.go +++ b/pkg/local_object_storage/shard/inhume.go @@ -8,21 +8,21 @@ import ( // InhumePrm encapsulates parameters for inhume operation. type InhumePrm struct { - target *objectSDK.Address + target []*objectSDK.Address tombstone *objectSDK.Address } // InhumeRes encapsulates results of inhume operation. type InhumeRes struct{} -// WithTarget sets object address that should be inhumed and tombstone address +// WithTarget sets list of objects that should be inhumed and tombstone address // as the reason for inhume operation. // -// Arguments should not be nil. +// tombstone should not be nil, addr should not be empty. // Should not be called along with MarkAsGarbage. -func (p *InhumePrm) WithTarget(addr, tombstone *objectSDK.Address) *InhumePrm { +func (p *InhumePrm) WithTarget(tombstone *objectSDK.Address, addrs ...*objectSDK.Address) *InhumePrm { if p != nil { - p.target = addr + p.target = addrs p.tombstone = tombstone } @@ -32,7 +32,7 @@ func (p *InhumePrm) WithTarget(addr, tombstone *objectSDK.Address) *InhumePrm { // MarkAsGarbage marks object to be physically removed from shard. // // Should not be called along with WithTarget. -func (p *InhumePrm) MarkAsGarbage(addr *objectSDK.Address) *InhumePrm { +func (p *InhumePrm) MarkAsGarbage(addr ...*objectSDK.Address) *InhumePrm { if p != nil { p.target = addr p.tombstone = nil @@ -44,7 +44,7 @@ func (p *InhumePrm) MarkAsGarbage(addr *objectSDK.Address) *InhumePrm { // Inhume calls metabase. Inhume method to mark object as removed. It won't be // removed physically from blobStor and metabase until `Delete` operation. func (s *Shard) Inhume(prm *InhumePrm) (*InhumeRes, error) { - metaPrm := new(meta.InhumePrm).WithAddress(prm.target) + metaPrm := new(meta.InhumePrm).WithAddresses(prm.target...) if prm.tombstone != nil { metaPrm.WithTombstoneAddress(prm.tombstone) diff --git a/pkg/local_object_storage/shard/inhume_test.go b/pkg/local_object_storage/shard/inhume_test.go index 1c3b3c4a4..14cab27aa 100644 --- a/pkg/local_object_storage/shard/inhume_test.go +++ b/pkg/local_object_storage/shard/inhume_test.go @@ -38,7 +38,7 @@ func testShardInhume(t *testing.T, sh *shard.Shard) { putPrm.WithObject(obj.Object()) inhPrm := new(shard.InhumePrm) - inhPrm.WithTarget(obj.Object().Address(), ts.Object().Address()) + inhPrm.WithTarget(ts.Object().Address(), obj.Object().Address()) getPrm := new(shard.GetPrm) getPrm.WithAddress(obj.Object().Address())