boolean tryLock(final ClusterLockKey clusterLockKey) {
        if (!securityContext.isProcessingUser()) {
            throw new PermissionException(securityContext.getUserRef(),
                    "Only the processing user is allowed to try a cluster lock");
        }

        boolean success = false;

        try {
            final String lockName = clusterLockKey.getName();
            final Lock currentLock = lockMap.get(lockName);
            if (currentLock == null) {
                final Lock newLock = new Lock(clusterLockKey);
                // Another node might have concurrently put a lock so only put
                // this new lock if no lock is present. This method will return
                // the lock we are trying to put if one does not already exist
                // and we successfully add this one.
                lockMap.putIfAbsent(lockName, newLock);
                final Lock lock = lockMap.get(lockName);
                // Check that the current lock is EXACTLY (hence ==) the one we
                // have just tried to put.
                if (lock == newLock) {
                    success = true;
                }
            }

            debug("lock()", clusterLockKey, currentLock, success);
        } catch (final RuntimeException e) {
            LOGGER.error(e.getMessage(), e);
        }

        return success;
    }
Try and lock with the supplied key.

@param clusterLockKey The key to try and lock with.
@return Return true if we managed to obtain a lock with the supplied key,
return false if this lock is already owned by another
node/process.
stroom-cluster/stroom-cluster-lock-impl-db/src/main/java/stroom/cluster/lock/impl/db/ClusterLockClusterHandler.java