Author: mircea.markus
Date: 2008-09-01 10:07:15 -0400 (Mon, 01 Sep 2008)
New Revision: 6653
Modified:
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
Log:
update locking during region inactivation
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-09-01 07:45:36 UTC
(rev 6652)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-09-01 14:07:15 UTC
(rev 6653)
@@ -538,6 +538,7 @@
}
catch (Exception transferFailed)
{
+ if (log.isTraceEnabled()) log.trace("Error while fetching
state",transferFailed);
successfulTransfer = false;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-09-01 07:45:36
UTC (rev 6652)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-09-01 14:07:15
UTC (rev 6653)
@@ -489,10 +489,7 @@
*/
protected void inactivateRegion(Fqn fqn) throws CacheException
{
- NodeSPI parent = null;
NodeSPI subtreeRoot = null;
- boolean parentLocked = false;
- boolean subtreeLocked = false;
InvocationContext ctx = cache.getInvocationContext();
ctx.getOptionOverrides().setLockAcquisitionTimeout((int)
(cache.getConfiguration().getLockAcquisitionTimeout() + 5000));
@@ -530,71 +527,13 @@
if (subtreeRoot != null)
{
- // Acquire locks
- subtreeLocked = lockManager.lockAllAndRecord(subtreeRoot, WRITE, ctx);
-
- // Lock the parent, as we're about to write to it
- parent = subtreeRoot.getParentDirect();
- if (parent != null) parentLocked = lockManager.lockAllAndRecord(parent,
WRITE, ctx);
-
// Remove the subtree
cache.evict(subtree, true);
-
- // Release locks
- if (parent != null)
- {
- log.debug("forcing release of locks in parent");
- if (lockManager.isLocked(parent)) lockManager.unlock(parent.getFqn(),
null);
- }
-
- parentLocked = false;
-
- log.debug("forcing release of all locks in subtree");
- lockManager.unlock(ctx);
- subtreeLocked = false;
}
}
}
- catch (InterruptedException e)
- {
- throw new CacheException(e);
- }
finally
{
- // If we didn't succeed, undo the marshalling change
- // NO. Since we inactivated, we may have missed changes
- //if (!success && !inactive)
- // marshaller_.activate(subtreeFqn);
-
- if (parentLocked)
- {
- log.debug("forcing release of locks in parent");
- try
- {
- if (parent != null && lockManager.isLocked(parent.getFqn()))
lockManager.unlock(parent.getFqn(), null);
- }
- catch (Throwable t)
- {
- log.error("failed releasing locks", t);
- }
- }
- if (subtreeLocked)
- {
- log.debug("forcing release of all locks in subtree");
- try
- {
- if (subtreeRoot != null &&
lockManager.isLocked(subtreeRoot.getFqn()))
- lockManager.unlock(subtreeRoot.getFqn(), null);
- }
- catch (Throwable t)
- {
- log.error("failed releasing locks", t);
- }
- }
-
- // If necessary, release locks
- if (ctx != null) lockManager.unlock(ctx);
-
unlock(fqn);
}
}
Modified:
core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-09-01
07:45:36 UTC (rev 6652)
+++
core/trunk/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-09-01
14:07:15 UTC (rev 6653)
@@ -370,6 +370,7 @@
}
catch (Throwable t)
{
+ if (log.isTraceEnabled()) log.trace("Unknown error while integrating
state", t);
stateReceivingFailed(t);
}
finally
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-09-01
07:45:36 UTC (rev 6652)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-09-01
14:07:15 UTC (rev 6653)
@@ -11,6 +11,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.lock.LockManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.BuddyReplicationConfig;
@@ -256,6 +257,27 @@
}
+ public void testLocksAndStateTransfer() throws Exception
+ {
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false,
true, false);
+ createAndActivateRegion(cache1, A);
+ cache1.put(A_B, "name", JOE);
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false,
true, false);
+ // Pause to give caches time to see each other
+ TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
+ createAndActivateRegion(cache2, A_B);
+ assertEquals("Incorrect name for /a/b", JOE, cache2.get(A_B,
"name"));
+
+ LockManager lockManager =
cache1.getComponentRegistry().getComponent(LockManager.class);
+ assert !lockManager.isLocked(A_B);
+ cache1.getRegion(A, false).deactivate();
+ assert !lockManager.isLocked(A);
+ assert !lockManager.isLocked(A_B);
+ createAndActivateRegion(cache1, A_B);
+ assertEquals("Incorrect name for /a/b", JOE, cache1.get(A_B,
"name"));
+ }
+
+
public void testPartialStateTferWithLoader() throws Exception
{
CacheSPI<Object, Object> cache1 = createCache("cache1", false,
true, true);