public class VCSLockManager extends Object implements LockManager
 The public methods called by the session are setLock(java.lang.String, org.nuxeo.ecm.core.api.Lock), removeLock(java.lang.String, java.lang.String) and getLock(java.lang.String). Method
 #shutdown must be called when done with the lock manager.
 
In cluster mode, changes are executed in a begin/commit so that tests/updates can be atomic.
 Transaction management can be done by hand because we're dealing with a low-level Mapper and not something
 wrapped by a JCA pool.
| Modifier and Type | Class and Description | 
|---|---|
protected static class  | 
VCSLockManager.LRUCache<K,V>  | 
| Modifier and Type | Field and Description | 
|---|---|
protected static int | 
CACHE_SIZE  | 
protected boolean | 
caching  | 
protected boolean | 
clusteringEnabled
If clustering is enabled then we have to wrap test/set and test/remove in a transaction. 
 | 
static int | 
LOCK_RETRIES  | 
static long | 
LOCK_SLEEP_DELAY  | 
static long | 
LOCK_SLEEP_INCREMENT  | 
protected VCSLockManager.LRUCache<Serializable,Lock> | 
lockCache
A cache of locks, used only in non-cluster mode, when this lock manager is the only one dealing with locks. 
 | 
protected Mapper | 
mapper
The mapper to use. 
 | 
protected static Lock | 
NULL_LOCK  | 
protected RepositoryImpl | 
repository  | 
protected ReentrantLock | 
serializationLock
Lock serializing access to the mapper. 
 | 
| Constructor and Description | 
|---|
VCSLockManager(RepositoryImpl repository)
Creates a lock manager for the given repository. 
 | 
VCSLockManager(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. 
 | 
protected Mapper | 
getMapper()
Delay mapper acquisition until the repository has been fully initialized. 
 | 
protected Serializable | 
idFromString(String id)  | 
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 Lock | 
setLockInternal(String id,
               Lock lock)  | 
protected boolean | 
shouldRetry(Exception e)
Does the exception mean that we should retry the transaction? 
 | 
protected boolean | 
shouldRetry(SQLException e)  | 
String | 
toString()  | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcanLockBeRemovedpublic static final int LOCK_RETRIES
public static final long LOCK_SLEEP_DELAY
public static final long LOCK_SLEEP_INCREMENT
protected final RepositoryImpl repository
protected Mapper mapper
protected final boolean clusteringEnabled
protected final ReentrantLock serializationLock
protected final boolean caching
protected final VCSLockManager.LRUCache<Serializable,Lock> lockCache
 Used under serializationLock.
protected static final int CACHE_SIZE
public VCSLockManager(String repositoryName)
The mapper will from then on be only used and closed by the lock manager.
 #close must be called when done with the lock manager.
public VCSLockManager(RepositoryImpl repository)
The mapper will from then on be only used and closed by the lock manager.
 #close must be called when done with the lock manager.
protected Mapper getMapper()
protected Serializable idFromString(String id)
public void closeLockManager()
LockManagercloseLockManager in interface LockManagerpublic Lock getLock(String id)
LockManager
 If the document does not exist, null is returned.
getLock in interface LockManagerid - 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 LockManagerid - the document idlock - the lock to setnull if locking succeeded, or the existing lock if locking failedprotected boolean shouldRetry(Exception e)
protected boolean shouldRetry(SQLException e)
protected Lock setLockInternal(String id, Lock lock)
public Lock removeLock(String id, String owner)
LockManagerThe 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 LockManagerid - the document idnull), with a failed flag if locking failedpublic void clearLockManagerCaches()
LockManagerclearLockManagerCaches in interface LockManagerCopyright © 2019 Nuxeo. All rights reserved.