/* (non-Javadoc)
@see com.aldous.locking.LockFactory#getLock(java.lang.String, com.aldous.locking.LockFactory.LockType)
434856
public Lock getLock(String lockName, LockType type, String comment) {
		return new SQLLock(lockName,type,comment, getSleepTime(), this);
	}
276837
public Optional<LockResource> tryLockInode(Long inodeId, LockMode mode) {
    return mInodeLocks.tryGet(inodeId, mode);
  }
1282002
protected String getLockProperty(String key) {
        return lockProps != null ? lockProps.getProperty(key) : null;
    }
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;
    }
997889
@Override
    public void lock(Object entity, LockModeType lockMode)
    {
        ivEm.lock(entity, lockMode);
    }
853250
public static function get_lock_factory($type) {
        global $CFG, $DB;
        $lockfactory = null;

        if (during_initial_install()) {
            $lockfactory = new \core\lock\installation_lock_factory($type);
        } else if (isset($CFG->lock_factory) && $CFG->lock_factory != 'auto') {
            if (!class_exists($CFG->lock_factory)) {
                // In this case I guess it is not safe to continue. Different cluster nodes could end up using different locking
                // types because of an installation error.
                throw new \coding_exception('Lock factory set in $CFG does not exist: ' . $CFG->lock_factory);
            }
            $lockfactoryclass = $CFG->lock_factory;
            $lockfactory = new $lockfactoryclass($type);
        } else {
            $dbtype = clean_param($DB->get_dbfamily(), PARAM_ALPHA);

            // DB Specific lock factory is preferred - should support auto-release.
            $lockfactoryclass = "\\core\\lock\\${dbtype}_lock_factory";
            if (!class_exists($lockfactoryclass)) {
                $lockfactoryclass = '\core\lock\file_lock_factory';
            }
            /* @var lock_factory $lockfactory */
            $lockfactory = new $lockfactoryclass($type);
            if (!$lockfactory->is_available()) {
                // Final fallback - DB row locking.
                $lockfactory = new \core\lock\db_record_lock_factory($type);
            }
        }

        return $lockfactory;
    }
876706
protected synchronized List<LockData> getLockList()
   {
      try
      {
         return getLockList.run();
      }
      catch (LockException e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("An exception occurred: " + e.getMessage());
         }
      }
      return null;
   }
411781
private boolean isLocked(Class entityType, String entityKey) throws LockingException {
        return isLocked(entityType, entityKey, null);
    }
711847
public void acquireLock (final NodeObject.Lock lock, final ResultListener<String> listener)
    {
        // wait until any pending resolution is complete
        queryLock(lock, new ChainedResultListener<String, String>(listener) {
            public void requestCompleted (String result) {
                if (result == null) {
                    if (_suboids.isEmpty()) {
                        lockAcquired(lock, 0L, listener);
                    } else {
                        _locks.put(lock, new LockHandler(lock, true, listener));
                    }
                } else {
                    listener.requestCompleted(result);
                }
            }
        });
    }
354128
public IEntityLock newReadLock(Class entityType, String entityKey, String owner)
            throws LockingException {
        return lockService.newLock(entityType, entityKey, IEntityLockService.READ_LOCK, owner);
    }
394398
@Override
    public synchronized Lock obtainWriteLock() {
        Set<File> readLocks = getReadLocks();
        if (readLocks.isEmpty()) {
            final File writeLock = getWriteLock();
            if (writeLock == null) {
                return createLock(true);
            }
        }

        return null;
    }
123377
protected Properties getLockProperties(String name) {
        return lockProperties != null ? lockProperties.get(name) : null;
    }
390554
protected CmsLockInfo getLock(String sitepath) throws CmsException {

        CmsObject cms = getCmsObject();
        CmsUser user = cms.getRequestContext().getCurrentUser();
        CmsLock lock = cms.getLock(sitepath);
        if (lock.isOwnedBy(user)) {
            return CmsLockInfo.forSuccess();
        }
        if (lock.getUserId().isNullUUID()) {
            cms.lockResourceTemporary(sitepath);
            return CmsLockInfo.forSuccess();
        }
        CmsUser owner = cms.readUser(lock.getUserId());
        return CmsLockInfo.forLockedResource(owner.getName());
    }
204171
public final Lock lock(Object key) {
        Lock lock = this.locks.get(key);
        lock.lock();
        return lock;
    }
1315354
@Override
    public FileLock lock(long position, long size, boolean shared) throws IOException
    {
        return new FileLockImpl(this, position, size, shared);
    }
800340
public IEntityLock newWriteLock(Class entityType, String entityKey, String owner)
            throws LockingException {
        return lockService.newLock(entityType, entityKey, IEntityLockService.WRITE_LOCK, owner);
    }
585080
@Override
    public LockResult lock(int waitWeight, String clientId) {
        return lock(waitWeight, clientId, DEFAULT_LOCK_DURATION_MS);
    }