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 String
dataSourceName
static int
LOCK_RETRIES
static long
LOCK_SLEEP_DELAY
static long
LOCK_SLEEP_INCREMENT
protected Model
model
protected SQLInfo
sqlInfo
-
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 void
checkConcurrentUpdate(Throwable e)
protected Lock
deleteLock(Serializable id, String owner)
protected Lock
deleteLock(Connection connection, Serializable id, String owner)
protected void
deleteLock0(Connection connection, Serializable id)
protected Connection
getConnection()
Lock
getLock(String id)
Gets the lock on a document.protected Serializable
idFromString(String id)
protected Lock
readLock(Serializable id)
protected Lock
readLock0(Connection connection, Serializable 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 boolean
shouldRetry(Exception e)
Does the exception mean that we should retry the transaction?protected boolean
shouldRetry(SQLException e)
String
toString()
protected Lock
writeLock(Serializable id, Lock lock)
protected Lock
writeLock(Connection connection, Serializable id, Lock lock)
protected void
writeLock0(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:LockManager
Gets the lock on a document.If the document does not exist,
null
is returned.- Specified by:
getLock
in interfaceLockManager
- Parameters:
id
- the document id- Returns:
- the existing lock, or
null
when there is no lock
-
setLock
public Lock setLock(String id, Lock lock)
Description copied from interface:LockManager
Sets 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:
setLock
in interfaceLockManager
- Parameters:
id
- the document idlock
- the lock to set- Returns:
null
if 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:LockManager
Removes the lock from a document.The previous lock is returned.
If
owner
isnull
then the lock is unconditionally removed.If
owner
is notnull
, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrue
forLock.getFailed()
.- Specified by:
removeLock
in interfaceLockManager
- Parameters:
id
- the document idowner
- the owner to check, ornull
for 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
-
-