forked from TrueCloudLab/frostfs-node
[#1559] metabase: Use Set
prefix for parameter setting
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
f58234aa2f
commit
34d319fed2
32 changed files with 150 additions and 181 deletions
|
@ -52,7 +52,7 @@ func TestReset(t *testing.T) {
|
|||
|
||||
func metaExists(db *meta.DB, addr oid.Address) (bool, error) {
|
||||
var existsPrm meta.ExistsPrm
|
||||
existsPrm.WithAddress(addr)
|
||||
existsPrm.SetAddress(addr)
|
||||
|
||||
res, err := db.Exists(existsPrm)
|
||||
return res.Exists(), err
|
||||
|
|
|
@ -21,14 +21,12 @@ type DeletePrm struct {
|
|||
// DeleteRes groups the resulting values of Delete operation.
|
||||
type DeleteRes struct{}
|
||||
|
||||
// WithAddresses is a Delete option to set the addresses of the objects to delete.
|
||||
// SetAddresses is a Delete option to set the addresses of the objects to delete.
|
||||
//
|
||||
// Option is required.
|
||||
func (p *DeletePrm) WithAddresses(addrs ...oid.Address) {
|
||||
if p != nil {
|
||||
func (p *DeletePrm) SetAddresses(addrs ...oid.Address) {
|
||||
p.addrs = addrs
|
||||
}
|
||||
}
|
||||
|
||||
type referenceNumber struct {
|
||||
all, cur int
|
||||
|
|
|
@ -120,7 +120,7 @@ func TestGraveOnlyDelete(t *testing.T) {
|
|||
|
||||
func metaDelete(db *meta.DB, addrs ...oid.Address) error {
|
||||
var deletePrm meta.DeletePrm
|
||||
deletePrm.WithAddresses(addrs...)
|
||||
deletePrm.SetAddresses(addrs...)
|
||||
|
||||
_, err := db.Delete(deletePrm)
|
||||
return err
|
||||
|
|
|
@ -23,12 +23,10 @@ type ExistsRes struct {
|
|||
|
||||
var ErrLackSplitInfo = errors.New("no split info on parent object")
|
||||
|
||||
// WithAddress is an Exists option to set object checked for existence.
|
||||
func (p *ExistsPrm) WithAddress(addr oid.Address) {
|
||||
if p != nil {
|
||||
// SetAddress is an Exists option to set object checked for existence.
|
||||
func (p *ExistsPrm) SetAddress(addr oid.Address) {
|
||||
p.addr = addr
|
||||
}
|
||||
}
|
||||
|
||||
// Exists returns the fact that the object is in the metabase.
|
||||
func (p ExistsRes) Exists() bool {
|
||||
|
|
|
@ -21,23 +21,19 @@ type GetRes struct {
|
|||
hdr *objectSDK.Object
|
||||
}
|
||||
|
||||
// WithAddress is a Get option to set the address of the requested object.
|
||||
// SetAddress is a Get option to set the address of the requested object.
|
||||
//
|
||||
// Option is required.
|
||||
func (p *GetPrm) WithAddress(addr oid.Address) {
|
||||
if p != nil {
|
||||
func (p *GetPrm) SetAddress(addr oid.Address) {
|
||||
p.addr = addr
|
||||
}
|
||||
}
|
||||
|
||||
// WithRaw is a Get option to set raw flag value. If flag is unset, then Get
|
||||
// SetRaw is a Get option to set raw flag value. If flag is unset, then Get
|
||||
// returns header of virtual object, otherwise it returns SplitInfo of virtual
|
||||
// object.
|
||||
func (p *GetPrm) WithRaw(raw bool) {
|
||||
if p != nil {
|
||||
func (p *GetPrm) SetRaw(raw bool) {
|
||||
p.raw = raw
|
||||
}
|
||||
}
|
||||
|
||||
// Header returns the requested object header.
|
||||
func (r GetRes) Header() *objectSDK.Object {
|
||||
|
|
|
@ -128,7 +128,7 @@ func TestDB_Get(t *testing.T) {
|
|||
obj = oidtest.Address()
|
||||
|
||||
var prm meta.InhumePrm
|
||||
prm.WithAddresses(obj)
|
||||
prm.SetAddresses(obj)
|
||||
|
||||
_, err = db.Inhume(prm)
|
||||
require.NoError(t, err)
|
||||
|
@ -189,11 +189,11 @@ func benchmarkGet(b *testing.B, numOfObj int) {
|
|||
b.ResetTimer()
|
||||
|
||||
var getPrm meta.GetPrm
|
||||
getPrm.WithAddress(addrs[len(addrs)/2])
|
||||
getPrm.SetAddress(addrs[len(addrs)/2])
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, addr := range addrs {
|
||||
getPrm.WithAddress(addr)
|
||||
getPrm.SetAddress(addr)
|
||||
|
||||
res, err := db.Get(getPrm)
|
||||
require.NoError(b, err)
|
||||
|
@ -206,8 +206,8 @@ func benchmarkGet(b *testing.B, numOfObj int) {
|
|||
|
||||
func metaGet(db *meta.DB, addr oid.Address, raw bool) (*objectSDK.Object, error) {
|
||||
var prm meta.GetPrm
|
||||
prm.WithAddress(addr)
|
||||
prm.WithRaw(raw)
|
||||
prm.SetAddress(addr)
|
||||
prm.SetRaw(raw)
|
||||
|
||||
res, err := db.Get(prm)
|
||||
return res.Header(), err
|
||||
|
|
|
@ -64,8 +64,8 @@ func TestDB_Iterate_OffsetNotFound(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithAddresses(object.AddressOf(obj1))
|
||||
inhumePrm.WithGCMark()
|
||||
inhumePrm.SetAddresses(object.AddressOf(obj1))
|
||||
inhumePrm.SetGCMark()
|
||||
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
@ -134,14 +134,14 @@ func TestDB_IterateDeletedObjects(t *testing.T) {
|
|||
// inhume with tombstone
|
||||
addrTombstone := oidtest.Address()
|
||||
|
||||
inhumePrm.WithAddresses(object.AddressOf(obj1), object.AddressOf(obj2))
|
||||
inhumePrm.WithTombstoneAddress(addrTombstone)
|
||||
inhumePrm.SetAddresses(object.AddressOf(obj1), object.AddressOf(obj2))
|
||||
inhumePrm.SetTombstoneAddress(addrTombstone)
|
||||
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
inhumePrm.WithAddresses(object.AddressOf(obj3), object.AddressOf(obj4))
|
||||
inhumePrm.WithGCMark()
|
||||
inhumePrm.SetAddresses(object.AddressOf(obj3), object.AddressOf(obj4))
|
||||
inhumePrm.SetGCMark()
|
||||
|
||||
// inhume with GC mark
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
|
@ -219,10 +219,10 @@ func TestDB_IterateOverGraveyard_Offset(t *testing.T) {
|
|||
addrTombstone := oidtest.Address()
|
||||
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithAddresses(
|
||||
inhumePrm.SetAddresses(
|
||||
object.AddressOf(obj1), object.AddressOf(obj2),
|
||||
object.AddressOf(obj3), object.AddressOf(obj4))
|
||||
inhumePrm.WithTombstoneAddress(addrTombstone)
|
||||
inhumePrm.SetTombstoneAddress(addrTombstone)
|
||||
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
@ -314,10 +314,10 @@ func TestDB_IterateOverGarbage_Offset(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithAddresses(
|
||||
inhumePrm.SetAddresses(
|
||||
object.AddressOf(obj1), object.AddressOf(obj2),
|
||||
object.AddressOf(obj3), object.AddressOf(obj4))
|
||||
inhumePrm.WithGCMark()
|
||||
inhumePrm.SetGCMark()
|
||||
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
@ -400,8 +400,8 @@ func TestDB_DropGraves(t *testing.T) {
|
|||
addrTombstone := oidtest.Address()
|
||||
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithAddresses(object.AddressOf(obj1), object.AddressOf(obj2))
|
||||
inhumePrm.WithTombstoneAddress(addrTombstone)
|
||||
inhumePrm.SetAddresses(object.AddressOf(obj1), object.AddressOf(obj2))
|
||||
inhumePrm.SetTombstoneAddress(addrTombstone)
|
||||
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -34,49 +34,38 @@ func (i InhumeRes) DeletedLockObjects() []oid.Address {
|
|||
return i.deletedLockObj
|
||||
}
|
||||
|
||||
// WithAddresses sets a list of object addresses that should be inhumed.
|
||||
func (p *InhumePrm) WithAddresses(addrs ...oid.Address) {
|
||||
if p != nil {
|
||||
// SetAddresses sets a list of object addresses that should be inhumed.
|
||||
func (p *InhumePrm) SetAddresses(addrs ...oid.Address) {
|
||||
p.target = addrs
|
||||
}
|
||||
}
|
||||
|
||||
// WithTombstoneAddress sets tombstone address as the reason for inhume operation.
|
||||
// SetTombstoneAddress sets tombstone address as the reason for inhume operation.
|
||||
//
|
||||
// addr should not be nil.
|
||||
// Should not be called along with WithGCMark.
|
||||
func (p *InhumePrm) WithTombstoneAddress(addr oid.Address) {
|
||||
if p != nil {
|
||||
// Should not be called along with SetGCMark.
|
||||
func (p *InhumePrm) SetTombstoneAddress(addr oid.Address) {
|
||||
p.tomb = &addr
|
||||
}
|
||||
}
|
||||
|
||||
// WithGCMark marks the object to be physically removed.
|
||||
// SetGCMark marks the object to be physically removed.
|
||||
//
|
||||
// Should not be called along with WithTombstoneAddress.
|
||||
func (p *InhumePrm) WithGCMark() {
|
||||
if p != nil {
|
||||
// Should not be called along with SetTombstoneAddress.
|
||||
func (p *InhumePrm) SetGCMark() {
|
||||
p.tomb = nil
|
||||
p.forceRemoval = false
|
||||
}
|
||||
}
|
||||
|
||||
// WithLockObjectHandling checks if there were
|
||||
// SetLockObjectHandling checks if there were
|
||||
// any LOCK object among the targets set via WithAddresses.
|
||||
func (p *InhumePrm) WithLockObjectHandling() {
|
||||
if p != nil {
|
||||
func (p *InhumePrm) SetLockObjectHandling() {
|
||||
p.lockObjectHandling = true
|
||||
}
|
||||
}
|
||||
|
||||
// WithForceGCMark allows removal any object. Expected to be
|
||||
// SetForceGCMark allows removal any object. Expected to be
|
||||
// called only in control service.
|
||||
func (p *InhumePrm) WithForceGCMark() {
|
||||
if p != nil {
|
||||
func (p *InhumePrm) SetForceGCMark() {
|
||||
p.tomb = nil
|
||||
p.forceRemoval = true
|
||||
}
|
||||
}
|
||||
|
||||
var errBreakBucketForEach = errors.New("bucket ForEach break")
|
||||
|
||||
|
|
|
@ -45,21 +45,21 @@ func TestInhumeTombOnTomb(t *testing.T) {
|
|||
existsPrm meta.ExistsPrm
|
||||
)
|
||||
|
||||
inhumePrm.WithAddresses(addr1)
|
||||
inhumePrm.WithTombstoneAddress(addr2)
|
||||
inhumePrm.SetAddresses(addr1)
|
||||
inhumePrm.SetTombstoneAddress(addr2)
|
||||
|
||||
// inhume addr1 via addr2
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
existsPrm.WithAddress(addr1)
|
||||
existsPrm.SetAddress(addr1)
|
||||
|
||||
// addr1 should become inhumed {addr1:addr2}
|
||||
_, err = db.Exists(existsPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
|
||||
inhumePrm.WithAddresses(addr3)
|
||||
inhumePrm.WithTombstoneAddress(addr1)
|
||||
inhumePrm.SetAddresses(addr3)
|
||||
inhumePrm.SetTombstoneAddress(addr1)
|
||||
|
||||
// try to inhume addr3 via addr1
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
|
@ -72,20 +72,20 @@ func TestInhumeTombOnTomb(t *testing.T) {
|
|||
_, err = db.Exists(existsPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
|
||||
existsPrm.WithAddress(addr3)
|
||||
existsPrm.SetAddress(addr3)
|
||||
|
||||
// addr3 should be inhumed {addr3: addr1}
|
||||
_, err = db.Exists(existsPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
|
||||
inhumePrm.WithAddresses(addr1)
|
||||
inhumePrm.WithTombstoneAddress(oidtest.Address())
|
||||
inhumePrm.SetAddresses(addr1)
|
||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||
|
||||
// try to inhume addr1 (which is already a tombstone in graveyard)
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
existsPrm.WithAddress(addr1)
|
||||
existsPrm.SetAddress(addr1)
|
||||
|
||||
// record with addr1 key should not appear in graveyard
|
||||
// (tomb can not be inhumed) but should be kept as object
|
||||
|
@ -103,7 +103,7 @@ func TestInhumeLocked(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
var prm meta.InhumePrm
|
||||
prm.WithAddresses(locked)
|
||||
prm.SetAddresses(locked)
|
||||
|
||||
_, err = db.Inhume(prm)
|
||||
|
||||
|
@ -113,8 +113,8 @@ func TestInhumeLocked(t *testing.T) {
|
|||
|
||||
func metaInhume(db *meta.DB, target, tomb oid.Address) error {
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithAddresses(target)
|
||||
inhumePrm.WithTombstoneAddress(tomb)
|
||||
inhumePrm.SetAddresses(target)
|
||||
inhumePrm.SetTombstoneAddress(tomb)
|
||||
|
||||
_, err := db.Inhume(inhumePrm)
|
||||
return err
|
||||
|
|
|
@ -77,14 +77,14 @@ func TestDB_IterateCoveredByTombstones(t *testing.T) {
|
|||
var prm meta.InhumePrm
|
||||
var err error
|
||||
|
||||
prm.WithAddresses(protected1, protected2, protectedLocked)
|
||||
prm.WithTombstoneAddress(ts)
|
||||
prm.SetAddresses(protected1, protected2, protectedLocked)
|
||||
prm.SetTombstoneAddress(ts)
|
||||
|
||||
_, err = db.Inhume(prm)
|
||||
require.NoError(t, err)
|
||||
|
||||
prm.WithAddresses(garbage)
|
||||
prm.WithGCMark()
|
||||
prm.SetAddresses(garbage)
|
||||
prm.SetGCMark()
|
||||
|
||||
_, err = db.Inhume(prm)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -26,15 +26,15 @@ type ListPrm struct {
|
|||
cursor *Cursor
|
||||
}
|
||||
|
||||
// WithCount sets maximum amount of addresses that ListWithCursor should return.
|
||||
func (l *ListPrm) WithCount(count uint32) {
|
||||
// SetCount sets maximum amount of addresses that ListWithCursor should return.
|
||||
func (l *ListPrm) SetCount(count uint32) {
|
||||
l.count = int(count)
|
||||
}
|
||||
|
||||
// WithCursor sets cursor for ListWithCursor operation. For initial request
|
||||
// SetCursor sets cursor for ListWithCursor operation. For initial request
|
||||
// ignore this param or use nil value. For consecutive requests, use value
|
||||
// from ListRes.
|
||||
func (l *ListPrm) WithCursor(cursor *Cursor) {
|
||||
func (l *ListPrm) SetCursor(cursor *Cursor) {
|
||||
l.cursor = cursor
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ func listWithCursorPrepareDB(b *testing.B) *meta.DB {
|
|||
|
||||
func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) {
|
||||
var prm meta.ListPrm
|
||||
prm.WithCount(uint32(batchSize))
|
||||
prm.SetCount(uint32(batchSize))
|
||||
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
|
@ -56,11 +56,11 @@ func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) {
|
|||
if err != meta.ErrEndOfListing {
|
||||
b.Fatalf("error: %v", err)
|
||||
}
|
||||
prm.WithCursor(nil)
|
||||
prm.SetCursor(nil)
|
||||
} else if ln := len(res.AddressList()); ln != batchSize {
|
||||
b.Fatalf("invalid batch size: %d", ln)
|
||||
} else {
|
||||
prm.WithCursor(res.Cursor())
|
||||
prm.SetCursor(res.Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,8 +225,8 @@ func sortAddresses(addr []oid.Address) []oid.Address {
|
|||
|
||||
func metaListWithCursor(db *meta.DB, count uint32, cursor *meta.Cursor) ([]oid.Address, *meta.Cursor, error) {
|
||||
var listPrm meta.ListPrm
|
||||
listPrm.WithCount(count)
|
||||
listPrm.WithCursor(cursor)
|
||||
listPrm.SetCount(count)
|
||||
listPrm.SetCursor(cursor)
|
||||
|
||||
r, err := db.ListWithCursor(listPrm)
|
||||
return r.AddressList(), r.Cursor(), err
|
||||
|
|
|
@ -59,31 +59,31 @@ func TestDB_Lock(t *testing.T) {
|
|||
lockAddr := objectcore.AddressOf(lockObj)
|
||||
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithGCMark()
|
||||
inhumePrm.SetGCMark()
|
||||
|
||||
// check locking relation
|
||||
|
||||
inhumePrm.WithAddresses(objAddr)
|
||||
inhumePrm.SetAddresses(objAddr)
|
||||
_, err := db.Inhume(inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
|
||||
inhumePrm.WithTombstoneAddress(oidtest.Address())
|
||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
|
||||
// try to remove lock object
|
||||
inhumePrm.WithAddresses(lockAddr)
|
||||
inhumePrm.SetAddresses(lockAddr)
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.Error(t, err)
|
||||
|
||||
// check that locking relation has not been
|
||||
// dropped
|
||||
|
||||
inhumePrm.WithAddresses(objAddr)
|
||||
inhumePrm.SetAddresses(objAddr)
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
|
||||
inhumePrm.WithTombstoneAddress(oidtest.Address())
|
||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
})
|
||||
|
@ -100,9 +100,9 @@ func TestDB_Lock(t *testing.T) {
|
|||
|
||||
// free locked object
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithAddresses(lockAddr)
|
||||
inhumePrm.WithForceGCMark()
|
||||
inhumePrm.WithLockObjectHandling()
|
||||
inhumePrm.SetAddresses(lockAddr)
|
||||
inhumePrm.SetForceGCMark()
|
||||
inhumePrm.SetLockObjectHandling()
|
||||
|
||||
res, err := db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
@ -112,8 +112,8 @@ func TestDB_Lock(t *testing.T) {
|
|||
err = db.FreeLockedBy([]oid.Address{lockAddr})
|
||||
require.NoError(t, err)
|
||||
|
||||
inhumePrm.WithAddresses(objAddr)
|
||||
inhumePrm.WithGCMark()
|
||||
inhumePrm.SetAddresses(objAddr)
|
||||
inhumePrm.SetGCMark()
|
||||
|
||||
// now we can inhume the object
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
|
@ -129,9 +129,9 @@ func TestDB_Lock(t *testing.T) {
|
|||
// force remove objects
|
||||
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithForceGCMark()
|
||||
inhumePrm.WithAddresses(objectcore.AddressOf(lockObj))
|
||||
inhumePrm.WithLockObjectHandling()
|
||||
inhumePrm.SetForceGCMark()
|
||||
inhumePrm.SetAddresses(objectcore.AddressOf(lockObj))
|
||||
inhumePrm.SetLockObjectHandling()
|
||||
|
||||
res, err := db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
@ -145,10 +145,10 @@ func TestDB_Lock(t *testing.T) {
|
|||
|
||||
// removing objects after unlock
|
||||
|
||||
inhumePrm.WithGCMark()
|
||||
inhumePrm.SetGCMark()
|
||||
|
||||
for i := 0; i < objsNum; i++ {
|
||||
inhumePrm.WithAddresses(objectcore.AddressOf(objs[i]))
|
||||
inhumePrm.SetAddresses(objectcore.AddressOf(objs[i]))
|
||||
|
||||
res, err = db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
@ -160,8 +160,8 @@ func TestDB_Lock(t *testing.T) {
|
|||
_, lockObj := putAndLockObj(t, db, 1)
|
||||
|
||||
var inhumePrm meta.InhumePrm
|
||||
inhumePrm.WithForceGCMark()
|
||||
inhumePrm.WithAddresses(objectcore.AddressOf(lockObj))
|
||||
inhumePrm.SetForceGCMark()
|
||||
inhumePrm.SetAddresses(objectcore.AddressOf(lockObj))
|
||||
|
||||
res, err := db.Inhume(inhumePrm)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -15,12 +15,10 @@ type ToMoveItPrm struct {
|
|||
// ToMoveItRes groups the resulting values of ToMoveIt operation.
|
||||
type ToMoveItRes struct{}
|
||||
|
||||
// WithAddress sets address of the object to move into another shard.
|
||||
func (p *ToMoveItPrm) WithAddress(addr oid.Address) {
|
||||
if p != nil {
|
||||
// SetAddress sets address of the object to move into another shard.
|
||||
func (p *ToMoveItPrm) SetAddress(addr oid.Address) {
|
||||
p.addr = addr
|
||||
}
|
||||
}
|
||||
|
||||
// DoNotMovePrm groups the parameters of DoNotMove operation.
|
||||
type DoNotMovePrm struct {
|
||||
|
@ -30,12 +28,10 @@ type DoNotMovePrm struct {
|
|||
// DoNotMoveRes groups the resulting values of DoNotMove operation.
|
||||
type DoNotMoveRes struct{}
|
||||
|
||||
// WithAddress sets address of the object to prevent moving into another shard.
|
||||
func (p *DoNotMovePrm) WithAddress(addr oid.Address) {
|
||||
if p != nil {
|
||||
// SetAddress sets address of the object to prevent moving into another shard.
|
||||
func (p *DoNotMovePrm) SetAddress(addr oid.Address) {
|
||||
p.addr = addr
|
||||
}
|
||||
}
|
||||
|
||||
// MovablePrm groups the parameters of Movable operation.
|
||||
type MovablePrm struct{}
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestDB_Movable(t *testing.T) {
|
|||
|
||||
func metaToMoveIt(db *meta.DB, addr oid.Address) error {
|
||||
var toMovePrm meta.ToMoveItPrm
|
||||
toMovePrm.WithAddress(addr)
|
||||
toMovePrm.SetAddress(addr)
|
||||
|
||||
_, err := db.ToMoveIt(toMovePrm)
|
||||
return err
|
||||
|
@ -75,7 +75,7 @@ func metaMovable(db *meta.DB) ([]oid.Address, error) {
|
|||
|
||||
func metaDoNotMove(db *meta.DB, addr oid.Address) error {
|
||||
var doNotMovePrm meta.DoNotMovePrm
|
||||
doNotMovePrm.WithAddress(addr)
|
||||
doNotMovePrm.SetAddress(addr)
|
||||
|
||||
_, err := db.DoNotMove(doNotMovePrm)
|
||||
return err
|
||||
|
|
|
@ -33,19 +33,15 @@ type PutPrm struct {
|
|||
// PutRes groups the resulting values of Put operation.
|
||||
type PutRes struct{}
|
||||
|
||||
// WithObject is a Put option to set object to save.
|
||||
func (p *PutPrm) WithObject(obj *objectSDK.Object) {
|
||||
if p != nil {
|
||||
// SetObject is a Put option to set object to save.
|
||||
func (p *PutPrm) SetObject(obj *objectSDK.Object) {
|
||||
p.obj = obj
|
||||
}
|
||||
}
|
||||
|
||||
// WithBlobovniczaID is a Put option to set blobovnicza ID to save.
|
||||
func (p *PutPrm) WithBlobovniczaID(id *blobovnicza.ID) {
|
||||
if p != nil {
|
||||
// SetBlobovniczaID is a Put option to set blobovnicza ID to save.
|
||||
func (p *PutPrm) SetBlobovniczaID(id *blobovnicza.ID) {
|
||||
p.id = id
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
ErrUnknownObjectType = errors.New("unknown object type")
|
||||
|
|
|
@ -114,8 +114,8 @@ func TestDB_PutBlobovnicaUpdate(t *testing.T) {
|
|||
|
||||
func metaPut(db *meta.DB, obj *objectSDK.Object, id *blobovnicza.ID) error {
|
||||
var putPrm meta.PutPrm
|
||||
putPrm.WithObject(obj)
|
||||
putPrm.WithBlobovniczaID(id)
|
||||
putPrm.SetObject(obj)
|
||||
putPrm.SetBlobovniczaID(id)
|
||||
|
||||
_, err := db.Put(putPrm)
|
||||
|
||||
|
|
|
@ -39,19 +39,15 @@ type SelectRes struct {
|
|||
addrList []oid.Address
|
||||
}
|
||||
|
||||
// WithContainerID is a Select option to set the container id to search in.
|
||||
func (p *SelectPrm) WithContainerID(cnr cid.ID) {
|
||||
if p != nil {
|
||||
// SetContainerID is a Select option to set the container id to search in.
|
||||
func (p *SelectPrm) SetContainerID(cnr cid.ID) {
|
||||
p.cnr = cnr
|
||||
}
|
||||
}
|
||||
|
||||
// WithFilters is a Select option to set the object filters.
|
||||
func (p *SelectPrm) WithFilters(fs object.SearchFilters) {
|
||||
if p != nil {
|
||||
// SetFilters is a Select option to set the object filters.
|
||||
func (p *SelectPrm) SetFilters(fs object.SearchFilters) {
|
||||
p.filters = fs
|
||||
}
|
||||
}
|
||||
|
||||
// AddressList returns list of addresses of the selected objects.
|
||||
func (r SelectRes) AddressList() []oid.Address {
|
||||
|
|
|
@ -807,8 +807,8 @@ func BenchmarkSelect(b *testing.B) {
|
|||
|
||||
func benchmarkSelect(b *testing.B, db *meta.DB, cid cidSDK.ID, fs objectSDK.SearchFilters, expected int) {
|
||||
var prm meta.SelectPrm
|
||||
prm.WithContainerID(cid)
|
||||
prm.WithFilters(fs)
|
||||
prm.SetContainerID(cid)
|
||||
prm.SetFilters(fs)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
res, err := db.Select(prm)
|
||||
|
@ -823,8 +823,8 @@ func benchmarkSelect(b *testing.B, db *meta.DB, cid cidSDK.ID, fs objectSDK.Sear
|
|||
|
||||
func metaSelect(db *meta.DB, cnr cidSDK.ID, fs objectSDK.SearchFilters) ([]oid.Address, error) {
|
||||
var prm meta.SelectPrm
|
||||
prm.WithFilters(fs)
|
||||
prm.WithContainerID(cnr)
|
||||
prm.SetFilters(fs)
|
||||
prm.SetContainerID(cnr)
|
||||
|
||||
res, err := db.Select(prm)
|
||||
return res.AddressList(), err
|
||||
|
|
|
@ -121,8 +121,8 @@ func (s *Shard) refillMetabase() error {
|
|||
|
||||
var inhumePrm meta.InhumePrm
|
||||
|
||||
inhumePrm.WithTombstoneAddress(tombAddr)
|
||||
inhumePrm.WithAddresses(tombMembers...)
|
||||
inhumePrm.SetTombstoneAddress(tombAddr)
|
||||
inhumePrm.SetAddresses(tombMembers...)
|
||||
|
||||
_, err = s.metaBase.Inhume(inhumePrm)
|
||||
if err != nil {
|
||||
|
@ -146,8 +146,8 @@ func (s *Shard) refillMetabase() error {
|
|||
}
|
||||
|
||||
var mPrm meta.PutPrm
|
||||
mPrm.WithObject(obj)
|
||||
mPrm.WithBlobovniczaID(blzID)
|
||||
mPrm.SetObject(obj)
|
||||
mPrm.SetBlobovniczaID(blzID)
|
||||
|
||||
_, err := s.metaBase.Put(mPrm)
|
||||
if err != nil && !meta.IsErrRemoved(err) {
|
||||
|
|
|
@ -65,7 +65,7 @@ func (s *Shard) Delete(prm DeletePrm) (DeleteRes, error) {
|
|||
}
|
||||
|
||||
var delPrm meta.DeletePrm
|
||||
delPrm.WithAddresses(prm.addr...)
|
||||
delPrm.SetAddresses(prm.addr...)
|
||||
|
||||
_, err := s.metaBase.Delete(delPrm)
|
||||
if err != nil {
|
||||
|
|
|
@ -39,7 +39,7 @@ func (p ExistsRes) Exists() bool {
|
|||
// Returns an error of type apistatus.ObjectAlreadyRemoved if object has been marked as removed.
|
||||
func (s *Shard) Exists(prm ExistsPrm) (ExistsRes, error) {
|
||||
var existsPrm meta.ExistsPrm
|
||||
existsPrm.WithAddress(prm.addr)
|
||||
existsPrm.SetAddress(prm.addr)
|
||||
|
||||
res, err := s.metaBase.Exists(existsPrm)
|
||||
exists := res.Exists()
|
||||
|
|
|
@ -236,8 +236,8 @@ func (s *Shard) collectExpiredObjects(ctx context.Context, e Event) {
|
|||
|
||||
var inhumePrm meta.InhumePrm
|
||||
|
||||
inhumePrm.WithAddresses(expired...)
|
||||
inhumePrm.WithGCMark()
|
||||
inhumePrm.SetAddresses(expired...)
|
||||
inhumePrm.SetGCMark()
|
||||
|
||||
// inhume the collected objects
|
||||
_, err = s.metaBase.Inhume(inhumePrm)
|
||||
|
@ -349,8 +349,8 @@ func (s *Shard) HandleExpiredTombstones(tss []meta.TombstonedObject) {
|
|||
tsAddrs = append(tsAddrs, ts.Tombstone())
|
||||
}
|
||||
|
||||
pInhume.WithGCMark()
|
||||
pInhume.WithAddresses(tsAddrs...)
|
||||
pInhume.SetGCMark()
|
||||
pInhume.SetAddresses(tsAddrs...)
|
||||
|
||||
// inhume tombstones
|
||||
_, err := s.metaBase.Inhume(pInhume)
|
||||
|
@ -383,8 +383,8 @@ func (s *Shard) HandleExpiredLocks(lockers []oid.Address) {
|
|||
}
|
||||
|
||||
var pInhume meta.InhumePrm
|
||||
pInhume.WithAddresses(lockers...)
|
||||
pInhume.WithGCMark()
|
||||
pInhume.SetAddresses(lockers...)
|
||||
pInhume.SetGCMark()
|
||||
|
||||
_, err = s.metaBase.Inhume(pInhume)
|
||||
if err != nil {
|
||||
|
|
|
@ -120,7 +120,7 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, big, small stor
|
|||
var exists bool
|
||||
if !skipMeta {
|
||||
var mPrm meta.ExistsPrm
|
||||
mPrm.WithAddress(addr)
|
||||
mPrm.SetAddress(addr)
|
||||
|
||||
mRes, err := s.metaBase.Exists(mPrm)
|
||||
if err != nil && s.GetMode() != ModeDegraded {
|
||||
|
|
|
@ -68,8 +68,8 @@ func (s *Shard) Head(prm HeadPrm) (HeadRes, error) {
|
|||
}
|
||||
|
||||
var headParams meta.GetPrm
|
||||
headParams.WithAddress(prm.addr)
|
||||
headParams.WithRaw(prm.raw)
|
||||
headParams.SetAddress(prm.addr)
|
||||
headParams.SetRaw(prm.raw)
|
||||
|
||||
res, err := s.metaBase.Get(headParams)
|
||||
if err != nil {
|
||||
|
|
|
@ -74,17 +74,17 @@ func (s *Shard) Inhume(prm InhumePrm) (InhumeRes, error) {
|
|||
}
|
||||
|
||||
var metaPrm meta.InhumePrm
|
||||
metaPrm.WithAddresses(prm.target...)
|
||||
metaPrm.WithLockObjectHandling()
|
||||
metaPrm.SetAddresses(prm.target...)
|
||||
metaPrm.SetLockObjectHandling()
|
||||
|
||||
if prm.tombstone != nil {
|
||||
metaPrm.WithTombstoneAddress(*prm.tombstone)
|
||||
metaPrm.SetTombstoneAddress(*prm.tombstone)
|
||||
} else {
|
||||
metaPrm.WithGCMark()
|
||||
metaPrm.SetGCMark()
|
||||
}
|
||||
|
||||
if prm.forceRemoval {
|
||||
metaPrm.WithForceGCMark()
|
||||
metaPrm.SetForceGCMark()
|
||||
}
|
||||
|
||||
res, err := s.metaBase.Inhume(metaPrm)
|
||||
|
|
|
@ -74,8 +74,8 @@ func (s *Shard) List() (res SelectRes, err error) {
|
|||
|
||||
for i := range lst {
|
||||
var sPrm meta.SelectPrm
|
||||
sPrm.WithContainerID(lst[i])
|
||||
sPrm.WithFilters(filters)
|
||||
sPrm.SetContainerID(lst[i])
|
||||
sPrm.SetFilters(filters)
|
||||
|
||||
sRes, err := s.metaBase.Select(sPrm) // consider making List in metabase
|
||||
if err != nil {
|
||||
|
@ -120,8 +120,8 @@ func ListContainers(s *Shard) ([]cid.ID, error) {
|
|||
// parameter set to zero.
|
||||
func (s *Shard) ListWithCursor(prm ListWithCursorPrm) (ListWithCursorRes, error) {
|
||||
var metaPrm meta.ListPrm
|
||||
metaPrm.WithCount(prm.count)
|
||||
metaPrm.WithCursor(prm.cursor)
|
||||
metaPrm.SetCount(prm.count)
|
||||
metaPrm.SetCursor(prm.cursor)
|
||||
res, err := s.metaBase.ListWithCursor(metaPrm)
|
||||
if err != nil {
|
||||
return ListWithCursorRes{}, fmt.Errorf("could not get list of objects: %w", err)
|
||||
|
|
|
@ -30,7 +30,7 @@ func (s *Shard) ToMoveIt(prm ToMoveItPrm) (ToMoveItRes, error) {
|
|||
}
|
||||
|
||||
var toMovePrm meta.ToMoveItPrm
|
||||
toMovePrm.WithAddress(prm.addr)
|
||||
toMovePrm.SetAddress(prm.addr)
|
||||
|
||||
_, err := s.metaBase.ToMoveIt(toMovePrm)
|
||||
if err != nil {
|
||||
|
|
|
@ -61,8 +61,8 @@ func (s *Shard) Put(prm PutPrm) (PutRes, error) {
|
|||
|
||||
// put to metabase
|
||||
var pPrm meta.PutPrm
|
||||
pPrm.WithObject(prm.obj)
|
||||
pPrm.WithBlobovniczaID(res.BlobovniczaID())
|
||||
pPrm.SetObject(prm.obj)
|
||||
pPrm.SetBlobovniczaID(res.BlobovniczaID())
|
||||
if _, err := s.metaBase.Put(pPrm); err != nil {
|
||||
// may we need to handle this case in a special way
|
||||
// since the object has been successfully written to BlobStor
|
||||
|
|
|
@ -45,8 +45,8 @@ func (r SelectRes) AddressList() []oid.Address {
|
|||
// did not allow to completely select the objects.
|
||||
func (s *Shard) Select(prm SelectPrm) (SelectRes, error) {
|
||||
var selectPrm meta.SelectPrm
|
||||
selectPrm.WithFilters(prm.filters)
|
||||
selectPrm.WithContainerID(prm.cnr)
|
||||
selectPrm.SetFilters(prm.filters)
|
||||
selectPrm.SetContainerID(prm.cnr)
|
||||
|
||||
mRes, err := s.metaBase.Select(selectPrm)
|
||||
if err != nil {
|
||||
|
|
|
@ -239,8 +239,8 @@ func (c *cache) writeObject(obj *object.Object, metaOnly bool) error {
|
|||
}
|
||||
|
||||
var pPrm meta.PutPrm
|
||||
pPrm.WithObject(obj)
|
||||
pPrm.WithBlobovniczaID(id)
|
||||
pPrm.SetObject(obj)
|
||||
pPrm.SetBlobovniczaID(id)
|
||||
|
||||
_, err := c.metabase.Put(pPrm)
|
||||
return err
|
||||
|
|
|
@ -60,7 +60,7 @@ func (c *cache) initFlushMarks() {
|
|||
|
||||
func (c *cache) isFlushed(addr oid.Address) bool {
|
||||
var existsPrm meta.ExistsPrm
|
||||
existsPrm.WithAddress(addr)
|
||||
existsPrm.SetAddress(addr)
|
||||
|
||||
mRes, err := c.metabase.Exists(existsPrm)
|
||||
if err != nil || !mRes.Exists() {
|
||||
|
|
Loading…
Reference in a new issue