local_object_storage: Rename method GetLocked
-> GetLocks
#1555
4 changed files with 20 additions and 20 deletions
|
@ -254,31 +254,31 @@ func (e *StorageEngine) IsLocked(ctx context.Context, addr oid.Address) (bool, e
|
|||
return locked, outErr
|
||||
}
|
||||
|
||||
// GetLocked return lock id's if object is locked according to StorageEngine's state.
|
||||
func (e *StorageEngine) GetLocked(ctx context.Context, addr oid.Address) ([]oid.ID, error) {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.GetLocked",
|
||||
// GetLocks return lock id's if object is locked according to StorageEngine's state.
|
||||
func (e *StorageEngine) GetLocks(ctx context.Context, addr oid.Address) ([]oid.ID, error) {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.GetLocks",
|
||||
trace.WithAttributes(
|
||||
attribute.String("address", addr.EncodeToString()),
|
||||
))
|
||||
defer span.End()
|
||||
|
||||
var locked []oid.ID
|
||||
var allLocks []oid.ID
|
||||
var outErr error
|
||||
|
||||
e.iterateOverUnsortedShards(func(h hashedShard) (stop bool) {
|
||||
ld, err := h.Shard.GetLocked(ctx, addr)
|
||||
locks, err := h.Shard.GetLocks(ctx, addr)
|
||||
if err != nil {
|
||||
e.reportShardError(ctx, h, logs.EngineInterruptGettingLockers, err, zap.Stringer("address", addr),
|
||||
zap.String("trace_id", tracingPkg.GetTraceID(ctx)))
|
||||
outErr = err
|
||||
}
|
||||
locked = append(locked, ld...)
|
||||
allLocks = append(allLocks, locks...)
|
||||
return false
|
||||
})
|
||||
if len(locked) > 0 {
|
||||
return locked, nil
|
||||
if len(allLocks) > 0 {
|
||||
return allLocks, nil
|
||||
}
|
||||
return locked, outErr
|
||||
return allLocks, outErr
|
||||
}
|
||||
|
||||
func (e *StorageEngine) processExpiredTombstones(ctx context.Context, addrs []meta.TombstonedObject) {
|
||||
|
|
|
@ -85,7 +85,7 @@ func (e *StorageEngine) put(ctx context.Context, prm PutPrm) error {
|
|||
}
|
||||
|
||||
if !existed && locked {
|
||||
lockers, err := e.GetLocked(ctx, ecParent)
|
||||
lockers, err := e.GetLocks(ctx, ecParent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ func objectLocked(tx *bbolt.Tx, idCnr cid.ID, idObj oid.ID) bool {
|
|||
}
|
||||
|
||||
// return `LOCK` id's if specified object is locked in the specified container.
|
||||
func getLocked(tx *bbolt.Tx, idCnr cid.ID, idObj oid.ID) ([]oid.ID, error) {
|
||||
func getLocks(tx *bbolt.Tx, idCnr cid.ID, idObj oid.ID) ([]oid.ID, error) {
|
||||
var lockers []oid.ID
|
||||
bucketLocked := tx.Bucket(bucketNameLocked)
|
||||
if bucketLocked != nil {
|
||||
|
@ -351,20 +351,20 @@ func (db *DB) IsLocked(ctx context.Context, prm IsLockedPrm) (res IsLockedRes, e
|
|||
return res, err
|
||||
}
|
||||
|
||||
// GetLocked return `LOCK` id's if provided object is locked by any `LOCK`. Not found
|
||||
// GetLocks return `LOCK` id's if provided object is locked by any `LOCK`. Not found
|
||||
// object is considered as non-locked.
|
||||
//
|
||||
// Returns only non-logical errors related to underlying database.
|
||||
func (db *DB) GetLocked(ctx context.Context, addr oid.Address) (res []oid.ID, err error) {
|
||||
func (db *DB) GetLocks(ctx context.Context, addr oid.Address) (res []oid.ID, err error) {
|
||||
var (
|
||||
startedAt = time.Now()
|
||||
success = false
|
||||
)
|
||||
defer func() {
|
||||
db.metrics.AddMethodDuration("GetLocked", time.Since(startedAt), success)
|
||||
db.metrics.AddMethodDuration("GetLocks", time.Since(startedAt), success)
|
||||
}()
|
||||
|
||||
_, span := tracing.StartSpanFromContext(ctx, "metabase.GetLocked",
|
||||
_, span := tracing.StartSpanFromContext(ctx, "metabase.GetLocks",
|
||||
trace.WithAttributes(
|
||||
attribute.String("address", addr.EncodeToString()),
|
||||
))
|
||||
|
@ -377,7 +377,7 @@ func (db *DB) GetLocked(ctx context.Context, addr oid.Address) (res []oid.ID, er
|
|||
return res, ErrDegradedMode
|
||||
}
|
||||
err = metaerr.Wrap(db.boltDB.View(func(tx *bbolt.Tx) error {
|
||||
res, err = getLocked(tx, addr.Container(), addr.Object())
|
||||
res, err = getLocks(tx, addr.Container(), addr.Object())
|
||||
return nil
|
||||
}))
|
||||
success = err == nil
|
||||
|
|
|
@ -72,10 +72,10 @@ func (s *Shard) IsLocked(ctx context.Context, addr oid.Address) (bool, error) {
|
|||
return res.Locked(), nil
|
||||
}
|
||||
|
||||
// GetLocked return lock id's of the provided object. Not found object is
|
||||
// GetLocks return lock id's of the provided object. Not found object is
|
||||
// considered as not locked. Requires healthy metabase, returns ErrDegradedMode otherwise.
|
||||
func (s *Shard) GetLocked(ctx context.Context, addr oid.Address) ([]oid.ID, error) {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "Shard.GetLocked",
|
||||
func (s *Shard) GetLocks(ctx context.Context, addr oid.Address) ([]oid.ID, error) {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "Shard.GetLocks",
|
||||
trace.WithAttributes(
|
||||
attribute.String("shard_id", s.ID().String()),
|
||||
attribute.String("address", addr.EncodeToString()),
|
||||
|
@ -86,5 +86,5 @@ func (s *Shard) GetLocked(ctx context.Context, addr oid.Address) ([]oid.ID, erro
|
|||
if m.NoMetabase() {
|
||||
return nil, ErrDegradedMode
|
||||
}
|
||||
return s.metaBase.GetLocked(ctx, addr)
|
||||
return s.metaBase.GetLocks(ctx, addr)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue