[jbosscache-commits] JBoss Cache SVN: r7923 - in core/trunk/src/main: java/org/jboss/cache/lock and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Thu Mar 19 06:28:45 EDT 2009
Author: manik.surtani at jboss.com
Date: 2009-03-19 06:28:45 -0400 (Thu, 19 Mar 2009)
New Revision: 7923
Modified:
core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementLockContainer.java
core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementOwnableReentrantLockContainer.java
core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementReentrantLockContainer.java
Log:
JBCACHE-1494 - concurrencyLevel to affect the non-striped lock container as well
Modified: core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2009-03-19 10:20:25 UTC (rev 7922)
+++ core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2009-03-19 10:28:45 UTC (rev 7923)
@@ -498,7 +498,7 @@
<entry>500</entry>
<entry>Specifies the number of shared locks to use for write locks acquired. Only used if <literal>nodeLockingScheme</literal>
- is <literal>mvcc</literal>, and is ignored if <literal>useLockStriping</literal> is <literal>false</literal>.
+ is <literal>mvcc</literal>.
See the <link linkend="mvcc.impl">section on JBoss Cache's MVCC implementation</link> for a more detailed discussion.</entry>
</row>
</tbody>
Modified: core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2009-03-19 10:20:25 UTC (rev 7922)
+++ core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2009-03-19 10:28:45 UTC (rev 7923)
@@ -93,10 +93,13 @@
@Start
public void startLockManager()
{
+ // don't we all love nested ternary operators? :-)
lockContainer =
configuration.isUseLockStriping() ?
- transactionManager == null ? new ReentrantSharedLockContainer<Fqn>(configuration.getConcurrencyLevel()) : new OwnableReentrantSharedLockContainer<Fqn>(configuration.getConcurrencyLevel(), invocationContextContainer) :
- transactionManager == null ? new PerElementReentrantLockContainer<Fqn>() : new PerElementOwnableReentrantLockContainer<Fqn>(invocationContextContainer);
+ transactionManager == null ? new ReentrantSharedLockContainer<Fqn>(configuration.getConcurrencyLevel()) :
+ new OwnableReentrantSharedLockContainer<Fqn>(configuration.getConcurrencyLevel(), invocationContextContainer) :
+ transactionManager == null ? new PerElementReentrantLockContainer<Fqn>(configuration.getConcurrencyLevel()) :
+ new PerElementOwnableReentrantLockContainer<Fqn>(configuration.getConcurrencyLevel(), invocationContextContainer);
}
@Start
@@ -107,7 +110,7 @@
public boolean lock(Fqn fqn, LockType lockType, Object owner) throws InterruptedException
{
- if (lockType == READ) return true; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return true; // we don't support read locks.
if (trace) log.trace("Attempting to lock " + fqn);
return lockContainer.acquireLock(fqn, lockAcquisitionTimeout, MILLISECONDS);
@@ -115,7 +118,7 @@
public boolean lock(Fqn fqn, LockType lockType, Object owner, long timeoutMillis) throws InterruptedException
{
- if (lockType == READ) return true; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return true; // we don't support read locks.
if (trace) log.trace("Attempting to lock " + fqn);
return lockContainer.acquireLock(fqn, lockAcquisitionTimeout, MILLISECONDS);
@@ -123,7 +126,7 @@
public boolean lockAndRecord(Fqn fqn, LockType lockType, InvocationContext ctx) throws InterruptedException
{
- if (lockType == READ) return true; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return true; // we don't support read locks.
if (trace) log.trace("Attempting to lock " + fqn);
if (lockContainer.acquireLock(fqn, lockAcquisitionTimeout, MILLISECONDS))
@@ -220,25 +223,25 @@
public boolean lockAll(NodeSPI node, LockType lockType, Object owner) throws InterruptedException
{
- if (lockType == READ) return true; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return true; // we don't support read locks.
return lockRecursively(node.getDelegationTarget(), lockAcquisitionTimeout, false, null);
}
public boolean lockAll(NodeSPI node, LockType lockType, Object owner, long timeout) throws InterruptedException
{
- if (lockType == READ) return true; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return true; // we don't support read locks.
return lockRecursively(node.getDelegationTarget(), timeout, false, null);
}
public boolean lockAll(NodeSPI node, LockType lockType, Object owner, long timeout, boolean excludeInternalFqns) throws InterruptedException
{
- if (lockType == READ) return true; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return true; // we don't support read locks.
return lockRecursively(node.getDelegationTarget(), timeout, excludeInternalFqns, null);
}
public boolean lockAllAndRecord(NodeSPI node, LockType lockType, InvocationContext ctx) throws InterruptedException
{
- if (lockType == READ) return true; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return true; // we don't support read locks.
return lockRecursively(node.getDelegationTarget(), ctx.getLockAcquisitionTimeout(lockAcquisitionTimeout), false, ctx);
}
@@ -265,7 +268,7 @@
public boolean ownsLock(Fqn fqn, LockType lockType, Object owner)
{
- if (lockType == READ) return false; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return false; // we don't support read locks.
return lockContainer.ownsLock(fqn, owner);
}
@@ -281,7 +284,7 @@
public boolean isLocked(NodeSPI n, LockType lockType)
{
- if (lockType == READ) return false; // we don't support read locks. TODO: enforce this with an assertion
+ if (lockType == READ) return false; // we don't support read locks.
return lockContainer.isLocked(n.getFqn());
}
Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementLockContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementLockContainer.java 2009-03-19 10:20:25 UTC (rev 7922)
+++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementLockContainer.java 2009-03-19 10:28:45 UTC (rev 7923)
@@ -13,8 +13,13 @@
*/
public abstract class PerElementLockContainer<E> implements LockContainer<E>
{
- ConcurrentMap<E, Lock> locks = new ConcurrentHashMap<E, Lock>();
+ protected final ConcurrentMap<E, Lock> locks;
+ protected PerElementLockContainer(int concurrencyLevel)
+ {
+ locks = new ConcurrentHashMap<E, Lock>(16, .75f, concurrencyLevel);
+ }
+
protected abstract Lock newLock();
public final Lock getLock(E object)
Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementOwnableReentrantLockContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementOwnableReentrantLockContainer.java 2009-03-19 10:20:25 UTC (rev 7922)
+++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementOwnableReentrantLockContainer.java 2009-03-19 10:28:45 UTC (rev 7923)
@@ -14,8 +14,9 @@
{
private InvocationContextContainer icc;
- public PerElementOwnableReentrantLockContainer(InvocationContextContainer icc)
+ public PerElementOwnableReentrantLockContainer(int concurrencyLevel, InvocationContextContainer icc)
{
+ super(concurrencyLevel);
this.icc = icc;
}
Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementReentrantLockContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementReentrantLockContainer.java 2009-03-19 10:20:25 UTC (rev 7922)
+++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/PerElementReentrantLockContainer.java 2009-03-19 10:28:45 UTC (rev 7923)
@@ -11,6 +11,11 @@
*/
public class PerElementReentrantLockContainer<E> extends PerElementLockContainer<E>
{
+ public PerElementReentrantLockContainer(int concurrencyLevel)
+ {
+ super(concurrencyLevel);
+ }
+
public boolean ownsLock(E object, Object owner)
{
ReentrantLock l = getLockFromMap(object);
More information about the jbosscache-commits
mailing list