Package org.nuxeo.ecm.core.storage.sql
Class VCSLockManager
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.sql.VCSLockManager
-
- All Implemented Interfaces:
LockManager
public class VCSLockManager extends Object implements LockManager
Manager of locks stored in the repository SQL database.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringdataSourceNamestatic intLOCK_RETRIESstatic longLOCK_SLEEP_DELAYstatic longLOCK_SLEEP_INCREMENTprotected Modelmodelprotected SQLInfosqlInfo
-
Constructor Summary
Constructors Constructor Description VCSLockManager(RepositoryImpl repository)Creates a lock manager for the given repository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckConcurrentUpdate(Throwable e)protected LockdeleteLock(Serializable id, String owner)protected LockdeleteLock(Connection connection, Serializable id, String owner)protected voiddeleteLock0(Connection connection, Serializable id)protected ConnectiongetConnection()LockgetLock(String id)Gets the lock on a document.protected SerializableidFromString(String id)protected LockreadLock(Serializable id)protected LockreadLock0(Connection connection, Serializable id)LockremoveLock(String id, String owner)Removes the lock from a document.LocksetLock(String id, Lock lock)Sets a lock on a document.protected booleanshouldRetry(Exception e)Does the exception mean that we should retry the transaction?protected booleanshouldRetry(SQLException e)StringtoString()protected LockwriteLock(Serializable id, Lock lock)protected LockwriteLock(Connection connection, Serializable id, Lock lock)protected voidwriteLock0(Connection connection, Serializable id, Lock lock)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.api.lock.LockManager
clearLockManagerCaches, closeLockManager
-
-
-
-
Field Detail
-
LOCK_RETRIES
public static final int LOCK_RETRIES
- See Also:
- Constant Field Values
-
LOCK_SLEEP_DELAY
public static final long LOCK_SLEEP_DELAY
- See Also:
- Constant Field Values
-
LOCK_SLEEP_INCREMENT
public static final long LOCK_SLEEP_INCREMENT
- See Also:
- Constant Field Values
-
dataSourceName
protected final String dataSourceName
-
model
protected final Model model
-
sqlInfo
protected final SQLInfo sqlInfo
-
-
Constructor Detail
-
VCSLockManager
public VCSLockManager(RepositoryImpl repository)
Creates a lock manager for the given repository.LockManager.closeLockManager()must be called when done with the lock manager.- Since:
- 9.3
-
-
Method Detail
-
getConnection
protected Connection getConnection() throws SQLException
- Throws:
SQLException
-
idFromString
protected Serializable idFromString(String id)
-
getLock
public Lock getLock(String id)
Description copied from interface:LockManagerGets the lock on a document.If the document does not exist,
nullis returned.- Specified by:
getLockin interfaceLockManager- Parameters:
id- the document id- Returns:
- the existing lock, or
nullwhen there is no lock
-
setLock
public Lock setLock(String id, Lock lock)
Description copied from interface:LockManagerSets a lock on a document.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).- Specified by:
setLockin interfaceLockManager- Parameters:
id- the document idlock- the lock to set- Returns:
nullif locking succeeded, or the existing lock if locking failed
-
checkConcurrentUpdate
protected void checkConcurrentUpdate(Throwable e)
-
shouldRetry
protected boolean shouldRetry(Exception e)
Does the exception mean that we should retry the transaction?
-
shouldRetry
protected boolean shouldRetry(SQLException e)
-
removeLock
public Lock removeLock(String id, String owner)
Description copied from interface:LockManagerRemoves the lock from a document.The previous lock is returned.
If
ownerisnullthen the lock is unconditionally removed.If
owneris notnull, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrueforLock.getFailed().- Specified by:
removeLockin interfaceLockManager- Parameters:
id- the document idowner- the owner to check, ornullfor no check- Returns:
- the previous lock (may be
null), with a failed flag if locking failed
-
readLock
protected Lock readLock(Serializable id)
-
readLock0
protected Lock readLock0(Connection connection, Serializable id) throws SQLException
- Throws:
SQLException
-
writeLock
protected Lock writeLock(Serializable id, Lock lock)
-
writeLock
protected Lock writeLock(Connection connection, Serializable id, Lock lock) throws SQLException
- Throws:
SQLException
-
writeLock0
protected void writeLock0(Connection connection, Serializable id, Lock lock) throws SQLException
- Throws:
SQLException
-
deleteLock
protected Lock deleteLock(Serializable id, String owner)
-
deleteLock
protected Lock deleteLock(Connection connection, Serializable id, String owner) throws SQLException
- Throws:
SQLException
-
deleteLock0
protected void deleteLock0(Connection connection, Serializable id) throws SQLException
- Throws:
SQLException
-
-