public class RedisLockManager extends Object implements LockManager
Modifier and Type | Field and Description |
---|---|
protected String |
prefix |
protected RedisAdmin |
redisAdmin |
protected RedisExecutor |
redisExecutor |
protected String |
redisNamespace |
protected String |
repositoryName |
protected String |
scriptRemoveSha |
protected String |
scriptSetSha |
Constructor and Description |
---|
RedisLockManager(String repositoryName)
Creates a lock manager for the given repository.
|
Modifier and Type | Method and Description |
---|---|
void |
clearLockManagerCaches()
Clears any cache held by the lock manager.
|
void |
closeLockManager()
Closes the lock manager and releases resources.
|
Lock |
getLock(String id)
Gets the lock on a document.
|
void |
loadScripts() |
protected Lock |
lockFromString(String lockString) |
Lock |
removeLock(String id,
String owner)
Removes the lock from a document.
|
Lock |
setLock(String id,
Lock lock)
Sets a lock on a document.
|
protected String |
stringFromLock(Lock lock) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canLockBeRemoved
protected final String redisNamespace
protected final String repositoryName
protected RedisExecutor redisExecutor
protected String scriptSetSha
protected String scriptRemoveSha
protected RedisAdmin redisAdmin
public RedisLockManager(String repositoryName)
#close
must be called when done with the lock manager.
public void loadScripts()
protected String stringFromLock(Lock lock)
protected Lock lockFromString(String lockString)
public Lock getLock(String id)
LockManager
If the document does not exist, null
is returned.
getLock
in interface LockManager
id
- the document idnull
when there is no lockpublic Lock setLock(String id, Lock lock)
LockManager
If the document is already locked, returns its existing lock status (there is no re-locking, LockManager.removeLock(java.lang.String, java.lang.String)
must be called first).
setLock
in interface LockManager
id
- the document idlock
- the lock to setnull
if locking succeeded, or the existing lock if locking failedpublic Lock removeLock(String id, String owner)
LockManager
The previous lock is returned.
If owner
is null
then the lock is unconditionally removed.
If owner
is not null
, it must match the existing lock owner for the lock to be removed. If it
doesn't match, the returned lock will return true
for Lock.getFailed()
.
removeLock
in interface LockManager
id
- the document idnull
), with a failed flag if locking failedpublic void closeLockManager()
LockManager
closeLockManager
in interface LockManager
public void clearLockManagerCaches()
LockManager
clearLockManagerCaches
in interface LockManager
Copyright © 2015 Nuxeo SA. All rights reserved.