boolean marshalling)
throws Exception
{
++testCount;
String passDir = getPassivationDir(testCount, 1);
JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
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", 30, jbcm.getPassivationMaxIdleTime());
assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
passDir = getPassivationDir(testCount, 2);
JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
PojoCache cache1 = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
jbcm1.init("test.war", webMetaData);
jbcm1.start();
SessionTestUtil.blockUntilViewsReceived(new Cache[]{ cache.getCache(), cache1.getCache()}, 10000);
assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
assertEquals("Correct max active count", 2, jbcm1.getMaxActiveAllowed());
assertEquals("Correct max idle time", 30, jbcm1.getPassivationMaxIdleTime());
assertEquals("Correct min idle time", 1, jbcm1.getPassivationMinIdleTime());
// Set up a session
createAndUseSession(jbcm, "1", true, true);
assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
// Create a 2nd
createAndUseSession(jbcm1, "2", true, true);
assertEquals("Session count correct", 2, 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("Session count correct", 2, jbcm1.getActiveSessionCount());
assertEquals("Local session count correct", 1, jbcm1.getLocalActiveSessionCount());
assertEquals("Created session count correct", 1, jbcm1.getCreatedSessionCount());
assertEquals("Expired session count correct", 0, jbcm1.getExpiredSessionCount());
// Sleep past minIdleTime
SessionTestUtil.sleepThread(1100);
assertEquals("Passivated session count correct", 0, jbcm1.getPassivatedSessionCount());
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());
// Both active sessions are local, as the remote session is oldest so we passivate it first
assertEquals("Local session count correct", 2, 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());
if (fullRestart)
{
jbcm1.stop();
cache1.stop();
cache1.destroy();
caches.remove(cache1);
}
jbcm.stop();
if (restartCache)
{
cache.stop();
cache.destroy();
caches.remove(cache);
passDir = getPassivationDir(testCount, 1);
jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
}
else
{
jbcm = SessionTestUtil.createManager("test" + testCount, 300, cache, null);
}
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", 30, jbcm.getPassivationMaxIdleTime());
assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
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());
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", 2, 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);
createAndUseSession(jbcm, "4", true, true);