mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/HEAD-BUG-FIX to HEAD:
54579: ALF-19785: Deadlock during build git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54739 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -30,6 +30,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
*/
|
||||
public abstract class AbstractLockStore<T extends ConcurrentMap<NodeRef, LockState>> implements LockStore
|
||||
{
|
||||
protected long maxTryLockMillis = 100;
|
||||
protected T map;
|
||||
|
||||
public AbstractLockStore(T map)
|
||||
@@ -37,6 +38,20 @@ public abstract class AbstractLockStore<T extends ConcurrentMap<NodeRef, LockSta
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum time a lock store should wait while trying to acquire a concurrency lock.
|
||||
*
|
||||
* @see #acquireConcurrencyLock(NodeRef)
|
||||
* @param maxTryLockMillis
|
||||
*/
|
||||
@Override
|
||||
public void setMaxTryLockMillis(long maxTryLockMillis)
|
||||
{
|
||||
this.maxTryLockMillis = maxTryLockMillis;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public LockState get(NodeRef nodeRef)
|
||||
{
|
||||
|
@@ -18,10 +18,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.lock.mem;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
@@ -58,5 +56,6 @@ public interface LockStore
|
||||
void clear();
|
||||
void acquireConcurrencyLock(NodeRef nodeRef);
|
||||
void releaseConcurrencyLock(NodeRef nodeRef);
|
||||
void setMaxTryLockMillis(long maxTryLockMillis);
|
||||
public Set<NodeRef> getNodes();
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
|
||||
import org.alfresco.repo.lock.LockServiceImpl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.LockHelper;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
|
||||
@@ -80,8 +81,9 @@ public class LockStoreImpl extends AbstractLockStore<ConcurrentMap<NodeRef, Lock
|
||||
public void acquireConcurrencyLock(NodeRef nodeRef)
|
||||
{
|
||||
WriteLock writeLock = getWriteLock(nodeRef);
|
||||
// Block until available
|
||||
writeLock.lock();
|
||||
// Block for a short time, if we can't acquire the lock, then throw
|
||||
// an exception that the will allow transaction retry behaviour.
|
||||
LockHelper.tryLock(writeLock, maxTryLockMillis);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user