[#1555] local_object_storage: Rename method GetLocked -> GetLocks

Renamed to better reflect the method's purpose of returning locks
for the specified object.

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-12-11 14:43:36 +03:00
parent e9837bbcf9
commit 72470d6b48
Signed by: a-savchuk
GPG key ID: 70C0A7FF6F9C4639
4 changed files with 15 additions and 15 deletions

View file

@ -254,9 +254,9 @@ func (e *StorageEngine) IsLocked(ctx context.Context, addr oid.Address) (bool, e
return locked, outErr return locked, outErr
} }
// GetLocked return lock id's if object is locked according to StorageEngine's state. // GetLocks 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) { func (e *StorageEngine) GetLocks(ctx context.Context, addr oid.Address) ([]oid.ID, error) {
ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.GetLocked", ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.GetLocks",
trace.WithAttributes( trace.WithAttributes(
attribute.String("address", addr.EncodeToString()), attribute.String("address", addr.EncodeToString()),
)) ))
@ -266,7 +266,7 @@ func (e *StorageEngine) GetLocked(ctx context.Context, addr oid.Address) ([]oid.
var outErr error var outErr error
e.iterateOverUnsortedShards(func(h hashedShard) (stop bool) { e.iterateOverUnsortedShards(func(h hashedShard) (stop bool) {
ld, err := h.Shard.GetLocked(ctx, addr) ld, err := h.Shard.GetLocks(ctx, addr)
if err != nil { if err != nil {
e.reportShardError(ctx, h, logs.EngineInterruptGettingLockers, err, zap.Stringer("address", addr), e.reportShardError(ctx, h, logs.EngineInterruptGettingLockers, err, zap.Stringer("address", addr),
zap.String("trace_id", tracingPkg.GetTraceID(ctx))) zap.String("trace_id", tracingPkg.GetTraceID(ctx)))

View file

@ -85,7 +85,7 @@ func (e *StorageEngine) put(ctx context.Context, prm PutPrm) error {
} }
if !existed && locked { if !existed && locked {
lockers, err := e.GetLocked(ctx, ecParent) lockers, err := e.GetLocks(ctx, ecParent)
if err != nil { if err != nil {
return err return err
} }

View file

@ -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. // 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 var lockers []oid.ID
bucketLocked := tx.Bucket(bucketNameLocked) bucketLocked := tx.Bucket(bucketNameLocked)
if bucketLocked != nil { if bucketLocked != nil {
@ -351,20 +351,20 @@ func (db *DB) IsLocked(ctx context.Context, prm IsLockedPrm) (res IsLockedRes, e
return res, err 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. // object is considered as non-locked.
// //
// Returns only non-logical errors related to underlying database. // 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 ( var (
startedAt = time.Now() startedAt = time.Now()
success = false success = false
) )
defer func() { 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( trace.WithAttributes(
attribute.String("address", addr.EncodeToString()), 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 return res, ErrDegradedMode
} }
err = metaerr.Wrap(db.boltDB.View(func(tx *bbolt.Tx) error { 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 return nil
})) }))
success = err == nil success = err == nil

View file

@ -72,10 +72,10 @@ func (s *Shard) IsLocked(ctx context.Context, addr oid.Address) (bool, error) {
return res.Locked(), nil 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. // considered as not locked. Requires healthy metabase, returns ErrDegradedMode otherwise.
func (s *Shard) GetLocked(ctx context.Context, addr oid.Address) ([]oid.ID, error) { func (s *Shard) GetLocks(ctx context.Context, addr oid.Address) ([]oid.ID, error) {
ctx, span := tracing.StartSpanFromContext(ctx, "Shard.GetLocked", ctx, span := tracing.StartSpanFromContext(ctx, "Shard.GetLocks",
trace.WithAttributes( trace.WithAttributes(
attribute.String("shard_id", s.ID().String()), attribute.String("shard_id", s.ID().String()),
attribute.String("address", addr.EncodeToString()), 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() { if m.NoMetabase() {
return nil, ErrDegradedMode return nil, ErrDegradedMode
} }
return s.metaBase.GetLocked(ctx, addr) return s.metaBase.GetLocks(ctx, addr)
} }