Author: mircea.markus
Date: 2008-04-22 07:14:28 -0400 (Tue, 22 Apr 2008)
New Revision: 5618
Modified:
core/trunk/src/main/java/org/jboss/cache/Cache.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
Log:
JBCACHE-1222 - bug fixing - put for external read
Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-04-22 10:38:03 UTC (rev
5617)
+++ core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-04-22 11:14:28 UTC (rev
5618)
@@ -172,7 +172,8 @@
* Under special operating behavior, associates the value with the specified key for a
node identified by the Fqn passed in.
* <ul>
* <li> Only goes through if the node specified does not exist; no-op
otherwise.</i>
- * <li> Force asynchronous mode for replication or invalidation to prevent any
blocking.</li>
+ * <li> Force asynchronous mode for replication to prevent any
blocking.</li>
+ * <li> invalidation does not take place. </li>
* <li> 0ms lock timeout to prevent any blocking here either. If the lock is not
acquired, this method is a no-op, and swallows the timeout exception.</li>
* <li> Ongoing transactions are suspended before this call, so failures here
will not affect any ongoing transactions.</li>
* <li> Errors and exceptions are 'silent' - logged at a much lower
level than normal, and this method does not throw exceptions</li>
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-22
10:38:03 UTC (rev 5617)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-22
11:14:28 UTC (rev 5618)
@@ -108,6 +108,7 @@
public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand
command) throws Throwable
{
+ if (command.isPutForExternalRead()) return invokeNextInterceptor(ctx, command);
return handleCrudMethod(ctx, command.getFqn(), null, command);
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-22
10:38:03 UTC (rev 5617)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-22
11:14:28 UTC (rev 5618)
@@ -70,16 +70,16 @@
@Override
public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand
command) throws Throwable
{
- return handlePutCommand(ctx, command);
+ return handlePutCommand(ctx, command, false);
}
@Override
public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand
command) throws Throwable
{
- return handlePutCommand(ctx, command);
+ return handlePutCommand(ctx, command, command.isPutForExternalRead());
}
- private Object handlePutCommand(InvocationContext ctx, CacheDataCommand command)
+ private Object handlePutCommand(InvocationContext ctx, CacheDataCommand command,
boolean zeroAcquisitionTimeout)
throws Throwable
{
if ((ctx.isSupressLocking()) || configuration.getIsolationLevel() ==
IsolationLevel.NONE)
@@ -99,7 +99,8 @@
}
else
{
- lockManager.acquireLocksWithTimeout(ctx, command.getFqn(),
NodeLock.LockType.WRITE, true, false, false, true, null, false);
+ lockManager.acquireLocksWithTimeout(ctx, command.getFqn(),
NodeLock.LockType.WRITE, true,
+ zeroAcquisitionTimeout, false, true, null, false);
}
Object retVal = invokeNextInterceptor(ctx, command);
ctx.clearInvocationLocksAcquired();
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-04-22
10:38:03 UTC (rev 5617)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-04-22
11:14:28 UTC (rev 5618)
@@ -104,8 +104,9 @@
long startTime = System.currentTimeMillis();
cache1.putForExternalRead(fqn, key, value);
+ long waited = System.currentTimeMillis() - startTime;
// crappy way to test that pFER does not block, but it is effective.
- assertTrue("Should not wait for lock timeout, should attempt to acquite lock
with 0ms!", System.currentTimeMillis() - startTime <
cache1.getConfiguration().getLockAcquisitionTimeout());
+ assertTrue("Should not wait " + waited + " millis for lock timeout,
should attempt to acquite lock with 0ms!", waited <
cache1.getConfiguration().getLockAcquisitionTimeout());
// should not block.
tm1.resume(t);