Returns this lock if it exists in the store.

@param lock
@return IEntityLock
344634
public IEntityLock find(IEntityLock lock) throws LockingException {
        IEntityLock foundLock = null;
        Map m = getLockCache(lock.getEntityType());
        foundLock = getLockFromCache(getCacheKey(lock), m);

        if (foundLock != null) {
            if (lock.getLockType() != foundLock.getLockType()
                    || !lock.getExpirationTime().equals(foundLock.getExpirationTime())) {
                foundLock = null;
            }
        }

        return foundLock;
    }
782560
public Optional<LockResource> tryGet(K key, LockMode mode) {
    ValNode valNode = getValNode(key);
    ReentrantReadWriteLock lock = valNode.mValue;
    Lock innerLock;
    switch (mode) {
      case READ:
        innerLock = lock.readLock();
        break;
      case WRITE:
        innerLock = lock.writeLock();
        break;
      default:
        throw new IllegalStateException("Unknown lock mode: " + mode);
    }
    if (!innerLock.tryLock()) {
      return Optional.empty();
    }
    return Optional.of(new RefCountLockResource(innerLock, false, valNode.mRefCount));
  }
800340
public IEntityLock newWriteLock(Class entityType, String entityKey, String owner)
            throws LockingException {
        return lockService.newLock(entityType, entityKey, IEntityLockService.WRITE_LOCK, owner);
    }
408037
public Object getLock(Object key)
    {
        int index = (key.hashCode() & 0x7FFFFFFF) % locks.length;

        // Double-checked locking.  Safe since Object has no state.
        Object lock = locks[index];
        if (lock == null)
        {
            synchronized (this)
            {
                lock = locks[index];
                if (lock == null)
                {
                    lock = new Object();
                    locks[index] = lock;
                }
            }
        }

        return lock;
    }
1282002
protected String getLockProperty(String key) {
        return lockProps != null ? lockProps.getProperty(key) : null;
    }
442453
public IEntityLock newWriteLock(EntityIdentifier entityID, String owner)
            throws LockingException {
        return lockService.newLock(
                entityID.getType(), entityID.getKey(), IEntityLockService.WRITE_LOCK, owner);
    }
831742
public boolean acquire(final Lock lock) {
        lock.setUniqueId(this.uniqueId);
        if (this.lockTimeout > 0) {
            lock.setExpirationDate(ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(this.lockTimeout));
        } else {
            lock.setExpirationDate(null);
        }
        var success = false;
        try {
            if (lock.getApplicationId() != null) {
                this.entityManager.merge(lock);
            } else {
                lock.setApplicationId(this.applicationId);
                this.entityManager.persist(lock);
            }
            success = true;
        } catch (final Exception e) {
            success = false;
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("[{}] could not obtain [{}] lock.", this.uniqueId, this.applicationId, e);
            } else {
                LOGGER.info("[{}] could not obtain [{}] lock.", this.uniqueId, this.applicationId);
            }
        }
        return success;
    }
1056071
static BlockCanaryInternals getInstance() {
        if (sInstance == null) {
            synchronized (BlockCanaryInternals.class) {
                if (sInstance == null) {
                    sInstance = new BlockCanaryInternals();
                }
            }
        }
        return sInstance;
    }
792631
public OFile unlock(final FileLock iLock) throws IOException {
    if (iLock != null) {
      try {
        iLock.release();
      } catch (ClosedChannelException e) {
      }
    }
    return this;
  }
1091267
protected CmsLock getRelatedLock() {

        if (m_relatedLock == null) {
            CmsLockType type;
            if (isSystemLock()) {
                type = CmsLockType.UNLOCKED;
            } else {
                type = CmsLockType.SYSTEM_UNLOCKED;
            }
            CmsLock lock = new CmsLock(getResourceName(), getUserId(), getProject(), type);
            lock.setRelatedLock(this);
            if (isUnlocked()) {
                // prevent the null lock gets modified
                return lock;
            }
            m_relatedLock = lock;
        }
        return m_relatedLock;
    }
196121
private IEntityLock instanceFromResultSet(java.sql.ResultSet rs)
            throws SQLException, LockingException {
        Integer entityTypeID = rs.getInt(1);
        Class entityType = EntityTypesLocator.getEntityTypes().getEntityTypeFromID(entityTypeID);
        String key = rs.getString(2);
        int lockType = rs.getInt(3);
        Timestamp ts = rs.getTimestamp(4);
        String lockOwner = rs.getString(5);

        return newInstance(entityType, key, lockType, ts, lockOwner);
    }
289580
Object getAsyncDeliveryLock() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getAsyncDeliveryLock");
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getAsyncDeliveryLock", asyncDeliveryLock);
        return asyncDeliveryLock;
    }
677556
@Override
    public ILockableEntityGroup findGroupWithLock(String key, String lockOwner)
            throws GroupsException {
        CompositeEntityIdentifier ent = newCompositeEntityIdentifier(key);
        IIndividualGroupService service = getComponentService(ent);
        return (service == null) ? null : service.findGroupWithLock(ent.getLocalKey(), lockOwner);
    }
1223534
public Optional<LockResource> tryLockEdge(Edge edge, LockMode mode) {
    return mEdgeLocks.tryGet(edge, mode);
  }
1197799
public function lock($locked = true)
    {
        $this->_locked = $locked === false ? false : true;
        return $this;
    }
1108128
function(lock) {
    lock.acquire = function(key, fn) {
      Lock._acquiredLocks[lock._id] = lock;
      lock._locked = true;
      lock._key = key;
      return client.setAsync(key, lock._id).nodeify(fn);
    };
  }
516456
protected LockData getLockDataById(String nodeId)
   {
      try
      {
         return getLockDataById.run(nodeId);
      }
      catch (LockException e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("An exception occurred: " + e.getMessage());
         }
      }
      return null;
   }