forked from TrueCloudLab/frostfs-node
[#1175] metabase: Implement LOCK operation
Implement `DB.Lock` method which marks list of the objects as locked by another object. Only regular objects can be locked. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
14d27455f3
commit
9f13674a10
4 changed files with 169 additions and 17 deletions
|
@ -132,3 +132,31 @@ func resetBucket(b *bbolt.Bucket) error {
|
|||
return b.DeleteBucket(k)
|
||||
})
|
||||
}
|
||||
|
||||
// if meets irregular object container in objs - returns its type, otherwise returns object.TypeRegular.
|
||||
//
|
||||
// firstIrregularObjectType(tx, cnr, obj) usage allows getting object type.
|
||||
func firstIrregularObjectType(tx *bbolt.Tx, idCnr cid.ID, objs ...[]byte) object.Type {
|
||||
if len(objs) == 0 {
|
||||
panic("empty object list in firstIrregularObjectType")
|
||||
}
|
||||
|
||||
irregularTypeBuckets := [...]struct {
|
||||
typ object.Type
|
||||
name []byte
|
||||
}{
|
||||
{object.TypeTombstone, tombstoneBucketName(&idCnr)},
|
||||
{object.TypeStorageGroup, storageGroupBucketName(&idCnr)},
|
||||
{object.TypeLock, bucketNameLockers(idCnr)},
|
||||
}
|
||||
|
||||
for i := range objs {
|
||||
for j := range irregularTypeBuckets {
|
||||
if inBucket(tx, irregularTypeBuckets[j].name, objs[i]) {
|
||||
return irregularTypeBuckets[j].typ
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return object.TypeRegular
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue