forked from TrueCloudLab/frostfs-node
[#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:
parent
e9837bbcf9
commit
72470d6b48
4 changed files with 15 additions and 15 deletions
|
@ -254,9 +254,9 @@ 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()),
|
||||
))
|
||||
|
@ -266,7 +266,7 @@ func (e *StorageEngine) GetLocked(ctx context.Context, addr oid.Address) ([]oid.
|
|||
var outErr error
|
||||
|
||||
e.iterateOverUnsortedShards(func(h hashedShard) (stop bool) {
|
||||
ld, err := h.Shard.GetLocked(ctx, addr)
|
||||
ld, 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)))
|
||||
|
|
|
@ -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…
Reference in a new issue