JobLockService implementation

- Provides transaction-aware locking
 - Post-transaction cleanup is automatically done
 - Retrying for lock acquisition is handled internally as well
 - Downgraded the lock concurrency tests for the build machine (maybe 50 threads was too much)
 - Deadlock tests added for the high-level locking


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13968 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2009-04-15 19:16:38 +00:00
parent 5bda334c22
commit 389f996f29
12 changed files with 863 additions and 10 deletions

View File

@@ -37,6 +37,8 @@ import org.alfresco.util.EqualsHelper;
*/
public class LockEntity
{
public static final Long CONST_LONG_ZERO = new Long(0L);
private Long id;
private Long version;
private Long sharedResourceId;
@@ -71,6 +73,18 @@ public class LockEntity
}
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder(512);
sb.append("LockEntity")
.append("[ ID=").append(id)
.append(", sharedResourceId=").append(sharedResourceId)
.append(", exclusiveResourceId=").append(exclusiveResourceId)
.append("]");
return sb.toString();
}
/**
* Determine if the lock is logically exclusive. A lock is <b>exclusive</b> if the
* shared lock resource matches the exclusive lock resource.
@@ -111,9 +125,20 @@ public class LockEntity
this.version = version;
}
/**
* Increments the version number or resets it if it reaches a large number
*/
public void incrementVersion()
{
this.version = new Long(version.longValue() + 1L);
long currentVersion = version.longValue();
if (currentVersion >= 10E6)
{
this.version = CONST_LONG_ZERO;
}
else
{
this.version = new Long(version.longValue() + 1L);
}
}
/**