[jboss-cvs] JBossAS SVN: r74547 - in trunk: testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jun 13 14:40:18 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-06-13 14:40:18 -0400 (Fri, 13 Jun 2008)
New Revision: 74547
Modified:
trunk/testsuite/imports/config/tests-clustering.xml
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml
trunk/testsuite/src/resources/cluster/http/passivation/ATTRIBUTE/jboss-web.xml
trunk/testsuite/src/resources/cluster/http/passivation/FIELD/jboss-web.xml
trunk/testsuite/src/resources/cluster/http/passivation/SESSION/jboss-web.xml
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheWrapper.java
Log:
[JBAS-5628][JBAS-5629] Web session persistent store cleanup
Modified: trunk/testsuite/imports/config/tests-clustering.xml
===================================================================
--- trunk/testsuite/imports/config/tests-clustering.xml 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/imports/config/tests-clustering.xml 2008-06-13 18:40:18 UTC (rev 74547)
@@ -234,6 +234,7 @@
<param name="cluster.includes.refid" value="${cluster.http.includes}"/>
<param name="jboss-junit-configuration" value="BuddyReplEnabled-${jboss-junit-configuration}"/>
<param name="jbosstest.cluster.web.cache.config" value="br-enabled-sync-standard-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.br" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-BR-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-BR-1"/>
</antcall>
@@ -244,6 +245,7 @@
<param name="cluster.includes.refid" value="${cluster.http.field.includes}"/>
<param name="jboss-junit-configuration" value="BuddyReplEnabled-${jboss-junit-configuration}"/>
<param name="jbosstest.cluster.web.cache.config" value="br-enabled-sync-field-granularity-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.br" value="true"/>
<param name="jbosstest.cluster.web.cache.pojo" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-BR-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-BR-1"/>
@@ -429,7 +431,6 @@
<param name="cluster.includes.refid" value="one.test.includes"/>
<param name="jboss-junit-configuration" value="Default-${jboss-junit-configuration}"/>
<param name="jbosstest.cluster.web.cache.config" value="standard-session-cache"/>
- <param name="jbosstest.cluster.web.cache.pojo" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-1"/>
</antcall>
@@ -514,6 +515,7 @@
<param name="cluster.includes.refid" value="one.test.includes"/>
<param name="jboss-junit-configuration" value="BuddyReplEnabled-${jboss-junit-configuration}"/>
<param name="jbosstest.cluster.web.cache.config" value="br-enabled-sync-standard-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.br" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-BR-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-BR-1"/>
</antcall>
@@ -537,6 +539,7 @@
<param name="cluster.includes.refid" value="one.test.includes"/>
<param name="jboss-junit-configuration" value="BuddyReplEnabled-${jboss-junit-configuration}"/>
<param name="jbosstest.cluster.web.cache.config" value="br-enabled-sync-field-granularity-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.br" value="true"/>
<param name="jbosstest.cluster.web.cache.pojo" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-field-${jboss-junit-configuration}-BR-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-field-${jboss-junit-configuration}-BR-1"/>
@@ -605,6 +608,7 @@
<param name="cluster.includes.refid" value="cluster.defaultcfg.http.includes"/>
<param name="jboss-junit-configuration" value="BuddyReplEnabled-${jboss-junit-configuration}"/>
<param name="jbosstest.cluster.web.cache.config" value="br-enabled-sync-standard-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.br" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-BR-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-BR-1"/>
</antcall>
@@ -651,6 +655,7 @@
<param name="cluster.includes.refid" value="cluster.defaultcfg.http.field.includes"/>
<param name="jboss-junit-configuration" value="BuddyReplEnabled-${jboss-junit-configuration}"/>
<param name="jbosstest.cluster.web.cache.config" value="br-enabled-sync-field-granularity-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.br" value="true"/>
<param name="jbosstest.cluster.web.cache.pojo" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-field-${jboss-junit-configuration}-BR-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-field-${jboss-junit-configuration}-BR-1"/>
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java 2008-06-13 18:40:18 UTC (rev 74547)
@@ -750,14 +750,14 @@
JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
PojoCache cache = jbcm.getPojoCache();
- JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2, true, 3, 1);
+ JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2, true, 30, 1);
jbcm.init("test.war", webMetaData);
jbcm.start();
assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
assertEquals("Correct max active count", 2, jbcm.getMaxActiveAllowed());
- assertEquals("Correct max idle time", 3, jbcm.getPassivationMaxIdleTime());
+ assertEquals("Correct max idle time", 30, jbcm.getPassivationMaxIdleTime());
assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
passDir = getPassivationDir(testCount, 2);
@@ -772,7 +772,7 @@
assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
assertEquals("Correct max active count", 2, jbcm1.getMaxActiveAllowed());
- assertEquals("Correct max idle time", 3, jbcm1.getPassivationMaxIdleTime());
+ assertEquals("Correct max idle time", 30, jbcm1.getPassivationMaxIdleTime());
assertEquals("Correct min idle time", 1, jbcm1.getPassivationMinIdleTime());
// Set up a session
@@ -802,11 +802,13 @@
createAndUseSession(jbcm1, "3", true, true);
+ // jbcm has 3 active because receipt of repl doesn't trigger passivation
assertEquals("Session count correct", 3, jbcm.getActiveSessionCount());
assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
assertEquals("Created session count correct", 1, jbcm.getCreatedSessionCount());
assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
assertEquals("Passivated session count correct", 0, jbcm.getPassivatedSessionCount());
+ // jbcm1 only has 2 active since it passivated one when it created 3rd
assertEquals("Session count correct", 2, jbcm1.getActiveSessionCount());
assertEquals("Local session count correct", 1, jbcm1.getLocalActiveSessionCount());
assertEquals("Created session count correct", 2, jbcm1.getCreatedSessionCount());
@@ -842,15 +844,25 @@
assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
assertEquals("Correct max active count", 2, jbcm.getMaxActiveAllowed());
- assertEquals("Correct max idle time", 3, jbcm.getPassivationMaxIdleTime());
+ assertEquals("Correct max idle time", 30, jbcm.getPassivationMaxIdleTime());
assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
- assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
+ int expected = (totalReplication && marshalling && fullRestart) ? 0 : 2;
+ assertEquals("Session count correct", expected, jbcm.getActiveSessionCount());
assertEquals("Local session count correct", 0, jbcm.getLocalActiveSessionCount());
assertEquals("Created session count correct", 0, jbcm.getCreatedSessionCount());
assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
- assertEquals("Passivated session count correct", 1, jbcm.getPassivatedSessionCount());
+ expected = (totalReplication && !(marshalling && fullRestart)) ? 1 : 0;
+ assertEquals("Passivated session count correct", expected, jbcm.getPassivatedSessionCount());
+ if (!fullRestart)
+ {
+ assertEquals("Session count correct", 2, jbcm1.getActiveSessionCount());
+ assertEquals("Local session count correct", 1, jbcm1.getLocalActiveSessionCount());
+ assertEquals("Created session count correct", 2, jbcm1.getCreatedSessionCount());
+ assertEquals("Expired session count correct", 0, jbcm1.getExpiredSessionCount());
+ assertEquals("Passivated session count correct", 1, jbcm1.getPassivatedSessionCount());
+ }
// Sleep past minIdleTime
SessionTestUtil.sleepThread(1100);
@@ -875,7 +887,7 @@
public void testMarshalledRedeploy() throws Exception
{
- log.info("Enter testStandaloneRedeploy");
+ log.info("Enter testMarshalledRedeploy");
replicatedWarRedeployTest(false, false, false, true);
@@ -883,12 +895,28 @@
public void testMarshalledRestart() throws Exception
{
- log.info("Enter testStandaloneRestart");
+ log.info("Enter testMarshalledRestart");
replicatedWarRedeployTest(true, true, false, true);
}
+ public void testTotalMarshalledRedeploy() throws Exception
+ {
+ log.info("Enter testTotalMarshalledRedeploy");
+
+ replicatedWarRedeployTest(false, false, true, true);
+
+ }
+
+ public void testTotalMarshalledRestart() throws Exception
+ {
+ log.info("Enter testTotalMarshalledRestart");
+
+ replicatedWarRedeployTest(true, true, true, true);
+
+ }
+
private Session createAndUseSession(JBossCacheManager jbcm, String id,
boolean canCreate, boolean access)
throws Exception
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java 2008-06-13 18:40:18 UTC (rev 74547)
@@ -54,5 +54,12 @@
{
return "http-field-pass";
}
+
+ @Override
+ protected boolean isCleanCacheOnRedeploy()
+ {
+ // With region based marshalling we always clean the cache
+ return true;
+ }
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java 2008-06-13 18:40:18 UTC (rev 74547)
@@ -57,6 +57,7 @@
protected String getUrlBase_;
protected String invalidateUrlBase_;
private String warFqn_;
+ private boolean usingBuddyReplication_;
private Set<HttpClient> clients = new HashSet<HttpClient>();
@@ -104,6 +105,9 @@
deploy(adaptors[1]);
deployed1 = true;
}
+
+ String br = System.getProperty("jbosstest.cluster.web.cache.br");
+ usingBuddyReplication_ = Boolean.parseBoolean(br);
}
protected void tearDown() throws Exception
@@ -125,6 +129,11 @@
}
}
+ protected boolean isCleanCacheOnRedeploy()
+ {
+ return usingBuddyReplication_;
+ }
+
/**
* Tests the ability to passivate session when max idle for session is reached
*
@@ -185,15 +194,14 @@
sleepThread(2100);
// Create enough sessions on server0 to trigger passivation
- // assuming that max-active-sessions is set to 20 in jboss-web.xml
+ // assuming that max-active-sessions is set to 10 in jboss-web.xml
getLog().debug("current active sessions = " + SessionTestUtil.getSessionIds(adaptors[0], warFqn_));
- HttpClient[] newClients = new HttpClient[(20)];
- for (int i = 0; i < newClients.length; i++)
+ for (int i = 0; i < 10; i++)
{
- newClients[i] = new HttpClient();
- clients.add(newClients[i]);
- makeGet(newClients[i], baseURL0_ +setUrl);
- makeGet(newClients[i], baseURL0_ +getUrl);
+ HttpClient newClient = new HttpClient();
+ clients.add(newClient);
+ makeGet(newClient, baseURL0_ +setUrl);
+ makeGet(newClient, baseURL0_ +getUrl);
}
// access the session and confirm that it was deserialized (passivated/activated)
@@ -244,9 +252,17 @@
// Get the Attribute using the same session ID
SessionTestUtil.setCookieDomainToThisServer(client, servers_[0]);
- String attr0 = makeGet(client, baseURL0_ +getUrl);
- assertEquals("attributeMatches after activation", attr0, attr);
+ if (isCleanCacheOnRedeploy())
+ {
+ // We don't expect data to survive a restart
+ makeGetFailed(client, baseURL0_ +getUrl);
+ }
+ else
+ {
+ String attr0 = makeGet(client, baseURL0_ +getUrl);
+ assertEquals("attributeMatches after activation", attr0, attr);
+ }
getLog().debug("Exit testRedeploy");
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2008-06-13 18:40:18 UTC (rev 74547)
@@ -125,6 +125,7 @@
FileCacheLoaderConfig fclc = new FileCacheLoaderConfig();
fclc.setProperties(clc.getFirstCacheLoaderConfig().getProperties());
fclc.setLocation(passivationDir);
+ fclc.setFetchPersistentState(true);
ArrayList<IndividualCacheLoaderConfig> iclcs = new ArrayList<IndividualCacheLoaderConfig>();
iclcs.add(fclc);
clc.setIndividualCacheLoaderConfigs(iclcs);
Modified: trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/src/resources/cluster/http/jboss-web-test-service.xml 2008-06-13 18:40:18 UTC (rev 74547)
@@ -45,7 +45,6 @@
<attribute name="CacheLoaderConfig">
<config>
<passivation>true</passivation>
- <preload>/</preload>
<shared>false</shared>
<cacheloader>
<class>org.jboss.cache.loader.FileCacheLoader</class>
Modified: trunk/testsuite/src/resources/cluster/http/passivation/ATTRIBUTE/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/passivation/ATTRIBUTE/jboss-web.xml 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/src/resources/cluster/http/passivation/ATTRIBUTE/jboss-web.xml 2008-06-13 18:40:18 UTC (rev 74547)
@@ -10,7 +10,7 @@
<replication-trigger>SET_AND_NON_PRIMITIVE_GET</replication-trigger>
<replication-granularity>ATTRIBUTE</replication-granularity>
</replication-config>
- <max-active-sessions>20</max-active-sessions>
+ <max-active-sessions>10</max-active-sessions>
<passivation-config>
<use-session-passivation>true</use-session-passivation>
<passivation-min-idle-time>2</passivation-min-idle-time>
Modified: trunk/testsuite/src/resources/cluster/http/passivation/FIELD/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/passivation/FIELD/jboss-web.xml 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/src/resources/cluster/http/passivation/FIELD/jboss-web.xml 2008-06-13 18:40:18 UTC (rev 74547)
@@ -12,7 +12,7 @@
<replication-granularity>FIELD</replication-granularity>
<replication-field-batch-mode>TRUE</replication-field-batch-mode>
</replication-config>
- <max-active-sessions>20</max-active-sessions>
+ <max-active-sessions>10</max-active-sessions>
<passivation-config>
<use-session-passivation>true</use-session-passivation>
<passivation-min-idle-time>2</passivation-min-idle-time>
Modified: trunk/testsuite/src/resources/cluster/http/passivation/SESSION/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/passivation/SESSION/jboss-web.xml 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/testsuite/src/resources/cluster/http/passivation/SESSION/jboss-web.xml 2008-06-13 18:40:18 UTC (rev 74547)
@@ -11,7 +11,7 @@
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
- <max-active-sessions>20</max-active-sessions>
+ <max-active-sessions>10</max-active-sessions>
<passivation-config>
<use-session-passivation>true</use-session-passivation>
<passivation-min-idle-time>2</passivation-min-idle-time>
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java 2008-06-13 18:40:18 UTC (rev 74547)
@@ -165,7 +165,7 @@
try {
// Ignore any cache notifications that our own work generates
SessionReplicationContext.startCacheActivity();
- cacheWrapper_.removeLocalSubtree(fqn);
+ cacheWrapper_.removeLocal(fqn);
}
finally {
SessionReplicationContext.finishCacheActivity();
@@ -189,7 +189,7 @@
try {
// Ignore any cache notifications that our own work generates
SessionReplicationContext.startCacheActivity();
- cacheWrapper_.removeLocalSubtree(fqn);
+ cacheWrapper_.removeLocal(fqn);
}
finally {
SessionReplicationContext.finishCacheActivity();
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java 2008-06-13 18:40:18 UTC (rev 74547)
@@ -2052,6 +2052,8 @@
if (passivationMax >= 0
&& elapsed > passivationMax)
{
+ if (log_.isTraceEnabled())
+ log_.trace("Elapsed time of " + elapsed + " for session "+ realId + " exceeds max of " + passivationMax + "; passivating");
processUnloadedSessionPassivation(realId, osu);
}
// If the session didn't exceed the passivationMaxIdleTime_, see
@@ -2059,9 +2061,11 @@
// active sessions, passivate the session if it exceed passivationMinIdleTime_
else if (maxActive_ > 0
&& passivationMin >= 0
- && calcActiveSessions() >= maxActive_
+ && calcActiveSessions() > maxActive_
&& elapsed >= passivationMin)
{
+ if (log_.isTraceEnabled())
+ log_.trace("Elapsed time of " + elapsed + " for session "+ realId + " exceeds min of " + passivationMin + "; passivating");
processUnloadedSessionPassivation(realId, osu);
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java 2008-06-13 18:40:18 UTC (rev 74547)
@@ -66,21 +66,18 @@
public static final Fqn BUDDY_BACKUP_FQN = BuddyManager.BUDDY_BACKUP_SUBTREE_FQN;
public static final String SESSION = "JSESSION";
public static final String ATTRIBUTE = "ATTRIBUTE";
- // Needed for cache invalidation
public static final String VERSION_KEY = "V";
public static final String TIMESTAMP_KEY = "T";
public static final String METADATA_KEY = "M";
public static final String ATTRIBUTE_KEY = "A";
- static final String FQN_DELIMITER = "/";
+ public static final String FQN_DELIMITER = "/";
private Cache plainCache_;
- // name of webapp's virtual host(JBAS-2194).
- // Idea is host_name + web_app_path + session id is a unique combo.
+ /** name of webapp's virtual host; hostName + webAppPath + session id is a unique combo. */
protected String hostName_;
- // web app path (JBAS-1367 and JBAS-2194).
- // Idea is host_name + web_app_path + session id is a unique combo.
+ /** Context path for webapp; hostName + webAppPath + session id is a unique combo. */
protected String webAppPath_;
protected TransactionManager tm;
@@ -88,14 +85,17 @@
private CacheListener cacheListener_;
protected JBossCacheWrapper cacheWrapper_;
- // Do we have to marshall attributes ourself or can we let
- // the TreeCache do it?
+ /** Do we have to marshall attributes ourself or can we let JBC do it? */
private boolean useTreeCacheMarshalling_ = false;
- // Are we configured for passivation?
+ /** Are we configured for passivation? */
private boolean usePassivation_ = false;
private PassivationListener passivationListener_;
+ /** Is cache configured for buddy replication? */
+ private boolean useBuddyReplication_ = false;
+
+
public JBossCacheService(Cache cache)
{
plainCache_ = cache;
@@ -152,7 +152,27 @@
hostName_ = host;
}
log_.debug("Old and new virtual host name are: " + host + ", " + hostName_);
+
+
+ // We require the cache tm to be BatchModeTransactionManager now.
+ tm = plainCache_.getConfiguration().getRuntimeConfig().getTransactionManager();
+ if( ! (tm instanceof BatchModeTransactionManager) )
+ {
+ throw new RuntimeException("start(): JBoss Cache transaction manager " +
+ "is not of type BatchModeTransactionManager. " +
+ "It is " + (tm == null ? "null" : tm.getClass().getName()));
+ }
+ Object[] objs = new Object[]{SESSION, hostName_, webAppPath_};
+ Fqn pathFqn = new Fqn( objs );
+
+ BuddyReplicationConfig brc = plainCache_.getConfiguration().getBuddyReplicationConfig();
+ this.useBuddyReplication_ = brc != null && brc.isEnabled();
+ if (useTreeCacheMarshalling_ || this.useBuddyReplication_)
+ {
+ // JBAS-5628/JBAS-5629 -- clean out persistent store
+ cleanWebappRegion(pathFqn);
+ }
// Listen for cache changes
cacheListener_ = new CacheListener(cacheWrapper_, manager_, hostName_, webAppPath_);
@@ -163,8 +183,7 @@
// register the tcl and bring over the state for the webapp
try
{
- Object[] objs = new Object[]{SESSION, hostName_, webAppPath_};
- Fqn pathFqn = new Fqn( objs );
+
log_.debug("UseMarshalling is true. We will register the fqn: " +
pathFqn + " with class loader" +tcl +
" and activate the webapp's Region");
@@ -183,14 +202,6 @@
throw new RuntimeException("Can't register class loader", ex);
}
}
-
- // We require the cache tm to be BatchModeTransactionManager now.
- tm = plainCache_.getConfiguration().getRuntimeConfig().getTransactionManager();
- if( ! (tm instanceof BatchModeTransactionManager) )
- {
- throw new RuntimeException("JBossCacheService.start(): JBossCacheAop transaction manager is not of type BatchModeTransactionManager." +
- " Please check the jboss-web-cluster-service.xml TransactionManagerClassLookup field.");
- }
if(manager_.isPassivationEnabled())
{
@@ -204,6 +215,19 @@
}
}
+ private void cleanWebappRegion(Fqn regionFqn)
+ {
+ try {
+ // Remove locally.
+ plainCache_.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ plainCache_.removeNode(regionFqn);
+ }
+ catch (CacheException e)
+ {
+ log_.error("can't clean content from the underlying distributed cache");
+ }
+ }
+
public void stop()
{
plainCache_.removeCacheListener(cacheListener_);
@@ -233,7 +257,13 @@
" or un-registration of its class loader", e);
}
}
-
+ BuddyReplicationConfig brc = plainCache_.getConfiguration().getBuddyReplicationConfig();
+ this.useBuddyReplication_ = brc != null && brc.isEnabled();
+ if (useTreeCacheMarshalling_ || this.useBuddyReplication_)
+ {
+ // JBAS-5628/JBAS-5629 -- clean out persistent store
+ cleanWebappRegion(pathFqn);
+ }
// remove session data
// BES 2007/08/18 Can't do this as it will
// 1) blow away passivated sessions
@@ -372,7 +402,7 @@
plainCache_.removeRegion(fqn);
}
- cacheWrapper_.removeLocalSubtree(fqn);
+ cacheWrapper_.removeLocal(fqn);
}
public void removeSessionLocal(String realId, String dataOwner)
@@ -388,7 +418,7 @@
{
log_.trace("Remove session from my own distributed store only. Fqn: " + fqn);
}
- cacheWrapper_.removeLocalSubtree(fqn);
+ cacheWrapper_.removeLocal(fqn);
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheWrapper.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheWrapper.java 2008-06-13 17:22:11 UTC (rev 74546)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheWrapper.java 2008-06-13 18:40:18 UTC (rev 74547)
@@ -21,13 +21,10 @@
*/
package org.jboss.web.tomcat.service.session;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
import org.jboss.cache.lock.TimeoutException;
public class JBossCacheWrapper
@@ -234,32 +231,6 @@
throw new RuntimeException(RETRY_FAIL_MSG, ex);
}
-
- /**
- * Wrapper to embed retry logic.
- *
- * @param fqn
- */
- void evict(Fqn fqn)
- {
- // FIXME remove this method if it remains unused
-
- TimeoutException ex = null;
- for (int i = 0; i < RETRY; i++)
- {
- try
- {
- plainCache_.evict(fqn, false);
- return;
- }
- catch (TimeoutException e)
- {
- ex = e;
- }
- }
-
- throw new RuntimeException(RETRY_FAIL_MSG, ex);
- }
void evictSubtree(Fqn fqn)
{
@@ -268,24 +239,6 @@
{
try
{
-// // Evict the node itself first, since if it stores a Pojo
-// // that will do everything
-// plainCache_.evict(fqn);
-//
-// // next do a depth first removal; this ensure all nodes
-// // are removed, not just their data map
-// Set children = plainCache_.getChildrenNames(fqn);
-// if (children != null)
-// {
-// for (Iterator it = children.iterator(); it.hasNext(); )
-// {
-// Fqn child = new Fqn(fqn, it.next());
-// plainCache_.evict(child);
-// }
-//
-// plainCache_.evict(fqn);
-// }
-// return;
plainCache_.evict(fqn, true);
return;
@@ -298,50 +251,5 @@
throw new RuntimeException(RETRY_FAIL_MSG, ex);
}
-
- void removeLocalSubtree(Fqn fqn)
- {
- // First remove the node itself. If it is the root of an AOP
- // object tree, this will do everything
- removeLocal(fqn);
- // Next, clear any children
- TimeoutException ex = null;
- for (int i = 0; i < RETRY; i++)
- {
- try
- {
- // Evict the node itself first, since if it stores a Pojo
- // that will do everything
- removeLocal(fqn);
-
- // next do a depth first removal; this ensures all nodes
- // are removed, not just their data map
- Node base = plainCache_.getRoot().getChild(fqn);
- if (base != null)
- {
- Set children = base.getChildren();
- if (children != null)
- {
- for (Iterator it = children.iterator(); it.hasNext(); )
- {
- Node child = (Node) it.next();
- removeLocalSubtree(child.getFqn());
- }
-
- removeLocal(fqn);
- }
- }
- return;
-
- }
- catch (TimeoutException e)
- {
- ex = e;
- }
- }
-
- throw new RuntimeException(RETRY_FAIL_MSG, ex);
- }
-
}
More information about the jboss-cvs-commits
mailing list