Author: bstansberry(a)jboss.com
Date: 2008-11-26 23:06:45 -0500 (Wed, 26 Nov 2008)
New Revision: 7208
Modified:
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
Log:
Handle expiration/passivation of sessions in buddy backup tree
Modified:
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2008-11-27
02:12:22 UTC (rev 7207)
+++
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2008-11-27
04:06:45 UTC (rev 7208)
@@ -38,6 +38,8 @@
import org.jboss.cache.CacheManager;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.integration.websession.util.WebAppMetadata.Granularity;
import org.jboss.cache.notifications.annotation.CacheListener;
@@ -147,13 +149,16 @@
* Allows test driver to mock Tomcat background processes' expiration
* of an overage session.
*
- * FIXME deal with buddy backup tree
- *
* @param id the session id
*/
public void expireSession(String id)
{
Session session = removeSession(id, true, true);
+ if (buddyReplication)
+ {
+ cleanBuddyBackupTree(id, false);
+ }
+
if (session != null)
session.getMetadata().valid = false;
}
@@ -162,8 +167,6 @@
* Allows test driver to mock Tomcat background processes' passivation
* of a session.
*
- * FIXME deal with buddy backup tree
- *
* @param id the session id
*/
public void passivate(String id)
@@ -174,6 +177,11 @@
sessions.remove(id);
cache.evict(getSessionFqn(id), true);
+
+ if (buddyReplication)
+ {
+ cleanBuddyBackupTree(id, true);
+ }
}
public Cache<Object, Object> getCache()
@@ -528,5 +536,30 @@
session.setOutdated(true);
}
}
+
+ private void cleanBuddyBackupTree(String id, boolean evict)
+ {
+ Fqn<String> mainFqn = getSessionFqn(id);
+ Node<Object, Object> root =
cache.getNode(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
+ if (root != null)
+ {
+ Set<Node<Object, Object>> children = root.getChildren();
+ for (Node<Object, Object> child : children)
+ {
+ @SuppressWarnings("unchecked")
+ Fqn<String> backupFqn = Fqn.fromRelativeFqn(child.getFqn(), mainFqn);
+ if (evict)
+ {
+ cache.evict(backupFqn, true);
+ }
+ else
+ {
+
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ cache.removeNode(backupFqn);
+ }
+ }
+ }
+
+ }
}