[jboss-cvs] JBossAS SVN: r72468 - in trunk: testsuite/imports and 27 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Apr 20 21:04:46 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-04-20 21:04:46 -0400 (Sun, 20 Apr 2008)
New Revision: 72468
Added:
trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossClusteredWebTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/TestConfigurationAdder.java
trunk/testsuite/src/resources/cluster/web/cachehelper/jboss-beans.xml
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java
Removed:
trunk/testsuite/src/resources/cluster/web/cachehelper/jboss-service.xml
Modified:
trunk/testsuite/build.xml
trunk/testsuite/imports/config/tests-clustering.xml
trunk/testsuite/imports/sections/cluster.xml
trunk/testsuite/imports/server-config.xml
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java
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/field/test/ScopedFieldBasedTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/jk/test/JvmRouteURLRewritingTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/AttributeBasedSessionPassivationTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/CrossContextCallsTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ScopedSetAttributeTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ScopedSetTriggerTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionEventTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SimpleTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/UndeployFieldTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/AttributeBasedConcurrentTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedAttrBasedTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/SessionBasedConcurrentTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployAttrTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/WebSessionTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/WebTestBase.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java
trunk/testsuite/src/resources/cluster/http/http-cross-ctx-first/WEB-INF/jboss-web.xml
trunk/testsuite/src/resources/cluster/http/http-cross-ctx-second/WEB-INF/jboss-web.xml
trunk/testsuite/src/resources/cluster/http/http-cross-ctx-third/WEB-INF/jboss-web.xml
trunk/testsuite/src/resources/cluster/http/http-field/WEB-INF/jboss-web.xml
trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field-batch-false.xml
trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field-scoped.xml
trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field.xml
trunk/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml
trunk/testsuite/src/resources/cluster/http/http-scoped/WEB-INF/jboss-web.xml
trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-attr-based.xml
trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-attr-set.xml
trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-set-trigger.xml
trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web.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/testsuite/src/resources/cluster/http/version.jsp
trunk/tomcat/build.xml
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedClusteredSession.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheCluster.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.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
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java
trunk/tomcat/src/resources/war-deployers-beans.xml
Log:
[JBAS-5381] Convert JBossCacheManager to use CacheManager
Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/build.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -1055,8 +1055,8 @@
<create-cluster-sso-node newconf="tomcat-sso-cluster1"/>
<echo message="Modifying the node0 and node1 Tomcat configuration for REPL_SYNC/UseJK"/>
- <http-cluster-node-config-change conf="tomcat-sso-cluster0" useBuddyRepl="false"/>
- <http-cluster-node-config-change conf="tomcat-sso-cluster1" useBuddyRepl="false"/>
+ <http-cluster-node-config-change conf="tomcat-sso-cluster0"/>
+ <http-cluster-node-config-change conf="tomcat-sso-cluster1"/>
<server:start name="tomcat-sso-cluster0"/>
<server:start name="tomcat-sso-cluster1"/>
@@ -3118,8 +3118,8 @@
<create-cluster-sso-node newconf="tomcat-sso-cluster1"/>
<echo message="Modifying the node0 and node1 Tomcat configuration for REPL_SYNC/UseJK"/>
- <http-cluster-node-config-change conf="tomcat-sso-cluster0" useBuddyRepl="false"/>
- <http-cluster-node-config-change conf="tomcat-sso-cluster1" useBuddyRepl="false"/>
+ <http-cluster-node-config-change conf="tomcat-sso-cluster0"/>
+ <http-cluster-node-config-change conf="tomcat-sso-cluster1"/>
<server:start name="tomcat-sso-cluster0"/>
<server:start name="tomcat-sso-cluster1"/>
Modified: trunk/testsuite/imports/config/tests-clustering.xml
===================================================================
--- trunk/testsuite/imports/config/tests-clustering.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/imports/config/tests-clustering.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -148,41 +148,35 @@
<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>
+
+ <echo message="Going to call target tests-clustering-unit for HTTP tests (ASYNC, no BR)"/>
- <echo message="Going to call target tests-clustering-unit for HTTP tests (ASYNC, with BR)"/>
-
<antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="${cluster.http.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.node0.config" value="cluster-${jboss-junit-configuration}-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-1"/>
</antcall>
- <server:stop name="cluster-${jboss-junit-configuration}-0"/>
- <server:stop name="cluster-${jboss-junit-configuration}-1"/>
+ <echo message="Going to call target tests-clustering-unit again for FIELD granularity tests (ASYNC, no BR)"/>
- <sleep seconds="4"/>
-
- <echo message="Going to call target tests-clustering-unit again for FIELD granularity tests (ASYNC, with BR)"/>
-
- <antcall target="tests-clustering-field-configure" inheritRefs="true"/>
-
- <server:start name="cluster-field-${jboss-junit-configuration}-0"/>
- <server:start name="cluster-field-${jboss-junit-configuration}-1"/>
-
- <antcall target="tests-clustering-unit">
+ <antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="${cluster.http.field.includes}"/>
<param name="jboss-junit-configuration" value="Default-${jboss-junit-configuration}"/>
- <param name="jbosstest.cluster.node0.config" value="cluster-field-${jboss-junit-configuration}-0"/>
- <param name="jbosstest.cluster.node1.config" value="cluster-field-${jboss-junit-configuration}-1"/>
+ <param name="jbosstest.cluster.web.cache.config" value="field-granularity-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>
- <server:stop name="cluster-field-${jboss-junit-configuration}-0"/>
- <server:stop name="cluster-field-${jboss-junit-configuration}-1"/>
+ <server:stop name="cluster-${jboss-junit-configuration}-0"/>
+ <server:stop name="cluster-${jboss-junit-configuration}-1"/>
+
<sleep seconds="4"/>
- <echo message="Going to call target tests-clustering-unit again with new configuration (SYNC, with BR)"/>
+ <echo message="Going to call target tests-clustering-unit again with new configuration (SYNC, no BR)"/>
<antcall target="tests-clustering-sync-configure"/>
@@ -192,6 +186,7 @@
<antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="${cluster.http.jk.includes}"/>
<param name="jboss-junit-configuration" value="SyncModeNUseJvm-${jboss-junit-configuration}"/>
+ <param name="jbosstest.cluster.web.cache.config" value="sync-standard-session-cache"/>
<param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-SYNC-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-SYNC-1"/>
</antcall>
@@ -199,67 +194,57 @@
<antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="${cluster.http.includes}"/>
<param name="jboss-junit-configuration" value="SyncModeNUseJvm-${jboss-junit-configuration}"/>
+ <param name="jbosstest.cluster.web.cache.config" value="sync-standard-session-cache"/>
+ <param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-SYNC-0"/>
+ <param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-SYNC-1"/>
</antcall>
- <server:stop name="cluster-${jboss-junit-configuration}-SYNC-0"/>
- <server:stop name="cluster-${jboss-junit-configuration}-SYNC-1"/>
+ <echo message="Going to call target tests-clustering-unit again for FIELD granularity tests (SYNC, no BR)"/>
- <sleep seconds="4"/>
-
- <echo message="Going to call target tests-clustering-unit again for FIELD granularity tests with new configuration (SYNC, with BR)"/>
-
- <antcall target="tests-clustering-field-sync-configure"/>
-
- <server:start name="cluster-field-${jboss-junit-configuration}-SYNC-0"/>
- <server:start name="cluster-field-${jboss-junit-configuration}-SYNC-1"/>
-
<antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="${cluster.http.field.includes}"/>
<param name="jboss-junit-configuration" value="SyncModeNUseJvm-${jboss-junit-configuration}"/>
- <param name="jbosstest.cluster.node0.config" value="cluster-field-${jboss-junit-configuration}-SYNC-0"/>
- <param name="jbosstest.cluster.node1.config" value="cluster-field-${jboss-junit-configuration}-SYNC-1"/>
+ <param name="jbosstest.cluster.web.cache.config" value="sync-field-granularity-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.pojo" value="true"/>
+ <param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-SYNC-0"/>
+ <param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-SYNC-1"/>
</antcall>
- <server:stop name="cluster-field-${jboss-junit-configuration}-SYNC-0"/>
- <server:stop name="cluster-field-${jboss-junit-configuration}-SYNC-1"/>
+ <server:stop name="cluster-${jboss-junit-configuration}-SYNC-0"/>
+ <server:stop name="cluster-${jboss-junit-configuration}-SYNC-1"/>
- <sleep seconds="4"/>
+ <sleep seconds="4"/>
- <echo message="Going to call target tests-clustering-unit again with new configuration (SYNC, BR)"/>
+ <echo message="Going to call target tests-clustering-unit again with new configuration (SYNC, BR)"/>
- <antcall target="tests-clustering-br-configure"/>
+ <antcall target="tests-clustering-br-configure"/>
- <server:start name="cluster-${jboss-junit-configuration}-BR-0"/>
- <server:start name="cluster-${jboss-junit-configuration}-BR-1"/>
+ <server:start name="cluster-${jboss-junit-configuration}-BR-0"/>
+ <server:start name="cluster-${jboss-junit-configuration}-BR-1"/>
+ <echo message="Going to call target tests-clustering-unit again with new configuration (SYNC, BR)"/>
+
<antcall target="tests-clustering-unit">
<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.node0.config" value="cluster-${jboss-junit-configuration}-BR-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-BR-1"/>
</antcall>
- <server:stop name="cluster-${jboss-junit-configuration}-BR-0"/>
- <server:stop name="cluster-${jboss-junit-configuration}-BR-1"/>
+ <echo message="Going to call target tests-clustering-unit again for FIELD granularity tests with new configuration (SYNC, BR)"/>
- <sleep seconds="4"/>
-
- <echo message="Going to call target tests-clustering-unit again for FIELD granularity tests with new configuration (SYNC, no BR)"/>
-
- <antcall target="tests-clustering-field-br-configure"/>
-
- <server:start name="cluster-field-${jboss-junit-configuration}-BR-0"/>
- <server:start name="cluster-field-${jboss-junit-configuration}-BR-1"/>
-
<antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="${cluster.http.field.includes}"/>
<param name="jboss-junit-configuration" value="BuddyReplEnabled-${jboss-junit-configuration}"/>
- <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"/>
+ <param name="jbosstest.cluster.web.cache.config" value="br-enabled-sync-field-granularity-session-cache"/>
+ <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"/>
</antcall>
- <server:stop name="cluster-field-${jboss-junit-configuration}-BR-0"/>
- <server:stop name="cluster-field-${jboss-junit-configuration}-BR-1"/>
+ <server:stop name="cluster-${jboss-junit-configuration}-BR-0"/>
+ <server:stop name="cluster-${jboss-junit-configuration}-BR-1"/>
</target>
@@ -271,54 +256,42 @@
<target name="tests-clustering-field-configure" unless="${tests.clustering.skip.startup}">
<create-cluster-node conf="cluster-field-${jboss-junit-configuration}-0"/>
<create-cluster-node conf="cluster-field-${jboss-junit-configuration}-1"/>
-
- <echo message="Modifying the node0 and node1 Tomcat configuration for FIELD"/>
- <http-cluster-field-node-config-change conf="cluster-field-${jboss-junit-configuration}-0"/>
- <http-cluster-field-node-config-change conf="cluster-field-${jboss-junit-configuration}-1"/>
</target>
<target name="tests-clustering-sync-configure" unless="${tests.clustering.skip.startup}">
<create-cluster-node conf="cluster-${jboss-junit-configuration}-SYNC-0"/>
<create-cluster-node conf="cluster-${jboss-junit-configuration}-SYNC-1"/>
- <echo message="Modifying the node0 and node1 Tomcat configuration for REPL_SYNC/UseJK"/>
- <http-cluster-node-config-change conf="cluster-${jboss-junit-configuration}-SYNC-0" useBuddyRepl="false"/>
- <http-cluster-node-config-change conf="cluster-${jboss-junit-configuration}-SYNC-1" useBuddyRepl="false"/>
+ <echo message="Modifying the node0 and node1 Tomcat configuration for JK"/>
+ <http-cluster-node-config-change conf="cluster-${jboss-junit-configuration}-SYNC-0"/>
+ <http-cluster-node-config-change conf="cluster-${jboss-junit-configuration}-SYNC-1"/>
</target>
<target name="tests-clustering-field-sync-configure" unless="${tests.clustering.skip.startup}">
<create-cluster-node conf="cluster-field-${jboss-junit-configuration}-SYNC-0"/>
<create-cluster-node conf="cluster-field-${jboss-junit-configuration}-SYNC-1"/>
- <echo message="Modifying the node0 and node1 Tomcat configuration for FIELD"/>
- <http-cluster-field-node-config-change conf="cluster-field-${jboss-junit-configuration}-SYNC-0"/>
- <http-cluster-field-node-config-change conf="cluster-field-${jboss-junit-configuration}-SYNC-1"/>
-
- <echo message="Modifying the node0 and node1 Tomcat configuration for REPL_SYNC/UseJK"/>
- <http-cluster-node-config-change conf="cluster-field-${jboss-junit-configuration}-SYNC-0" useBuddyRepl="false"/>
- <http-cluster-node-config-change conf="cluster-field-${jboss-junit-configuration}-SYNC-1" useBuddyRepl="false"/>
+ <echo message="Modifying the node0 and node1 Tomcat configuration for JK"/>
+ <http-cluster-node-config-change conf="cluster-field-${jboss-junit-configuration}-SYNC-0"/>
+ <http-cluster-node-config-change conf="cluster-field-${jboss-junit-configuration}-SYNC-1"/>
</target>
<target name="tests-clustering-br-configure" unless="${tests.clustering.skip.startup}">
<create-cluster-node conf="cluster-${jboss-junit-configuration}-BR-0"/>
<create-cluster-node conf="cluster-${jboss-junit-configuration}-BR-1"/>
- <echo message="Modifying the node0 and node1 Tomcat configuration for REPL_SYNC/UseJK/BR"/>
- <http-cluster-node-config-change conf="cluster-${jboss-junit-configuration}-BR-0" useBuddyRepl="true"/>
- <http-cluster-node-config-change conf="cluster-${jboss-junit-configuration}-BR-1" useBuddyRepl="true"/>
+ <echo message="Modifying the node0 and node1 Tomcat configuration for JK"/>
+ <http-cluster-node-config-change conf="cluster-${jboss-junit-configuration}-BR-0"/>
+ <http-cluster-node-config-change conf="cluster-${jboss-junit-configuration}-BR-1"/>
</target>
<target name="tests-clustering-field-br-configure" unless="${tests.clustering.skip.startup}">
<create-cluster-node conf="cluster-field-${jboss-junit-configuration}-BR-0"/>
<create-cluster-node conf="cluster-field-${jboss-junit-configuration}-BR-1"/>
- <echo message="Modifying the node0 and node1 Tomcat configuration for FIELD"/>
- <http-cluster-field-node-config-change conf="cluster-field-${jboss-junit-configuration}-BR-0"/>
- <http-cluster-field-node-config-change conf="cluster-field-${jboss-junit-configuration}-BR-1"/>
-
- <echo message="Modifying the node0 and node1 Tomcat configuration for REPL_SYNC/UseJK/BR"/>
- <http-cluster-node-config-change conf="cluster-field-${jboss-junit-configuration}-BR-0" useBuddyRepl="true"/>
- <http-cluster-node-config-change conf="cluster-field-${jboss-junit-configuration}-BR-1" useBuddyRepl="true"/>
+ <echo message="Modifying the node0 and node1 Tomcat configuration for JK"/>
+ <http-cluster-node-config-change conf="cluster-field-${jboss-junit-configuration}-BR-0"/>
+ <http-cluster-node-config-change conf="cluster-field-${jboss-junit-configuration}-BR-1"/>
</target>
<!-- Executes a set of tests in a clustered environment -->
@@ -403,6 +376,8 @@
<antcall target="tests-clustering-unit">
<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>
@@ -418,6 +393,8 @@
<antcall target="tests-clustering-unit">
<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="field-granularity-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.pojo" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-field-${jboss-junit-configuration}-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-field-${jboss-junit-configuration}-1"/>
</antcall>
@@ -460,6 +437,8 @@
<antcall target="tests-clustering-unit">
<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="field-granularity-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.pojo" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-field-${jboss-junit-configuration}-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-field-${jboss-junit-configuration}-1"/>
</antcall>
@@ -481,9 +460,10 @@
<antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="one.test.includes"/>
- <param name="jboss-junit-configuration" value="BuddyReplDisabled-${jboss-junit-configuration}"/>
- <param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-0"/>
- <param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-1"/>
+ <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.node0.config" value="cluster-${jboss-junit-configuration}-BR-0"/>
+ <param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-BR-1"/>
</antcall>
<server:stop name="cluster-${jboss-junit-configuration}-BR-0"/>
@@ -503,9 +483,11 @@
<antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="one.test.includes"/>
- <param name="jboss-junit-configuration" value="BuddyReplDisabled-${jboss-junit-configuration}"/>
- <param name="jbosstest.cluster.node0.config" value="cluster-field-${jboss-junit-configuration}-0"/>
- <param name="jbosstest.cluster.node1.config" value="cluster-field-${jboss-junit-configuration}-1"/>
+ <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.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"/>
</antcall>
<server:stop name="cluster-field-${jboss-junit-configuration}-BR-0"/>
@@ -571,6 +553,8 @@
<antcall target="tests-clustering-unit">
<param name="cluster.includes.refid" value="cluster.defaultcfg.http.field.includes"/>
<param name="jboss-junit-configuration" value="Default-${jboss-junit-configuration}"/>
+ <param name="jbosstest.cluster.web.cache.config" value="field-granularity-session-cache"/>
+ <param name="jbosstest.cluster.web.cache.pojo" value="true"/>
<param name="jbosstest.cluster.node0.config" value="cluster-field-${jboss-junit-configuration}-0"/>
<param name="jbosstest.cluster.node1.config" value="cluster-field-${jboss-junit-configuration}-1"/>
</antcall>
Modified: trunk/testsuite/imports/sections/cluster.xml
===================================================================
--- trunk/testsuite/imports/sections/cluster.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/imports/sections/cluster.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -112,10 +112,11 @@
<!-- Remote interface to JBoss Cache -->
<jar destfile="${build.lib}/jbosscache-helper.sar">
<metainf dir="${build.resources}/cluster/web/cachehelper">
- <include name="jboss-service.xml"/>
+ <include name="jboss-beans.xml"/>
</metainf>
<fileset dir="${build.classes}">
<include name="org/jboss/test/cluster/web/CacheHelper*"/>
+ <include name="org/jboss/test/cluster/web/TestConfigurationAdder.class"/>
</fileset>
</jar>
Modified: trunk/testsuite/imports/server-config.xml
===================================================================
--- trunk/testsuite/imports/server-config.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/imports/server-config.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -905,15 +905,8 @@
<!-- A macro for setting up a node ready for http clustering config change -->
<macrodef name="http-cluster-node-config-change">
<attribute name="conf"/>
- <attribute name="useBuddyRepl" default="false"/>
<sequential>
- <!-- Switch from sync to async mode in cluster/jbossweb-cluster-beans.xml -->
- <replace file="${jboss.dist}/server/@{conf}/deploy/cluster/jbossweb-cluster-beans.xml"
- token=""cacheModeString">REPL_ASYNC" value=""cacheModeString">REPL_SYNC"/>
- <!-- Toggle buddy replication in jbossweb-cluster-beans.xml -->
- <replace file="${jboss.dist}/server/@{conf}/deploy/cluster/jbossweb-cluster-beans.xml"
- token="<property name="enabled">true" value="<property name="enabled">@{useBuddyRepl}"/>
- <!-- Added jvmRoute in server.xml -->
+ <!-- Added jvmRoute in server.xml -->
<echo message="Giving a name to the Tomcat instance under ${jboss.dist}/server/@{conf}"/>
<replace file="${jboss.dist}/server/@{conf}/deploy/jbossweb.sar/server.xml"
token="jvmRoute="@{conf}"" value=""/>
@@ -925,22 +918,6 @@
</sequential>
</macrodef>
- <!-- A macro for setting up a node ready for http clustering with FIELD granularity -->
- <macrodef name="http-cluster-field-node-config-change">
- <attribute name="conf"/>
- <attribute name="jboss.dist" default="${jboss.dist}"
- description="The jboss dist root directory" />
- <sequential>
- <echo message="Configuring the Tomcat instance under ${jboss.dist}/server/@{conf} for FIELD granularity"/>
- <!-- Switch on marshalling in cluster/jbossweb-cluster-beans.xml -->
- <replace file="@{jboss.dist}/server/@{conf}/deploy/cluster/jbossweb-cluster-beans.xml"
- token=""useRegionBasedMarshalling">false" value=""useRegionBasedMarshalling">true"/>
- <!-- Inactivate on startup in cluster/jbossweb-cluster-beans.xml -->
- <replace file="@{jboss.dist}/server/@{conf}/deploy/cluster/jbossweb-cluster-beans.xml"
- token=""inactiveOnStartup">false" value=""inactiveOnStartup">true"/>
- </sequential>
- </macrodef>
-
<!-- A macro to execute a junit task. macro attributes:
junit.patternset : require patternset id that identifies the junit test
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/CacheListenerUnitTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -28,6 +28,7 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.web.tomcat.service.session.CacheListener;
import org.jboss.web.tomcat.service.session.CacheListenerBase;
+import org.jboss.web.tomcat.service.session.FieldBasedJBossCacheService;
import org.jboss.web.tomcat.service.session.JBossCacheService;
/**
@@ -93,7 +94,7 @@
test = new Fqn(test, JBossCacheService.ATTRIBUTE);
assertFalse("Buddy ATTRIBUTE fqn correct", CacheListener.isFqnPojoKeySized(test, true));
- test = JBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+ test = FieldBasedJBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
assertTrue("Non-buddy pojo root correct", CacheListener.isFqnPojoKeySized(test, false));
assertFalse("Non-buddy pojo root correct with wrong isBuddy", CacheListener.isFqnPojoKeySized(test, true));
@@ -106,10 +107,10 @@
public void testGetPojoKeyFromFqn()
{
- Fqn test = JBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+ Fqn test = FieldBasedJBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
assertEquals("Non-buddy pojo field correct", "person", CacheListener.getPojoKeyFromFqn(test, false));
- test = JBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+ test = FieldBasedJBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
test = new Fqn(test, "subobject");
assertEquals("Non-buddy pojo field correct with subobject", "person", CacheListener.getPojoKeyFromFqn(test, false));
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-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -81,11 +81,11 @@
// Set system properties to properly bind JGroups channels
// First, preserve any existing values
- bind_address = System.getProperty("bind.address");
+ bind_address = System.getProperty("jgroups.bind_addr");
udp_group = System.getProperty("jboss.partition.udpGroup");
udp_port = System.getProperty("jboss.partition.udpPort");
- System.setProperty("bind.address", "127.0.0.1");
+ System.setProperty("jgroups.bind_addr", System.getProperty("jbosstest.cluster.node0", "127.0.0.1"));
String grp = System.getProperty("jbosstest.udpGroup");
if (grp != null && grp.length() > 0)
{
@@ -105,9 +105,9 @@
// Restore any system properties we set in setUp
if (bind_address == null)
- System.clearProperty("bind.address");
+ System.clearProperty("jgroups.bind_addr");
else
- System.setProperty("bind.address", bind_address);
+ System.setProperty("jgroups.bind_addr", bind_address);
if (udp_group == null)
System.clearProperty("jboss.partition.udpGroup");
else
@@ -925,15 +925,15 @@
}
private JBossWebMetaData createWebMetaData(int maxSessions, boolean passivation,
- int maxIdle, int minIdle)
+ int maxIdle, int minIdle)
{
JBossWebMetaData webMetaData = new JBossWebMetaData();
webMetaData.setDistributable(new EmptyMetaData());
- webMetaData.setMaxActiveSessions(maxSessions);
+ webMetaData.setMaxActiveSessions(new Integer(maxSessions));
PassivationConfig pcfg = new PassivationConfig();
- pcfg.setUseSessionPassivation(passivation);
- pcfg.setPassivationMaxIdleTime(maxIdle);
- pcfg.setPassivationMinIdleTime(minIdle);
+ pcfg.setUseSessionPassivation(Boolean.valueOf(passivation));
+ pcfg.setPassivationMaxIdleTime(new Integer(maxIdle));
+ pcfg.setPassivationMinIdleTime(new Integer(minIdle));
webMetaData.setPassivationConfig(pcfg);
ReplicationConfig repCfg = new ReplicationConfig();
repCfg.setReplicationGranularity(ReplicationGranularity.SESSION);
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-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -24,12 +24,11 @@
import junit.framework.Test;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.defaultcfg.web.test.SessionPassivationTestCase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* @author bstansberry
- *
*/
public class FieldBasedSessionPassivationTestCase extends SessionPassivationTestCase
{
@@ -46,13 +45,26 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(FieldBasedSessionPassivationTestCase.class,
- "jbosscache-helper.sar, http-field-pass.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(FieldBasedSessionPassivationTestCase.class,
+ "http-field-pass.war");
}
+ @Override
protected String getWarName()
{
return "http-field-pass";
}
+
+ @Override
+ protected String getCacheConfigName()
+ {
+ return "field-granularity-session-cache";
+ }
+
+ @Override
+ protected boolean isFieldBased()
+ {
+ return true;
+ }
+
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/ScopedFieldBasedTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/ScopedFieldBasedTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/ScopedFieldBasedTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -22,8 +22,9 @@
package org.jboss.test.cluster.defaultcfg.web.field.test;
import junit.framework.Test;
-import org.jboss.test.JBossClusteredTestCase;
+
import org.jboss.test.cluster.multicfg.web.field.test.FieldBasedTestCase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Clustering test case of get/set under scoped class loader.
@@ -51,9 +52,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(ScopedFieldBasedTestCase.class,
- "jbosscache-helper.sar, http-scoped-field.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(ScopedFieldBasedTestCase.class,
+ "http-scoped-field.war");
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/jk/test/JvmRouteURLRewritingTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/jk/test/JvmRouteURLRewritingTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/jk/test/JvmRouteURLRewritingTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.test.cluster.defaultcfg.web.jk.test;
import java.io.IOException;
@@ -8,9 +30,15 @@
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
+/**
+ * Tests that failover works properly, with an updated jvmRoute portion
+ * of the session id, when JK is used but session cookies are not.
+ *
+ * @author Brian Stansberry
+ */
public class JvmRouteURLRewritingTestCase extends WebTestBase
{
@@ -21,9 +49,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(JvmRouteURLRewritingTestCase.class,
- "http-jk.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(JvmRouteURLRewritingTestCase.class,
+ "http-jk.war");
}
public void testJkFailoverWithURLRewriting() throws Exception
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/AttributeBasedSessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/AttributeBasedSessionPassivationTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/AttributeBasedSessionPassivationTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -24,7 +24,7 @@
import junit.framework.Test;
-import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* @author bstansberry
@@ -50,9 +50,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(AttributeBasedSessionPassivationTestCase.class,
- "jbosscache-helper.sar, http-attr-pass.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(AttributeBasedSessionPassivationTestCase.class,
+ "http-attr-pass.war");
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/CrossContextCallsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/CrossContextCallsTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/CrossContextCallsTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -9,8 +9,8 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.multicfg.web.test.ScopedTestCase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
public class CrossContextCallsTestCase extends ScopedTestCase
{
@@ -25,9 +25,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(CrossContextCallsTestCase.class,
- "http-cross-ctx.ear");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(CrossContextCallsTestCase.class,
+ "http-cross-ctx.ear");
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ScopedSetAttributeTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ScopedSetAttributeTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ScopedSetAttributeTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -23,11 +23,9 @@
import junit.framework.Test;
import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.multicfg.web.test.ScopedTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Clustering test case of get/set under scoped class loader.
@@ -56,9 +54,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(ScopedSetAttributeTestCase.class,
- "http-scoped-set-attr.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(ScopedSetAttributeTestCase.class,
+ "http-scoped-set-attr.war");
}
@@ -70,7 +67,6 @@
public void testNonPrimitiveModify()
throws Exception
{
- String attr = "";
getLog().debug("Enter testNonPrimitiveModify");
getLog().debug(setUrl + ":::::::" + getUrl);
@@ -88,7 +84,7 @@
makeGet(client, baseURL0_ +modifyNoSetUrl);
// Get the Attribute set
- attr = makeGet(client, baseURL0_ +getUrl);
+ makeGet(client, baseURL0_ +getUrl);
sleepThread(DEFAULT_SLEEP);
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ScopedSetTriggerTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ScopedSetTriggerTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ScopedSetTriggerTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -25,9 +25,9 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.multicfg.web.test.ScopedTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Clustering test case of get/set under scoped class loader.
@@ -55,9 +55,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(ScopedSetTriggerTestCase.class,
- "http-scoped-set.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(ScopedSetTriggerTestCase.class,
+ "http-scoped-set.war");
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionEventTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionEventTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionEventTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -23,12 +23,8 @@
import junit.framework.Test;
import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.WebTestBase;
-import org.jboss.test.cluster.web.BindingListener;
-import org.jboss.test.cluster.web.SessionListener;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Test case for clustered session event.
@@ -48,9 +44,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(SessionEventTestCase.class,
- "http-sr.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(SessionEventTestCase.class,
+ "http-sr.war");
}
public void testSessionBindingEvent()
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-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -33,9 +33,9 @@
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Session passivation tests.
@@ -85,16 +85,15 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(SessionPassivationTestCase.class,
- "jbosscache-helper.sar, http-session-pass.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(SessionPassivationTestCase.class,
+ "http-session-pass.war");
}
protected void setUp() throws Exception
{
super.setUp();
- MBeanServerConnection[] adaptors = getAdaptors();
+ MBeanServerConnection[] adaptors = getAdaptors();
if (!deployed0)
{
deploy(adaptors[0]);
@@ -126,6 +125,11 @@
}
}
+ protected String getCacheConfigName()
+ {
+ return "standard-session-cache";
+ }
+
/**
* Tests the ability to passivate session when max idle for session is reached
*
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SimpleTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SimpleTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SimpleTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -26,10 +26,11 @@
import javax.management.MBeanServerConnection;
import junit.framework.Test;
+
import org.apache.commons.httpclient.HttpClient;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Simple clustering test case of get/set.
@@ -49,9 +50,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(SimpleTestCase.class,
- "jbosscache-helper.sar, http-sr.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(SimpleTestCase.class,
+ "http-sr.war");
}
/**
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -26,10 +26,9 @@
import junit.framework.Test;
import org.apache.commons.httpclient.HttpClient;
-
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.multicfg.web.test.ScopedTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Clustering test case of get/set under non-scoped class loader.
@@ -56,9 +55,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(FieldBasedTestCase.class,
+ return JBossClusteredWebTestCase.getDeploySetup(FieldBasedTestCase.class,
"jbosscache-helper.sar, http-field.war");
- return t1;
}
protected void concatenate()
@@ -71,7 +69,7 @@
{
return "http-field";
}
-
+
public void testSubjectObserver() throws Exception
{
getLog().debug("Enter testSubjectObserver");
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -31,9 +31,9 @@
import org.apache.commons.httpclient.HttpClient;
import org.jboss.cache.Fqn;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Tests the use of the TreeCache.activateRegion()/inactivateRegion().
@@ -84,22 +84,28 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(StateTransferTestCase.class,
- "jbosscache-helper.sar, http-scoped.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(StateTransferTestCase.class,
+ "http-scoped.war");
}
protected void setUp() throws Exception
{
super.setUp();
+ MBeanServerConnection[] adaptors = getAdaptors();
+ // Tell the CacheHelper that this isn't a PojoCache-based test
+ for (MBeanServerConnection adaptor : adaptors)
+ {
+ SessionTestUtil.setCacheConfigName(adaptor, getCacheConfigName(), false);
+ }
+
if (warObjectName == null)
{
String oname = "jboss.web:J2EEApplication=none,J2EEServer=none," +
"j2eeType=WebModule,name=//localhost/" + getWarName();
warObjectName = new ObjectName(oname);
- MBeanServerConnection[] adaptors = getAdaptors();
+
adaptor0_ = adaptors[0];
adaptor1_ = adaptors[1];
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/UndeployFieldTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/UndeployFieldTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/UndeployFieldTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -2,8 +2,8 @@
import junit.framework.Test;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.multicfg.web.test.UndeployTestCase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Tests that a clustered session still functions properly on the second
@@ -22,21 +22,28 @@
super(name);
}
+ @Override
protected String getContextPath()
{
return "/http-scoped-field/";
}
+ @Override
protected String getWarName()
{
return "http-scoped-field.war";
}
+ @Override
+ protected boolean isFieldBased()
+ {
+ return true;
+ }
+
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(UndeployFieldTestCase.class,
- "http-scoped-field.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(UndeployFieldTestCase.class,
+ "http-scoped-field.war");
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/AttributeBasedConcurrentTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/AttributeBasedConcurrentTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/AttributeBasedConcurrentTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -22,15 +22,9 @@
package org.jboss.test.cluster.multicfg.web.test;
import junit.framework.Test;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
-import java.util.Random;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
-import EDU.oswego.cs.dl.util.concurrent.Semaphore;
-
/**
* Simple clustering test case of get/set. It is attribute based granularity with concurrent access.
*
@@ -50,8 +44,7 @@
// Use different war file
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(AttributeBasedConcurrentTestCase.class,
- "http-scoped-attr.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(AttributeBasedConcurrentTestCase.class,
+ "http-scoped-attr.war");
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedAttrBasedTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedAttrBasedTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedAttrBasedTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -22,8 +22,9 @@
package org.jboss.test.cluster.multicfg.web.test;
import junit.framework.Test;
-import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
+
/**
* Clustering test case of get/set under scoped class loader.
* Replication granularity is attribute-based.
@@ -50,9 +51,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(ScopedAttrBasedTestCase.class,
- "http-scoped-attr.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(ScopedAttrBasedTestCase.class,
+ "http-scoped-attr.war");
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -34,9 +34,9 @@
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Clustering test case of get/set under scoped class loader.
@@ -126,9 +126,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(ScopedTestCase.class,
- "http-scoped.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(ScopedTestCase.class,
+ "http-scoped.war");
}
protected void setUp() throws Exception
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/SessionBasedConcurrentTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/SessionBasedConcurrentTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/SessionBasedConcurrentTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -21,16 +21,15 @@
*/
package org.jboss.test.cluster.multicfg.web.test;
+import java.util.Random;
+
import junit.framework.Test;
+
import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
-import java.util.Random;
-
import EDU.oswego.cs.dl.util.concurrent.Semaphore;
/**
@@ -62,9 +61,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(SessionBasedConcurrentTestCase.class,
- "http-sr.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(SessionBasedConcurrentTestCase.class,
+ "http-sr.war");
}
/**
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployAttrTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployAttrTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployAttrTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -2,7 +2,7 @@
import junit.framework.Test;
-import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Tests that a clustered session still functions properly on the second
@@ -33,9 +33,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(UndeployAttrTestCase.class,
- "http-scoped-attr.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(UndeployAttrTestCase.class,
+ "http-scoped-attr.war");
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -5,9 +5,9 @@
import junit.framework.Test;
import org.apache.commons.httpclient.HttpClient;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Tests that a clustered session still functions properly on the second
@@ -49,9 +49,8 @@
public static Test suite() throws Exception
{
- Test t1 = JBossClusteredTestCase.getDeploySetup(UndeployTestCase.class,
- "http-scoped.war");
- return t1;
+ return JBossClusteredWebTestCase.getDeploySetup(UndeployTestCase.class,
+ "http-scoped.war");
}
/**
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/WebSessionTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/WebSessionTestCase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/WebSessionTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -30,15 +30,15 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/** Tests of http session replication
*
* @author Scott.Stark at jboss.org
* @version $Revision$
*/
-public class WebSessionTestCase extends JBossClusteredTestCase
+public class WebSessionTestCase extends JBossClusteredWebTestCase
{
/**
* Standard number of ms to pause between http requests
@@ -53,8 +53,7 @@
public static Test suite() throws Exception
{
- Test t1 = getDeploySetup(WebSessionTestCase.class, "dist-ss.war");
- return t1;
+ return getDeploySetup(WebSessionTestCase.class, "dist-ss.war");
}
/** This makes 2 requests to the jbosstest.cluster.node0 /dist-ss/StatefulSessionServlet
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -149,6 +149,14 @@
TYPES);
}
+ public static void setCacheConfigName(MBeanServerConnection adaptor, String cacheConfigName, boolean usePojoCache) throws Exception
+ {
+ adaptor.invoke(CacheHelper.OBJECT_NAME,
+ "setCacheConfigName",
+ new Object[] { cacheConfigName, Boolean.valueOf(usePojoCache) },
+ new String[]{ String.class.getName(), boolean.class.getName() });
+ }
+
public static boolean exists(MBeanServerConnection adaptor, String fqn) throws Exception
{
Boolean b = (Boolean) adaptor.invoke(CacheHelper.OBJECT_NAME,
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/WebTestBase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/WebTestBase.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/WebTestBase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -29,7 +29,7 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.web.JBossClusteredWebTestCase;
/**
* Base class to test HttpSessionReplication.
@@ -38,7 +38,7 @@
* @version $Revision: 1.0
*/
public abstract class WebTestBase
- extends JBossClusteredTestCase
+ extends JBossClusteredWebTestCase
{
/**
* Standard number of ms to pause between http requests
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -29,61 +29,79 @@
import javax.management.ObjectName;
import org.jboss.cache.Cache;
+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.pojo.PojoCache;
-import org.jboss.cache.pojo.jmx.PojoCacheJmxWrapperMBean;
-import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.ha.cachemanager.CacheManagerLocator;
+import org.jboss.ha.cachemanager.PojoCacheManager;
import org.jboss.mx.util.ObjectNameFactory;
import org.jboss.system.ServiceMBeanSupport;
/**
- * Helper class to locate and invoke methods on the cache mbean used by Tomcat.
+ * Helper class to locate and invoke methods on the cache mbeans used by JBossWeb.
*
- * @author Ben Wang
- * Date: Aug 16, 2005
+ * @author Ben Wang Date: Aug 16, 2005
+ * @author Brian Stansberry
+ *
* @version $Id$
*/
public class CacheHelper
extends ServiceMBeanSupport
implements CacheHelperMBean
{
+ public static final String CACHE_CONFIG_PROP = "jbosstest.cluster.web.cache.config";
+ public static final String CACHE_TYPE_PROP = "jbosstest.cluster.web.cache.pojo";
+
public static final ObjectName OBJECT_NAME =
ObjectNameFactory.create("jboss.test:service=WebTestCacheHelper");
- private static final String DEFAULT_CACHE_NAME =
- "jboss.cache:service=TomcatClusteringCache";
private static final String VERSION_KEY = "VERSION";
- private PojoCache pojoCache;
+ private String cacheConfigName;
+ private Cache cache;
+ private boolean usePojoCache;
private boolean leaveInstalledAfterShutdown;
public CacheHelper()
{
}
- public static PojoCache getCacheInstance()
+ public static Cache getCacheInstance(String cacheConfig, boolean usePojoCache)
{
try
{
- ObjectName cacheServiceName_ = new ObjectName(DEFAULT_CACHE_NAME);
- // Create Proxy-Object for this service
- PojoCacheJmxWrapperMBean mbean = (PojoCacheJmxWrapperMBean) MBeanProxyExt.create(PojoCacheJmxWrapperMBean.class,
- cacheServiceName_);
- if (mbean == null)
+ if (usePojoCache)
{
- throw new RuntimeException("getCacheInstance: locate null " + cacheServiceName_);
+ PojoCacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ return cm.getPojoCache(cacheConfig, true).getCache();
}
- return mbean.getPojoCache();
+ else
+ {
+ CacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ return cm.getCache(cacheConfig, true);
+ }
}
- catch (Throwable e)
+ catch (RuntimeException re)
{
- e.printStackTrace();
+ throw re;
+ }
+ catch (Exception e)
+ {
throw new RuntimeException("getCacheInstance: Exception: " +e);
}
}
+ public void setCacheConfigName(String cacheConfigName, boolean usePojoCache)
+ {
+ if (this.cacheConfigName == null || !this.cacheConfigName.equals(cacheConfigName))
+ releaseCache();
+ this.cacheConfigName = cacheConfigName;
+ this.usePojoCache = usePojoCache;
+ getCache();
+ }
+
public Object getSessionVersion(String sessionFqn)
{
return getCache().get(Fqn.fromString(sessionFqn), VERSION_KEY);
@@ -126,7 +144,7 @@
result.addAll(main.getChildrenNames());
}
-// Check in the buddy backup tree
+ // Check in the buddy backup tree
Set buddies = getBuddyBackupRoots();
for (Iterator iter = buddies.iterator(); iter.hasNext();)
@@ -202,12 +220,49 @@
this.leaveInstalledAfterShutdown = true;
}
+ public void startService() throws Exception
+ {
+ super.startService();
+ cacheConfigName = System.getProperty(CACHE_CONFIG_PROP);
+ String pojo = System.getProperty(CACHE_TYPE_PROP, "false");
+ usePojoCache = Boolean.parseBoolean(pojo);
+
+ getLog().debug("cacheConfigName=" + cacheConfigName +
+ " and usePojoCache=" + usePojoCache);
+ }
+
+ public void stopService() throws Exception
+ {
+ super.stopService();
+ releaseCache();
+ }
+
+ private void releaseCache()
+ {
+ if (cache != null && cacheConfigName != null)
+ {
+ if (usePojoCache)
+ {
+ PojoCacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ cm.releaseCache(cacheConfigName);
+ }
+ else
+ {
+ CacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ cm.releaseCache(cacheConfigName);
+ }
+
+ cache = null;
+ }
+ }
+
public void uninstall()
{
Thread t = new Thread() {
public void run() {
try
{
+ releaseCache();
server.unregisterMBean(OBJECT_NAME);
}
catch (Exception e) {}
@@ -216,6 +271,7 @@
t.start();
}
+
private Set getBuddyBackupRoots()
{
@@ -232,15 +288,17 @@
return buddies;
}
- private PojoCache getPojoCache()
- {
- if (pojoCache == null)
- pojoCache = getCacheInstance();
- return pojoCache;
- }
-
private Cache getCache()
{
- return getPojoCache().getCache();
+ if (cache == null)
+ {
+
+ getLog().debug("Getting cache: cacheConfigName=" + cacheConfigName +
+ " and usePojoCache=" + usePojoCache);
+ cache = getCacheInstance(cacheConfigName, usePojoCache);
+ if (cache.getCacheStatus() != CacheStatus.STARTED)
+ cache.start();
+ }
+ return cache;
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -2,10 +2,10 @@
import java.util.Set;
-import org.jboss.cache.Fqn;
-
public interface CacheHelperMBean
{
+ void setCacheConfigName(String cacheConfigName, boolean usePojoCache);
+
Object getSessionVersion(String sessionFqn);
Object getBuddySessionVersion(String sessionFqn) throws Exception;
Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossClusteredWebTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossClusteredWebTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/JBossClusteredWebTestCase.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -0,0 +1,222 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web;
+
+import java.util.StringTokenizer;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.AbstractTestSetup;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossTestClusteredServices;
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class JBossClusteredWebTestCase extends JBossClusteredTestCase
+{
+
+ public static AbstractTestDelegate getDelegate(Class clazz)
+ throws Exception
+ {
+ return new JBossTestClusteredServices(clazz);
+ }
+
+ public JBossClusteredWebTestCase(String name)
+ {
+ super(name);
+ }
+
+ public String getCacheConfigName()
+ {
+ return System.getProperty(CacheHelper.CACHE_CONFIG_PROP);
+ }
+
+ public static Test getDeploySetup(Test test, String jarNames)
+ throws Exception
+ {
+ return new JBossClusteredWebTestSetup(test, jarNames);
+ }
+
+ public static Test getDeploySetup(Class clazz, String jarNames)
+ throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTest(new TestSuite(clazz));
+ return getDeploySetup(suite, jarNames);
+ }
+
+ private static String getJarNamesWithHelper(String jarNames)
+ {
+ if (jarNames == null || jarNames.length() == 0)
+ return "jbosscache-helper.sar";
+ else
+ return "jbosscache-helper.sar, " + jarNames;
+ }
+
+ public static class JBossClusteredWebTestSetup extends JBossTestSetup
+ {
+ public static final String SYSTEM_PROPS_SVC = "jboss:type=Service,name=SystemProperties";
+
+ private String cacheConfigName;
+ private String usePojoCache;
+ private String jarNames = null;
+ private JBossTestClusteredServices clusteredServices;
+
+ /**
+ * Create a new JBossTestClusteredWebSetup.
+ *
+ * @param test
+ * @param jarNames
+ * @throws Exception
+ */
+ public JBossClusteredWebTestSetup(Test test, String jarNames) throws Exception
+ {
+ super(JBossClusteredWebTestCase.class, test);
+ this.jarNames = getJarNamesWithHelper(jarNames);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ getLog().debug("delegate is " + delegate);
+
+ clusteredServices = (JBossTestClusteredServices) delegate;
+
+ cacheConfigName = System.getProperty(CacheHelper.CACHE_CONFIG_PROP);
+ usePojoCache = System.getProperty(CacheHelper.CACHE_TYPE_PROP, "false");
+ if (cacheConfigName != null || Boolean.parseBoolean(usePojoCache))
+ {
+ setServerSideCacheConfigProperties();
+ }
+
+ deployJars();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ undeployJars();
+
+ super.tearDown();
+ if (cacheConfigName != null)
+ {
+ clearServerSideCacheConfigProperties();
+ }
+ }
+ finally
+ {
+ AbstractTestSetup.delegate = null;
+ }
+ }
+
+ private void setServerSideCacheConfigProperties() throws Exception
+ {
+ getLog().debug("configuring server with cacheConfigName=" + cacheConfigName + " and usePojoCache=" + usePojoCache);
+
+ ObjectName on = new ObjectName(SYSTEM_PROPS_SVC);
+ for (MBeanServerConnection adaptor : clusteredServices.getAdaptors())
+ {
+ adaptor.invoke(on, "set",
+ new Object[]{CacheHelper.CACHE_CONFIG_PROP, cacheConfigName},
+ new String[] {String.class.getName(), String.class.getName()});
+
+ adaptor.invoke(on, "set",
+ new Object[]{CacheHelper.CACHE_TYPE_PROP, usePojoCache},
+ new String[] {String.class.getName(), String.class.getName()});
+ }
+ }
+
+ private void clearServerSideCacheConfigProperties() throws Exception
+ {
+ ObjectName on = new ObjectName(SYSTEM_PROPS_SVC);
+ for (MBeanServerConnection adaptor : clusteredServices.getAdaptors())
+ {
+ adaptor.invoke(on, "remove",
+ new Object[]{CacheHelper.CACHE_CONFIG_PROP},
+ new String[] {String.class.getName()});
+
+ adaptor.invoke(on, "remove",
+ new Object[] {CacheHelper.CACHE_TYPE_PROP},
+ new String[] {String.class.getName()});
+ }
+ }
+
+ private void deployJars() throws Exception
+ {
+ JBossTestCase.deploymentException = null;
+ try
+ {
+ // deploy the comma seperated list of jars
+ StringTokenizer st = new StringTokenizer(jarNames, ", ");
+ while (st.hasMoreTokens())
+ {
+ String jarName = st.nextToken();
+ this.redeploy(jarName);
+ this.getLog().debug("deployed package: " + jarName);
+ }
+ }
+ catch (Exception ex)
+ {
+ // Throw this in testServerFound() instead.
+ JBossTestCase.deploymentException = ex;
+ }
+
+ // wait a couple seconds to let the cluster stabilize
+ synchronized (this)
+ {
+ wait(2000);
+ }
+ }
+
+ private void undeployJars() throws Exception
+ {
+ // deploy the comma seperated list of jars
+ StringTokenizer st = new StringTokenizer(jarNames, ", ");
+ String[] depoyments = new String[st.countTokens()];
+ for (int i = depoyments.length - 1; i >= 0; i--)
+ depoyments[i] = st.nextToken();
+ for (int i = 0; i < depoyments.length; i++)
+ {
+ String jarName = depoyments[i];
+ this.getLog().debug("Attempt undeploy of " + jarName);
+ this.undeploy(jarName);
+ this.getLog().debug("undeployed package: " + jarName);
+ }
+ }
+
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/TestConfigurationAdder.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/TestConfigurationAdder.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/TestConfigurationAdder.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.ConfigurationRegistry;
+
+/**
+ * Utility that analyzes the set of available cache configurations in
+ * a ConfigurationRegistry and adds alternatives with different CacheMode
+ * and buddy replication settings
+ *
+ * @author Brian Stansberry
+ */
+public class TestConfigurationAdder
+{
+ public static final String DEFAULT_STD_SESSION_CFG = "standard-session-cache";
+ public static final String DEFAULT_FIELD_SESSION_CFG = "field-granularity-session-cache";
+
+ private ConfigurationRegistry configurationRegistry;
+ private String standardSessionConfig = DEFAULT_STD_SESSION_CFG;
+ private String fieldSessionConfig = DEFAULT_FIELD_SESSION_CFG;
+ private boolean addAlternateCacheMode;
+ private boolean addAlternateBuddyReplication;
+
+ public void start() throws Exception
+ {
+ createAlternates(standardSessionConfig, configurationRegistry.getConfiguration(standardSessionConfig));
+ createAlternates(fieldSessionConfig, configurationRegistry.getConfiguration(fieldSessionConfig));
+ }
+
+ private void createAlternates(String stdName, Configuration std) throws Exception
+ {
+ CacheMode altCacheMode = (std.getCacheMode() == CacheMode.REPL_ASYNC) ? CacheMode.REPL_SYNC : CacheMode.REPL_ASYNC;
+ String altCacheModeTag = (altCacheMode == CacheMode.REPL_ASYNC ? "async" : "sync");
+ boolean brEnabled = !std.getBuddyReplicationConfig().isEnabled();
+ String altBrTag = (brEnabled ? "br-enabled" : "br-disabled");
+
+ String altModeName = altCacheModeTag + "-" + stdName;
+ if (configurationRegistry.getConfigurationNames().contains(altModeName) == false)
+ {
+ Configuration altMode = std.clone();
+ altMode.setCacheMode(altCacheMode);
+ altMode.setClusterName(altModeName);
+ configurationRegistry.registerConfiguration(altModeName, altMode);
+ }
+
+ String altBrName = altBrTag + "-" + stdName;
+ if (configurationRegistry.getConfigurationNames().contains(altBrName) == false)
+ {
+ Configuration altBr = std.clone();
+ altBr.getBuddyReplicationConfig().setEnabled(brEnabled);
+ altBr.setClusterName(altBrName);
+ configurationRegistry.registerConfiguration(altBrName, altBr);
+ }
+
+ String altCombinedName = altBrTag + "-" + altCacheModeTag + "-" + stdName;
+ if (configurationRegistry.getConfigurationNames().contains(altCombinedName) == false)
+ {
+ Configuration altCombined = std.clone();
+ altCombined.setCacheMode(altCacheMode);
+ altCombined.getBuddyReplicationConfig().setEnabled(brEnabled);
+ altCombined.setClusterName(altCombinedName);
+ configurationRegistry.registerConfiguration(altCombinedName, altCombined);
+ }
+ }
+
+
+ public ConfigurationRegistry getConfigurationRegistry()
+ {
+ return configurationRegistry;
+ }
+ public void setConfigurationRegistry(ConfigurationRegistry configurationRegistry)
+ {
+ this.configurationRegistry = configurationRegistry;
+ }
+ public String getStandardSessionConfig()
+ {
+ return standardSessionConfig;
+ }
+ public void setStandardSessionConfig(String standardSessionConfig)
+ {
+ this.standardSessionConfig = standardSessionConfig;
+ }
+ public String getFieldSessionConfig()
+ {
+ return fieldSessionConfig;
+ }
+ public void setFieldSessionConfig(String fieldSessionConfig)
+ {
+ this.fieldSessionConfig = fieldSessionConfig;
+ }
+ public boolean isAddAlternateCacheMode()
+ {
+ return addAlternateCacheMode;
+ }
+ public void setAddAlternateCacheMode(boolean addAlternateCacheMode)
+ {
+ this.addAlternateCacheMode = addAlternateCacheMode;
+ }
+ public boolean isAddAlternateBuddyReplication()
+ {
+ return addAlternateBuddyReplication;
+ }
+ public void setAddAlternateBuddyReplication(boolean addAlternateBuddyReplication)
+ {
+ this.addAlternateBuddyReplication = addAlternateBuddyReplication;
+ }
+
+
+
+}
Modified: trunk/testsuite/src/resources/cluster/http/http-cross-ctx-first/WEB-INF/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-cross-ctx-first/WEB-INF/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-cross-ctx-first/WEB-INF/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -10,7 +10,8 @@
<!-- To avoid a custom config, use the jmx-console security domain -->
<security-domain>java:/jaas/jmx-console</security-domain>
- <replication-config>
+ <replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-cross-ctx-second/WEB-INF/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-cross-ctx-second/WEB-INF/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-cross-ctx-second/WEB-INF/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -10,7 +10,8 @@
<!-- To avoid a custom config, use the jmx-console security domain -->
<security-domain>java:/jaas/jmx-console</security-domain>
- <replication-config>
+ <replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-cross-ctx-third/WEB-INF/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-cross-ctx-third/WEB-INF/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-cross-ctx-third/WEB-INF/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -10,7 +10,8 @@
<!-- To avoid a custom config, use the jmx-console security domain -->
<security-domain>java:/jaas/jmx-console</security-domain>
- <replication-config>
+ <replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-field/WEB-INF/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-field/WEB-INF/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-field/WEB-INF/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -11,6 +11,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:field-granularity-session-cache}</cache-name>
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field-batch-false.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field-batch-false.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field-batch-false.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -11,6 +11,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:field-granularity-session-cache}</cache-name>
<replication-granularity>FIELD</replication-granularity>
<replication-field-batch-mode>FALSE</replication-field-batch-mode>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field-scoped.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field-scoped.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field-scoped.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -11,6 +11,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:field-granularity-session-cache}</cache-name>
<replication-granularity>FIELD</replication-granularity>
<replication-field-batch-mode>TRUE</replication-field-batch-mode>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-field/jboss-web-field.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -13,6 +13,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:field-granularity-session-cache}</cache-name>
<replication-granularity>FIELD</replication-granularity>
<replication-field-batch-mode>TRUE</replication-field-batch-mode>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-jk/WEB-INF/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -13,6 +13,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
-->
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-scoped/WEB-INF/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-scoped/WEB-INF/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-scoped/WEB-INF/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -11,6 +11,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-attr-based.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-attr-based.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-attr-based.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -11,6 +11,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_NON_PRIMITIVE_GET</replication-trigger>
<replication-granularity>ATTRIBUTE</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-attr-set.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-attr-set.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-attr-set.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -11,6 +11,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET</replication-trigger>
<replication-granularity>ATTRIBUTE</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-set-trigger.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-set-trigger.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web-set-trigger.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -11,6 +11,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/http-scoped/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -11,6 +11,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_NON_PRIMITIVE_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/passivation/ATTRIBUTE/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/passivation/ATTRIBUTE/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/passivation/ATTRIBUTE/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -6,6 +6,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_NON_PRIMITIVE_GET</replication-trigger>
<replication-granularity>ATTRIBUTE</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/passivation/FIELD/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/passivation/FIELD/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/passivation/FIELD/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -8,6 +8,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:field-granularity-session-cache}</cache-name>
<replication-granularity>FIELD</replication-granularity>
<replication-field-batch-mode>TRUE</replication-field-batch-mode>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/passivation/SESSION/jboss-web.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/http/passivation/SESSION/jboss-web.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/passivation/SESSION/jboss-web.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -7,6 +7,7 @@
<security-domain>java:/jaas/jmx-console</security-domain>
<replication-config>
+ <cache-name>${jbosstest.cluster.web.cache.config:standard-session-cache}</cache-name>
<replication-trigger>SET_AND_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
</replication-config>
Modified: trunk/testsuite/src/resources/cluster/http/version.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/version.jsp 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/http/version.jsp 2008-04-21 01:04:46 UTC (rev 72468)
@@ -1,14 +1,12 @@
<%@page contentType="text/html"
import="org.jboss.mx.util.*"
import="javax.management.*"
- import="org.jboss.cache.*"
- import="org.jboss.cache.pojo.PojoCache"
+ import="org.jboss.test.cluster.web.CacheHelper"
%>
<%
MBeanServer server = MBeanServerLocator.locateJBoss();
- ObjectName on = new ObjectName("jboss.cache:service=TomcatClusteringCache");
- PojoCache cache = (PojoCache) server.getAttribute(on, "PojoCache");
- Fqn fqn = Fqn.fromString("/JSESSION/localhost" + request.getContextPath() + "/" + session.getId());
- Object version = cache.getCache().get(fqn, "VERSION" );
+ Object version = server.invoke(CacheHelper.OBJECT_NAME, "getSessionVersion",
+ new Object[]{session.getId()},
+ new String[] {"java.lang.String"});
%>
<%= version %>
Added: trunk/testsuite/src/resources/cluster/web/cachehelper/jboss-beans.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/web/cachehelper/jboss-beans.xml (rev 0)
+++ trunk/testsuite/src/resources/cluster/web/cachehelper/jboss-beans.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Additional cache configs used by test deployments -->
+ <bean name="ClusterTestCacheConfigs"
+ class="org.jboss.test.cluster.web.TestConfigurationAdder">
+
+ <property name="configurationRegistry"><inject bean="CacheConfigurationRegistry"/></property>
+
+ </bean>
+
+ <bean name="ClusterTestCacheHelper" class="org.jboss.test.cluster.web.CacheHelper">
+
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.test:service=WebTestCacheHelper", exposedInterface=org.jboss.test.cluster.web.CacheHelperMBean.class, registerDirectly=true)</annotation>
+
+ </bean>
+
+</deployment>
Deleted: trunk/testsuite/src/resources/cluster/web/cachehelper/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/web/cachehelper/jboss-service.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/testsuite/src/resources/cluster/web/cachehelper/jboss-service.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<server>
-
- <mbean code="org.jboss.test.cluster.web.CacheHelper"
- name="jboss.test:service=WebTestCacheHelper"/>
-
-</server>
Modified: trunk/tomcat/build.xml
===================================================================
--- trunk/tomcat/build.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/build.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -328,8 +328,6 @@
<mkdir dir="${build.deploy}/cluster"/>
<copy todir="${build.deploy}/cluster"
file="${build.lib}/jbossweb-cluster.aop"/>
- <copy tofile="${build.deploy}/cluster/jbossweb-cluster-beans.xml"
- file="${build.resources}/jbossweb-cluster-beans.xml"/>
<!-- Update the build marker to allow bypassing -->
<touch file="${build-bypass.marker}"/>
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -46,8 +46,8 @@
{
public static final int IGNORED = -1;
- private String cacheSource;
private String cacheName;
+ private String fieldGranularityCacheName;
private SnapshotMode snapshotMode;
private int snapshotInterval;
private ReplicationGranularity replicationGranularity;
@@ -89,6 +89,16 @@
this.cacheName = cacheName;
}
+ public String getFieldGranularityCacheName()
+ {
+ return fieldGranularityCacheName;
+ }
+
+ public void setFieldGranularityCacheName(String fieldGranularityCacheName)
+ {
+ this.fieldGranularityCacheName = fieldGranularityCacheName;
+ }
+
public SnapshotMode getSnapshotMode()
{
return snapshotMode;
@@ -185,16 +195,6 @@
this.passivationMaxIdleTime = passivationMaxIdleTime;
}
- public String getCacheSource()
- {
- return cacheSource;
- }
-
- public void setCacheSource(String cacheSource)
- {
- this.cacheSource = cacheSource;
- }
-
/**
* Injects the configured default property values into any
* {@link JBossWebMetaData} attached to <code>unit</code> if the
@@ -249,8 +249,7 @@
repCfg = new ReplicationConfig();
metaData.setReplicationConfig(repCfg);
}
- if (repCfg.getCacheName() == null)
- repCfg.setCacheName(this.cacheName);
+
if (repCfg.getUseJK() == null && useJK != null)
repCfg.setUseJK(this.useJK);
if (repCfg.getSnapshotMode() == null)
@@ -263,6 +262,13 @@
repCfg.setReplicationTrigger(this.replicationTrigger);
if (repCfg.getReplicationFieldBatchMode() == null)
repCfg.setReplicationFieldBatchMode(Boolean.valueOf(this.replicationFieldBatchMode));
+
+ if (repCfg.getCacheName() == null)
+ {
+ String cacheConfig = ReplicationGranularity.FIELD == repCfg.getReplicationGranularity()
+ ? fieldGranularityCacheName : cacheName;
+ repCfg.setCacheName(cacheConfig);
+ }
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -30,13 +30,10 @@
import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.metadata.web.jboss.ReplicationConfig;
/**
* Adds a dependency on a clustered cache.
*
- * TODO consider doing this internally in WebMetaData.
- *
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
@@ -49,7 +46,7 @@
*
*/
public ClusteringDependencyDeployer()
- {
+ {
setStage(DeploymentStages.DESCRIBE);
setInput(JBossWebMetaData.class);
setOutput(JBossWebMetaData.class);
@@ -60,22 +57,22 @@
JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
if( metaData != null && metaData.getDistributable() != null )
{
- ReplicationConfig rpcfg = metaData.getReplicationConfig();
- String cacheName = rpcfg == null ? null: rpcfg.getCacheName();
- if (cacheName == null)
+ if (clusterCacheDependency != null)
{
- cacheName = clusterCacheDependency;
+ log.debug("Adding dependency on " + clusterCacheDependency + " to " + unit.getName());
+ List<String> depends = metaData.getDepends();
+ if (depends == null)
+ depends = new ArrayList<String>();
+ if (!depends.contains(clusterCacheDependency))
+ {
+ depends.add(clusterCacheDependency);
+ }
+ metaData.setDepends(depends);
}
-
- log.debug("Adding dependency on " + cacheName + " to " + unit.getName());
- List<String> depends = metaData.getDepends();
- if (depends == null)
- depends = new ArrayList<String>();
- if (!depends.contains(cacheName))
+ else
{
- depends.add(cacheName);
+ log.warn("clusterCacheDependency is null; either configure it or remove this deployer");
}
- metaData.setDepends(depends);
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedClusteredSession.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedClusteredSession.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedClusteredSession.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -80,7 +80,8 @@
protected static final String info = "FieldBasedClusteredSession/1.0";
protected transient Map attributes_ = Collections.synchronizedMap(new HashMap());
-
+ protected transient FieldBasedJBossCacheService fieldProxy_;
+
public FieldBasedClusteredSession(JBossCacheManager manager)
{
super(manager);
@@ -143,12 +144,32 @@
// removePojosLocal call here in order to evict the ATTRIBUTE node.
// Otherwise empty nodes for the session root and child ATTRIBUTE will
// remain in the tree and screw up our list of session names.
- proxy_.removePojosLocal(realId);
- proxy_.removeSessionLocal(realId);
+ fieldProxy_.removePojosLocal(realId);
+ fieldProxy_.removeSessionLocal(realId);
}
// ------------------------------------------------ JBoss internal abstract method
+
+
+ @Override
+ protected void establishProxy()
+ {
+ if (fieldProxy_ == null)
+ {
+ fieldProxy_ = ((JBossCacheManager) manager).getPojoCacheService();
+
+ // still null???
+ if (fieldProxy_ == null)
+ {
+ throw new IllegalStateException("Cache service is null");
+ }
+
+ // Set the superclass ref as well
+ this.proxy_ = fieldProxy_;
+ }
+ }
+
/**
* Populate the attributes stored in the distributed store to the local
* transient map. Add ourself as an Observer to newly found attributes and
@@ -160,7 +181,7 @@
// Preserve any local attributes that were excluded from replication
Map excluded = removeExcludedAttributes(attributes_);
- Set keys = proxy_.getPojoKeys(realId);
+ Set keys = fieldProxy_.getPojoKeys(realId);
Set oldKeys = new HashSet(attributes_.keySet());
// Since we are going to touch each attribute, might as well
@@ -176,7 +197,7 @@
String name = (String) it.next();
Object oldAttrib = null;
- Object newAttrib = proxy_.getPojo(realId, name);
+ Object newAttrib = fieldProxy_.getPojo(realId, name);
if (newAttrib != null)
{
oldAttrib = attributes_.put(name, newAttrib);
@@ -185,10 +206,10 @@
{
// Need to observe this pojo as well
// for any modification events.
- proxy_.addObserver(this, newAttrib);
+ fieldProxy_.addObserver(this, newAttrib);
// Stop observing the old pojo
- proxy_.removeObserver(this, oldAttrib); // null pojo OK :)
+ fieldProxy_.removeObserver(this, oldAttrib); // null pojo OK :)
}
// Check if we have a listener
@@ -201,7 +222,7 @@
oldAttrib = attributes_.remove(name);
// Stop observing this pojo
- proxy_.removeObserver(this, oldAttrib); // null pojo OK :)
+ fieldProxy_.removeObserver(this, oldAttrib); // null pojo OK :)
}
}
@@ -214,7 +235,7 @@
for (Iterator it = oldKeys.iterator(); it.hasNext(); )
{
Object oldAttrib = attributes_.remove(it.next());
- proxy_.removeObserver(this, oldAttrib);
+ fieldProxy_.removeObserver(this, oldAttrib);
}
// Restore any excluded attributes
@@ -259,9 +280,9 @@
if (localCall && !replicationExcludes.contains(name))
{
if (localOnly)
- proxy_.removePojoLocal(realId, name);
+ fieldProxy_.removePojoLocal(realId, name);
else
- proxy_.removePojo(realId, name);
+ fieldProxy_.removePojo(realId, name);
sessionAttributesDirty();
}
@@ -271,7 +292,7 @@
log.warn("removeJBossInternalAttribute(): null value to remove with key: "+ name);
return null;
}
- proxy_.removeObserver(this, result);
+ fieldProxy_.removeObserver(this, result);
return result;
}
@@ -316,10 +337,10 @@
Object oldVal = null;
if (!replicationExcludes.contains(key))
{
- oldVal = proxy_.setPojo(realId, key, value);
+ oldVal = fieldProxy_.setPojo(realId, key, value);
if(oldVal != null)
{ // We are done with the old one.
- proxy_.removeObserver(this, oldVal);
+ fieldProxy_.removeObserver(this, oldVal);
}
if(value != null)
@@ -328,11 +349,11 @@
if( value instanceof Map || value instanceof Collection)
{
// We need to obtain the proxy first.
- value = proxy_.getPojo(realId, key);
+ value = fieldProxy_.getPojo(realId, key);
}
// Need to use obj since it can return as a proxy.
- proxy_.addObserver(this, value);
+ fieldProxy_.addObserver(this, value);
}
// Only mark session dirty if we can replicate the attribute
Added: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java (rev 0)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -0,0 +1,587 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.WeakHashMap;
+
+import org.jboss.aspects.patterns.observable.Observer;
+import org.jboss.aspects.patterns.observable.Subject;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Region;
+import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.eviction.EvictionException;
+import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
+import org.jboss.cache.pojo.PojoCacheThreadContext;
+import org.jboss.metadata.web.jboss.ReplicationGranularity;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class FieldBasedJBossCacheService extends JBossCacheService
+{
+ private final PojoCache pojoCache_;
+ private Region evictionRegion_;
+ private JBossWebManagedLRUAlgorithm evictionAlgorithm_;
+ private WeakHashMap typeMap = new WeakHashMap();
+
+ /**
+ * Create a new FieldBasedJBossCacheService.
+ *
+ * @param cache
+ */
+ public FieldBasedJBossCacheService(PojoCache cache)
+ {
+ super(cache.getCache());
+ this.pojoCache_ = cache;
+ setCache(pojoCache_.getCache());
+ }
+
+ private Fqn getFieldFqn(String id, String key)
+ {
+ return getFieldFqn(hostName_, webAppPath_, id, key);
+ }
+
+
+ private static void breakKeys(String key, List list)
+ {
+ StringTokenizer token = new StringTokenizer(key, FQN_DELIMITER);
+ while(token.hasMoreTokens())
+ {
+ list.add(token.nextToken());
+ }
+ }
+ public static Fqn getFieldFqn(String hostName, String contextPath, String sessionId, String attributeKey)
+ {
+ List list = new ArrayList(6);
+ list.add(SESSION);
+ list.add(hostName);
+ list.add(contextPath);
+ list.add(sessionId);
+ list.add(ATTRIBUTE);
+ // Guard against string with delimiter.
+ breakKeys(attributeKey, list);
+ return new Fqn(list);
+ }
+
+ @Override
+ public void start(ClassLoader tcl, JBossCacheManager manager)
+ {
+ super.start(tcl, manager);
+
+ if(manager.isPassivationEnabled())
+ {
+ initializeFieldGranularityEviction(tcl);
+ }
+ }
+
+
+
+ @Override
+ public void stop()
+ {
+ super.stop();
+
+ if (evictionRegion_ != null)
+ {
+ getCache().removeRegion(evictionRegion_.getFqn());
+ evictionRegion_ = null;
+ }
+ }
+
+ @Override
+ public void processEviction()
+ {
+ if (evictionAlgorithm_ != null)
+ {
+ try
+ {
+ evictionAlgorithm_.backgroundProcess(evictionRegion_);
+ }
+ catch (EvictionException e)
+ {
+ log_.error("Problem handling eviction for region " + evictionRegion_, e);
+ }
+ }
+ }
+
+ /**
+ * store the pojo instance in the cache. Note that this is for the aop cache.
+ * THe pojo needs to be "aspectized".
+ *
+ * @param realId the session id with any jvmRoute removed
+ * @param key the attribute key
+ * @param pojo
+ */
+ public Object setPojo(String realId, String key, Object pojo)
+ {
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("setPojo(): session id: " + realId + " key: " + key +
+ " object: " + pojo.toString());
+ }
+ // Construct the fqn.
+ Fqn fqn = getFieldFqn(realId, key);
+ try {
+ // Ignore any cache notifications that our own work generates
+ SessionReplicationContext.startCacheActivity();
+ return pojoCache_.attach(fqn.toString(), pojo);
+ } catch (CacheException e) {
+ throw new RuntimeException("JBossCacheService: exception occurred in cache setPojo ... ", e);
+ }
+ finally {
+ SessionReplicationContext.finishCacheActivity();
+ }
+ }
+
+ /**
+ * Remove pojo from the underlying cache store.
+ * @param realId the session id with any jvmRoute removed
+ * @param key the attribute key
+ * @return pojo that just removed. Null if there none.
+ */
+ public Object removePojo(String realId, String key)
+ {
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("removePojo(): session id: " +realId + " key: " +key);
+ }
+ // Construct the fqn.
+ Fqn fqn = getFieldFqn(realId, key);
+ try {
+ // Ignore any cache notifications that our own work generates
+ SessionReplicationContext.startCacheActivity();
+ return pojoCache_.detach(fqn.toString());
+ } catch (CacheException e) {
+ throw new RuntimeException("JBossCacheService: exception occurred in cache removePojo ... ", e);
+ }
+ finally {
+ SessionReplicationContext.finishCacheActivity();
+ }
+ }
+
+ /**
+ * Remove all the pojos from the underlying cache store locally
+ * without replication.
+ *
+ * @param realId the session id with any jvmRoute removed
+ */
+ public void removePojosLocal(String realId)
+ {
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("removePojoLocal(): session id: " +realId);
+ }
+ // Construct the fqn.
+ Fqn fqn = getAttributeFqn(realId);
+ try {
+ // Ignore any cache notifications that our own work generates
+ SessionReplicationContext.startCacheActivity();
+ cacheWrapper_.removeLocalSubtree(fqn);
+ }
+ finally {
+ SessionReplicationContext.finishCacheActivity();
+ }
+ }
+
+ /**
+ * Remove all the pojos from the underlying cache store locally
+ * without replication.
+ *
+ * @param realId the session id with any jvmRoute removed
+ */
+ public void removePojoLocal(String realId, String key)
+ {
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("removePojoLocal(): session id: " + realId + " key: " +key);
+ }
+ // Construct the fqn.
+ Fqn fqn = getFieldFqn(realId, key);
+ try {
+ // Ignore any cache notifications that our own work generates
+ SessionReplicationContext.startCacheActivity();
+ cacheWrapper_.removeLocalSubtree(fqn);
+ }
+ finally {
+ SessionReplicationContext.finishCacheActivity();
+ }
+ }
+
+ public Set getPojoKeys(String realId)
+ {
+ Set keys = null;
+ Fqn fqn = getAttributeFqn(realId);
+ try
+ {
+ keys = getChildrenNames(fqn);
+ }
+ catch (CacheException e)
+ {
+ log_.error("getPojoKeys(): Exception getting keys for session " + realId, e);
+ }
+
+ return keys;
+ }
+
+
+ /**
+ *
+ * @param realId the session id with any jvmRoute removed
+ * @param key the attribute key
+ * @return Pojo that is associated with the attribute
+ */
+ public Object getPojo(String realId, String key)
+ {
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("getPojo(): session id: " +realId + " key: " +key);
+ }
+ // Construct the fqn.
+ Fqn fqn = getFieldFqn(realId, key);
+
+ PojoCacheThreadContext ctx = pojoCache_.getThreadContext();
+ try
+ {
+ ctx.setGravitationEnabled(true);
+ return pojoCache_.find(fqn.toString());
+ }
+ catch (CacheException e)
+ {
+ throw new RuntimeException("JBossCacheService: exception occurred in cache getPojo ... ", e);
+ }
+ finally
+ {
+ ctx.clear();
+ }
+ }
+
+ /**
+ * Recursively adds session as observer to the pojo graph. Assumes the
+ * whole object graph has Subject "introduction" declared. If a portion
+ * of the graph isn't a Subject, the recursion does not continue below
+ * that part of the graph.
+ *
+ * @param session the session
+ * @param pojo the pojo. Can be <code>null</code>.
+ */
+ public void addObserver(Observer session, Object pojo)
+ {
+ addObserver(session, pojo, new HashSet());
+ }
+
+ private void addObserver(Observer session, Object pojo, Set processed)
+ {
+ if ( pojo instanceof Collection )
+ {
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("addObserver(): pojo of type " +pojo.getClass().getName() + " is a Collection; trying to observe elements");
+ }
+ Collection col = (Collection)pojo;
+ for (Iterator i = col.iterator(); i.hasNext();) {
+ // If not a managed pojo, will return anyway
+ addObserver(session, i.next(), processed);
+ }
+ }
+ else if (pojo instanceof Map)
+ {
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("addObserver(): pojo of type " +pojo.getClass().getName() + " is a Map; trying to observe entries");
+ }
+ for (Iterator i = ((Map)pojo).entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+
+ // Walk thru key and value
+ addObserver(session, entry.getKey(), processed);
+ addObserver(session, entry.getValue(), processed);
+ }
+ }
+
+ if(! (pojo instanceof Subject) )
+ {
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("addObserver(): pojo of type " +pojo.getClass().getName() + " is not a Subject");
+ }
+ return; // No need to add observer since it is primitive.
+ }
+
+ Subject subject = (Subject)pojo;
+ subject.addObserver(session);
+
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("addObserver(): session: " +session + " pojo name: " +pojo.getClass().getName());
+ }
+
+ // Examine each field of the type and its superclasses to see if
+ // we need to add the observer to the pojo held by that field
+ // Traverse recursively
+
+ // First identify and cache the names of all the class'
+ // non-immediate fields
+ Class type = pojo.getClass();
+ Set complexFields = (Set) typeMap.get(type);
+ if (complexFields == null)
+ {
+ complexFields = Util.parseComplexFields(type);
+ typeMap.put(type, complexFields);
+ }
+
+ if (complexFields.size() == 0)
+ return;
+
+ // Store a ref to the pojo to avoid cyclic additions
+ processed.add(pojo);
+
+ for (Iterator iter = complexFields.iterator(); iter.hasNext();)
+ {
+ String fieldName = (String) iter.next();
+ Class curType = type;
+ while (curType != null)
+ {
+ try
+ {
+ Field field = curType.getDeclaredField(fieldName);
+ boolean accessible = field.isAccessible();
+ Object value = null;
+ try
+ {
+ field.setAccessible(true);
+
+ value=field.get(pojo);
+ // Continue recursively unless we've already handled this value
+ if (value != null && !processed.contains(value))
+ addObserver(session, value, processed);
+ break;
+ }
+ catch(IllegalAccessException e)
+ {
+ throw new RuntimeException("field access failed", e);
+ }
+ finally
+ {
+ field.setAccessible(accessible);
+ }
+ }
+ catch (NoSuchFieldException e)
+ {
+ // Check if the field is declared in a superclass
+ curType = curType.getSuperclass();
+ if (curType == null)
+ throw new RuntimeException("Field " + fieldName +
+ " does not exist", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Recursively removes session as observer to the pojo graph. Assumes the
+ * whole object graph has Subject "introduction" declared. If a portion
+ * of the graph isn't a Subject, the recursion does not continue below
+ * that part of the graph.
+ *
+ * @param session the session
+ * @param pojo the pojo to stop observing. Can be <code>null</code>.
+ */
+ public void removeObserver(Observer session, Object pojo)
+ {
+ removeObserver(session, pojo, new HashSet());
+ }
+
+ private void removeObserver(Observer session, Object pojo, Set stack)
+ {
+ if ( pojo instanceof Collection )
+ {
+ Collection col = (Collection)pojo;
+ for (Iterator i = col.iterator(); i.hasNext();) {
+ Object obj = i.next();
+ // If not a managed pojo, will return anyway
+ removeObserver(session, obj, stack);
+ }
+
+ return;
+ }
+ else if (pojo instanceof Map)
+ {
+ Map map = (Map)pojo;
+ for (Iterator i = map.keySet().iterator(); i.hasNext();) {
+ Object key = i.next();
+ Object value = map.get(key);
+
+ // Walk thru key and value
+ removeObserver(session, key, stack);
+ removeObserver(session, value, stack);
+ }
+
+ return;
+ }
+ // BRIAN 3/14 changed this from checking Advised to checking Subject
+ // since that is what we cast to below
+ if(! (pojo instanceof Subject) )
+ {
+ return; // No need to add observer since it is primitive.
+ }
+
+ Subject subject = (Subject)pojo;
+ try
+ {
+ subject.removeObserver(session);
+ }
+ catch (PojoCacheAlreadyDetachedException e)
+ {
+ // We've hit a stale pojo; can't continue further
+ // This will regularly happen when we handle notifications
+ // of remote attribute removals and remote invalidations
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("removeObserver(): found detached in session: " +session + " pojo name: " +pojo.getClass().getName());
+ }
+ return;
+ }
+
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("removeObserver(): session: " +session + " pojo name: " +pojo.getClass().getName());
+ }
+
+ // Examine each field of the type and its superclasses to see if
+ // we need to remove the observer from the pojo held by that field
+ // Traverse recursively
+
+ // First identify and cache the names of all the class'
+ // non-immediate fields
+ Class type = pojo.getClass();
+ Set complexFields = (Set) typeMap.get(type);
+ if (complexFields == null)
+ {
+ complexFields = Util.parseComplexFields(type);
+ typeMap.put(type, complexFields);
+ }
+
+ if (complexFields.size() == 0)
+ return;
+
+ // Store a ref to the pojo to avoid cyclic removals
+ stack.add(pojo);
+
+ for (Iterator iter = complexFields.iterator(); iter.hasNext();)
+ {
+ String fieldName = (String) iter.next();
+ Class curType = type;
+ while (curType != null)
+ {
+ try
+ {
+ Field field = curType.getDeclaredField(fieldName);
+ boolean accessible = field.isAccessible();
+ Object value = null;
+ try
+ {
+ field.setAccessible(true);
+
+ value=field.get(pojo);
+ // Continue recursively unless we've already handled this value
+ if (value != null && !stack.contains(value))
+ removeObserver(session, value, stack);
+ break;
+ }
+ catch (PojoCacheAlreadyDetachedException e)
+ {
+ // We've hit a stale proxy; can't continue further
+ // This will regularly happen when we handle notifications
+ // of remote attribute removals and remote invalidations
+ if(log_.isTraceEnabled())
+ {
+ log_.trace("removeObserver(): found detached pojo in field " + field.getName() + " in object graph under session: " +session + " pojo name: " +pojo.getClass().getName());
+ }
+ break;
+ }
+ catch(IllegalAccessException e)
+ {
+ throw new RuntimeException("field access failed", e);
+ }
+ finally
+ {
+ field.setAccessible(accessible);
+ }
+ }
+ catch (NoSuchFieldException e)
+ {
+ // Check if the field is declared in a superclass
+ curType = curType.getSuperclass();
+ if (curType == null)
+ throw new RuntimeException("Field " + fieldName +
+ " does not exist", e);
+ }
+ }
+ }
+ }
+
+ private void initializeFieldGranularityEviction(ClassLoader regionCL)
+ {
+ JBossCacheManager manager = getManager();
+ if (manager.getReplicationGranularity() == ReplicationGranularity.FIELD)
+ {
+ int maxNodes = Math.max(0, manager.getPassivationMaxObjects());
+ int maxIdle = Math.max(0, manager.getPassivationMaxObjectIdleTime());
+ if (maxNodes > 0 || maxIdle > 0)
+ {
+ EvictionPolicyConfig epc = getEvictionPolicyConfig(maxIdle, maxNodes);
+ evictionRegion_ = getCache().getRegion(getWebappFqn(), true);
+ evictionRegion_.setEvictionPolicy(epc);
+ EvictionPolicy policy = evictionRegion_.getEvictionPolicy();
+ evictionAlgorithm_ = (JBossWebManagedLRUAlgorithm) policy.getEvictionAlgorithm();
+
+ // Assign the classloader to this region as well
+ evictionRegion_.registerContextClassLoader(regionCL);
+ }
+ }
+ }
+
+ private EvictionPolicyConfig getEvictionPolicyConfig(int timeToLiveSeconds, int maxNodes)
+ {
+ JBossWebManagedLRUConfiguration epc = new JBossWebManagedLRUConfiguration();
+ epc.setEvictionPolicyClass(JBossWebManagedLRUPolicy.class.getName());
+ epc.setTimeToLiveSeconds(timeToLiveSeconds);
+ epc.setMaxNodes(maxNodes);
+ return epc;
+ }
+
+}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheCluster.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheCluster.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheCluster.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -524,21 +524,29 @@
log.debug("Creating ClusterManager for context " + name
+ " using class " + getManagerClassName());
Manager manager = null;
- try
+
+ String mgrClass = getManagerClassName();
+ if (mgrClass != null && !JBossCacheManager.class.getName().equals(mgrClass))
{
- manager = (Manager) getClass().getClassLoader().loadClass(
- getManagerClassName()).newInstance();
- }
- catch (Exception x)
+ try
+ {
+ manager = (Manager) getClass().getClassLoader().loadClass(mgrClass).newInstance();
+ }
+ catch (Exception x)
+ {
+ log.error("Unable to load class " + mgrClass + " for replication manager; using JBossCacheManager", x);
+ }
+ }
+
+ if (manager == null)
{
- log.error("Unable to load class for replication manager", x);
- manager = new JBossCacheManager();
- }
- finally
- {
- manager.setDistributable(true);
+ if (pojoCache == null)
+ throw new IllegalStateException("PojoCache not initialized");
+ manager = new JBossCacheManager(pojoCache.getPojoCache());
}
+ manager.setDistributable(true);
+
if (manager instanceof JBossCacheManager)
{
configureManager((JBossCacheManager) manager);
@@ -625,7 +633,6 @@
manager.setSnapshotMode(snapshotMode);
manager.setSnapshotInterval(snapshotInterval);
manager.setUseJK(useJK);
- manager.setCacheObjectNameString(pojoCacheObjectName);
// Only set replication attributes if they were not
// already set via a <Manager> element in an XML config file
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-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -21,6 +21,7 @@
*/
package org.jboss.web.tomcat.service.session;
+import java.security.AccessController;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -44,8 +45,12 @@
import org.apache.catalina.Session;
import org.apache.catalina.Valve;
import org.apache.catalina.core.ContainerBase;
+import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheStatus;
import org.jboss.cache.pojo.PojoCache;
+import org.jboss.ha.cachemanager.CacheManagerLocator;
+import org.jboss.ha.cachemanager.PojoCacheManager;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.jboss.PassivationConfig;
import org.jboss.metadata.web.jboss.ReplicationConfig;
@@ -53,6 +58,7 @@
import org.jboss.metadata.web.jboss.ReplicationTrigger;
import org.jboss.metadata.web.jboss.SnapshotMode;
import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.util.loading.ContextClassLoaderSwitcher;
/**
* Implementation of a clustered session manager for
@@ -98,8 +104,7 @@
private PojoCache pojoCache_;
- /** Our TreeCache's ObjectName */
- private String cacheObjectNameString_ = "jboss.cache:service=TomcatClusteringCache";
+ private Cache plainCache_;
/**
* If set to true, will add a JvmRouteFilter to the request.
@@ -119,7 +124,7 @@
private int snapshotInterval_ = 0;
/**
- * Replication granulairty.
+ * Replication granularity.
*/
private ReplicationGranularity replicationGranularity_;
@@ -151,6 +156,14 @@
* The snapshot manager we are using.
*/
private SnapshotManager snapshotManager_;
+
+ /**
+ * The name of our cache's configuration
+ */
+ private String cacheConfigName_;
+
+ /** Did we get our cache from a cache manager */
+ private boolean cacheFromCacheManager_;
// ---------------------------------------------------------- Constructors
@@ -161,9 +174,15 @@
public JBossCacheManager(PojoCache cache)
{
- super();
+ this(cache.getCache());
this.pojoCache_ = cache;
}
+
+ public JBossCacheManager(Cache cache)
+ {
+ super();
+ this.plainCache_ = cache;
+ }
/**
* Initializes this Manager when running in embedded mode.
@@ -213,15 +232,11 @@
" and snapshotMode is " + snapshotMode_ +
" and snapshotInterval is " + snapshotInterval_);
- PojoCache pc = getPojoCache();
- if (pc == null)
- {
- proxy_ = new JBossCacheService(cacheObjectNameString_);
- }
- else
- {
- proxy_ = new JBossCacheService(pc);
- }
+ this.cacheConfigName_ = repCfg.getCacheName();
+
+ // Initing the proxy would be better in start, but we do it here so we
+ // can detect ClusteringNotSupportedException at this deploy stage
+ initCacheProxy();
// Confirm our replication granularity is compatible with the cache
// Throws ISE if not
@@ -230,33 +245,78 @@
embedded_ = true;
}
- // ------------------------------------------------------------- Properties
-
/**
- * Gets the <code>JBossCacheService</code> through which we interact
- * with the <code>TreeCache</code>.
+ * Accesses the underlying cache and creates the proxy
+ *
+ * @throws ClusteringNotSupportedException
*/
- public JBossCacheService getCacheService()
+ private void initCacheProxy() throws ClusteringNotSupportedException
{
- return proxy_;
+ // We are likely going to cause creation and start of a cache here;
+ // we don't want to leak the TCCL to cache/jgroups threads,
+ // so we switch it to our classloader
+ ContextClassLoaderSwitcher switcher = (ContextClassLoaderSwitcher) AccessController.doPrivileged(ContextClassLoaderSwitcher.INSTANTIATOR);
+ ContextClassLoaderSwitcher.SwitchContext switchContext = switcher.getSwitchContext(getClass().getClassLoader());
+ try
+ {
+ if (ReplicationGranularity.FIELD == replicationGranularity_)
+ {
+ PojoCache pojoC = getPojoCache();
+ if (pojoC == null)
+ {
+ pojoC = Util.findPojoCache(cacheConfigName_);
+
+ cacheFromCacheManager_ = true;
+
+ if (pojoC.getCache().getCacheStatus() != CacheStatus.STARTED)
+ pojoC.getCache().start();
+ }
+ proxy_ = new FieldBasedJBossCacheService(pojoC);
+ }
+ else
+ {
+ Cache pc = getPlainCache();
+ if (pc == null)
+ {
+ pc = Util.findPlainCache(cacheConfigName_);
+
+ cacheFromCacheManager_ = true;
+
+ if (pc.getCacheStatus() != CacheStatus.STARTED)
+ pc.start();
+ }
+ proxy_ = new JBossCacheService(pc);
+ }
+ }
+ finally
+ {
+ // Restore the TCCL
+ switchContext.reset();
+ }
}
+ // ------------------------------------------------------------- Properties
+
/**
- * Gets a String representation of the JMX <code>ObjectName</code> under
- * which our <code>TreeCache</code> is registered.
+ * Gets the <code>FieldBasedJBossCacheService</code> through which we interact
+ * with the PojoCache.
+ *
+ * @throws IllegalStateException if we are not using field based replication
*/
- public String getCacheObjectNameString()
+ public FieldBasedJBossCacheService getPojoCacheService()
{
- return cacheObjectNameString_;
+ if (proxy_ != null && !(proxy_ instanceof FieldBasedJBossCacheService))
+ throw new IllegalStateException("PojoCache not being used");
+ return (FieldBasedJBossCacheService) proxy_;
}
/**
- * Sets the JMX <code>ObjectName</code> under which our
- * <code>TreeCache</code> is registered.
+ * Gets the <code>JBossCacheService</code> through which we interact
+ * with the <code>Cache</code>.
*/
- public void setCacheObjectNameString(String treeCacheObjectName)
+ public JBossCacheService getCacheService()
{
- this.cacheObjectNameString_ = treeCacheObjectName;
+ return proxy_;
}
/**
@@ -573,6 +633,12 @@
log_.debug("Stopping");
+ // Block for any ongoing backgroundProcess, then disable
+ synchronized (backgroundProcessAllowed)
+ {
+ backgroundProcessAllowed.set(false);
+ }
+
resetStats();
// Notify our interested LifecycleListeners
@@ -584,8 +650,16 @@
tcl_ = null;
proxy_.stop();
+ proxy_ = null;
+
tm = null;
+ if (cacheFromCacheManager_)
+ {
+ // Let the manager know we are done with the cache
+ releaseCacheToManager();
+ }
+
snapshotManager_.stop();
// Clean up maps
@@ -610,7 +684,7 @@
}
/**
- * Clear the underlying cache store and also pojo that has the observers.
+ * Clear the underlying cache store.
*/
protected void clearSessions()
{
@@ -640,7 +714,6 @@
{
ses.expire(notify, localCall, localOnly);
}
-
}
catch (Throwable t)
{
@@ -655,24 +728,33 @@
}
}
+ String action = passivation ? "evicting" : "removing";
Set<Map.Entry<String, OwnedSessionUpdate>> unloaded =
unloadedSessions_.entrySet();
for (Iterator<Map.Entry<String, OwnedSessionUpdate>> it = unloaded.iterator(); it.hasNext();)
{
Map.Entry<String, OwnedSessionUpdate> entry = it.next();
- String realId = entry.getKey();
- if (passivation)
+ String realId = entry.getKey();
+ try
{
- OwnedSessionUpdate osu = entry.getValue();
- // Ignore the marker entries for our passivated sessions
- if (!osu.passivated)
+ if (passivation)
{
- proxy_.evictSession(realId, osu.owner);
+ OwnedSessionUpdate osu = entry.getValue();
+ // Ignore the marker entries for our passivated sessions
+ if (!osu.passivated)
+ {
+ proxy_.evictSession(realId, osu.owner);
+ }
}
+ else
+ {
+ proxy_.removeSessionLocal(realId);
+ }
}
- else
+ catch (Exception e)
{
- proxy_.removeSessionLocal(realId);
+ // Not as big a problem; we don't own the session
+ log_.debug("Problem " + action + " session " + realId + " -- " + e);
}
it.remove();
}
@@ -836,9 +918,13 @@
*/
private void add(ClusteredSession session, boolean replicate)
{
+ // TODO -- why are we doing this check? The request checks session
+ // validity and will expire the session; this seems redundant
if (!session.isValid())
{
- log_.error("Cannot add session with id=" + session.getIdInternal() +
+ // Not an error; this can happen if a failover request pulls in an
+ // outdated session from the distributed cache (see TODO above)
+ log_.debug("Cannot add session with id=" + session.getIdInternal() +
" because it is invalid");
return;
}
@@ -1776,7 +1862,7 @@
return (passivationMode_ && proxy_.isCachePassivationEnabled());
}
- // ---------------------------------------------------- Lifecyle Unembedded
+ // ------------------------------------------------------ Lifecyle Embedded
/**
* Start this Manager when running embedded in JBoss AS.
@@ -1789,19 +1875,24 @@
// Start the JBossCacheService
// Will need to pass the classloader that is associated with this
- //web app so de-serialization will work correctly.
+ // web app so de-serialization will work correctly.
tcl_ = super.getContainer().getLoader().getClassLoader();
-
- proxy_.start(tcl_, this);
-
- tm = proxy_.getTransactionManager();
- if(tm == null)
- {
- throw new LifecycleException("JBossCacheManager.start(): Obtain null tm");
- }
try
{
+ if (proxy_ == null) // Could happen during a restart
+ {
+ initCacheProxy();
+ }
+
+ proxy_.start(tcl_, this);
+
+ tm = proxy_.getTransactionManager();
+ if(tm == null)
+ {
+ throw new LifecycleException("JBossCacheManager.start(): Obtain null tm");
+ }
+
initializeUnloadedSessions();
// Setup our SnapshotManager
@@ -1812,6 +1903,10 @@
log_.debug("start(): JBossCacheService started");
}
+ catch (LifecycleException le)
+ {
+ throw le;
+ }
catch (Exception e)
{
log_.error("Unable to start manager.", e);
@@ -1858,15 +1953,7 @@
// Create the JBossCacheService
try
{
- PojoCache pc = getPojoCache();
- if (pc == null)
- {
- proxy_ = new JBossCacheService(cacheObjectNameString_);
- }
- else
- {
- proxy_ = new JBossCacheService(pc);
- }
+ initCacheProxy();
// Confirm our replication granularity is compatible with the cache
// Throws ISE if not
@@ -2018,7 +2105,15 @@
unloadedSessions_.put(realId, osu);
if (passivateExcess && calcActiveSessions() > maxActive_)
{
- processUnloadedSessionPassivation(realId, osu);
+ try
+ {
+ processUnloadedSessionPassivation(realId, osu);
+ }
+ catch (Exception e)
+ {
+ // most likely a lock conflict if the session is being updated remotely; ignore it
+ log_.debug("Problem passivating session " + realId + " -- " + e.toString());
+ }
}
}
}
@@ -2173,11 +2268,33 @@
}
}
+ public void releaseCacheToManager()
+ {
+ try
+ {
+ PojoCacheManager pcm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ pcm.releaseCache(cacheConfigName_);
+ }
+ catch (Exception e)
+ {
+ log_.error("Problem releasing cache to CacheManager -- config is " + cacheConfigName_, e);
+ }
+ }
+
public PojoCache getPojoCache()
{
return pojoCache_;
}
+
+ public Cache getPlainCache()
+ {
+ return plainCache_;
+ }
+ public String getCacheConfigName()
+ {
+ return (cacheFromCacheManager_ ? cacheConfigName_ : null);
+ }
private class OwnedSessionUpdate
{
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManagerMBean.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -66,9 +66,13 @@
String getLastAccessedTime(String sessionId);
/**
- * Gets the JMX ObjectName of the distributed session cache as a string.
+ * Gets the cache config name used to get the underlying cache
+ * from a cache manager.
+ *
+ * @return the config name, or <code>null</code> if this has not yet been
+ * configured or the cache was directly injected.
*/
- String getCacheObjectNameString();
+ String getCacheConfigName();
/**
* Gets the replication granularity.
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-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -25,44 +25,26 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.WeakHashMap;
import java.util.Map.Entry;
-import javax.management.ObjectName;
import javax.transaction.TransactionManager;
import org.apache.catalina.Container;
-import org.jboss.aspects.patterns.observable.Observer;
-import org.jboss.aspects.patterns.observable.Subject;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.Region;
-import org.jboss.cache.pojo.PojoCache;
-import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
-import org.jboss.cache.pojo.PojoCacheThreadContext;
-import org.jboss.cache.pojo.jmx.PojoCacheJmxWrapperMBean;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.eviction.EvictionException;
-import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.pojo.impl.InternalConstant;
import org.jboss.cache.transaction.BatchModeTransactionManager;
import org.jboss.invocation.MarshalledValue;
import org.jboss.logging.Logger;
-import org.jboss.metadata.web.jboss.ReplicationGranularity;
-import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.serial.io.MarshalledObject;
/**
@@ -86,21 +68,19 @@
static final String VERSION_KEY = "VERSION";
static final String FQN_DELIMITER = "/";
- private PojoCache pojoCache_;
private Cache plainCache_;
- private ObjectName cacheServiceName_;
// name of webapp's virtual host(JBAS-2194).
// Idea is host_name + web_app_path + session id is a unique combo.
- private String hostName_;
+ protected String hostName_;
// web app path (JBAS-1367 and JBAS-2194).
// Idea is host_name + web_app_path + session id is a unique combo.
- private String webAppPath_;
- private TransactionManager tm;
+ protected String webAppPath_;
+ protected TransactionManager tm;
private JBossCacheManager manager_;
private CacheListener cacheListener_;
- private JBossCacheWrapper cacheWrapper_;
+ protected JBossCacheWrapper cacheWrapper_;
// Do we have to marshall attributes ourself or can we let
// the TreeCache do it?
@@ -109,69 +89,34 @@
// Are we configured for passivation?
private boolean usePassivation_ = false;
private PassivationListener passivationListener_;
- private Region evictionRegion_;
- private JBossWebManagedLRUAlgorithm evictionAlgorithm_;
- private WeakHashMap typeMap = new WeakHashMap();
- public JBossCacheService(PojoCache cache)
+ public JBossCacheService(Cache cache)
{
- if (cache == null)
- {
- throw new IllegalArgumentException("cache cannot be null");
- }
+ plainCache_ = cache;
- pojoCache_ = cache;
+ cacheWrapper_ = new JBossCacheWrapper(plainCache_);
- init();
+ useTreeCacheMarshalling_ = plainCache_.getConfiguration().isUseRegionBasedMarshalling();
+ CacheLoaderConfig clc = plainCache_.getConfiguration().getCacheLoaderConfig();
+ if(clc != null)
+ {
+ usePassivation_ = (clc.isPassivation() && !clc.isShared());
+ }
}
- public JBossCacheService(String treeCacheObjectName) throws ClusteringNotSupportedException
+ protected JBossCacheManager getManager()
{
- // Find JBossCacheService
- try
- {
- cacheServiceName_ = new ObjectName(treeCacheObjectName);
- // Get the pojo cache
- PojoCacheJmxWrapperMBean mbean = (PojoCacheJmxWrapperMBean) MBeanProxyExt.create(PojoCacheJmxWrapperMBean.class,
- cacheServiceName_);
- if (mbean != null)
- {
- pojoCache_ = mbean.getPojoCache();
- }
- }
- catch (Throwable t)
- {
-
- String str = "Could not access TreeCache service " +
- (cacheServiceName_ == null ? "<null>" : cacheServiceName_.toString()) +
- " for Tomcat clustering";
- log_.debug(str);
- throw new ClusteringNotSupportedException(str, t);
- }
-
- if (pojoCache_ == null)
- {
- String str = "Could not access TreeCache service " +
- (cacheServiceName_ == null ? "<null>" : cacheServiceName_.toString()) +
- " for Tomcat clustering";
- log_.debug(str);
- throw new ClusteringNotSupportedException(str);
- }
-
- init();
+ return manager_;
}
- private void init()
+ protected Cache getCache()
{
- plainCache_ = pojoCache_.getCache();
- cacheWrapper_ = new JBossCacheWrapper(pojoCache_);
+ return plainCache_;
+ }
- useTreeCacheMarshalling_ = plainCache_.getConfiguration().isUseRegionBasedMarshalling();
- CacheLoaderConfig clc = plainCache_.getConfiguration().getCacheLoaderConfig();
- if(clc != null)
- {
- usePassivation_ = (clc.isPassivation() && !clc.isShared());
- }
+ protected void setCache(Cache cache)
+ {
+ this.plainCache_ = cache;
}
public void start(ClassLoader tcl, JBossCacheManager manager)
@@ -240,8 +185,6 @@
log_.debug("Passivation is enabled");
passivationListener_ = new PassivationListener(manager_, hostName_, webAppPath_);
plainCache_.addCacheListener(passivationListener_);
-
- initializeFieldGranularityEviction(tcl);
}
else
{
@@ -277,13 +220,7 @@
log_.error("Exception during inactivation of webapp region " + pathFqn +
" or un-registration of its class loader", e);
}
- }
-
- if (evictionRegion_ != null)
- {
- plainCache_.removeRegion(evictionRegion_.getFqn());
- evictionRegion_ = null;
- }
+ }
// remove session data
// BES 2007/08/18 Can't do this as it will
@@ -443,7 +380,7 @@
}
public void evictSession(String realId, String dataOwner)
- {
+ {
Fqn fqn = dataOwner == null ? getSessionFqn(realId) : getSessionFqn(realId, dataOwner);
if(log_.isTraceEnabled())
{
@@ -583,8 +520,8 @@
Node webRoot = owner.getChild(getWebappFqn());
if (webRoot != null)
{
- Set ids = webRoot.getChildrenNames();
- storeSessionOwners(ids, owner.getFqn().getLastElement(), result);
+ Set<String> ids = webRoot.getChildrenNames();
+ storeSessionOwners(ids, (String) owner.getFqn().getLastElement(), result);
}
}
}
@@ -595,439 +532,25 @@
return result;
}
- private Set getChildrenNames(Fqn fqn)
+ protected Set getChildrenNames(Fqn fqn)
{
Node node = plainCache_.getRoot().getChild(fqn);
return (node == null ? null : node.getChildrenNames());
}
- private void storeSessionOwners(Set ids, Object owner, Map map)
+ private void storeSessionOwners(Set<String> ids, String owner, Map<String, String> map)
{
if (ids != null)
{
- for (Iterator it = ids.iterator(); it.hasNext();)
- {
- map.put(it.next(), owner);
- }
- }
- }
-
- /**
- * store the pojo instance in the cache. Note that this is for the aop cache.
- * THe pojo needs to be "aspectized".
- *
- * @param realId the session id with any jvmRoute removed
- * @param key the attribute key
- * @param pojo
- */
- public Object setPojo(String realId, String key, Object pojo)
- {
- if(log_.isTraceEnabled())
- {
- log_.trace("setPojo(): session id: " + realId + " key: " + key +
- " object: " + pojo.toString());
- }
- // Construct the fqn.
- Fqn fqn = getFieldFqn(realId, key);
- try {
- // Ignore any cache notifications that our own work generates
- SessionReplicationContext.startCacheActivity();
- return pojoCache_.attach(fqn.toString(), pojo);
- } catch (CacheException e) {
- throw new RuntimeException("JBossCacheService: exception occurred in cache setPojo ... ", e);
- }
- finally {
- SessionReplicationContext.finishCacheActivity();
- }
- }
-
- /**
- * Remove pojo from the underlying cache store.
- * @param realId the session id with any jvmRoute removed
- * @param key the attribute key
- * @return pojo that just removed. Null if there none.
- */
- public Object removePojo(String realId, String key)
- {
- if(log_.isTraceEnabled())
- {
- log_.trace("removePojo(): session id: " +realId + " key: " +key);
- }
- // Construct the fqn.
- Fqn fqn = getFieldFqn(realId, key);
- try {
- // Ignore any cache notifications that our own work generates
- SessionReplicationContext.startCacheActivity();
- return pojoCache_.detach(fqn.toString());
- } catch (CacheException e) {
- throw new RuntimeException("JBossCacheService: exception occurred in cache removePojo ... ", e);
- }
- finally {
- SessionReplicationContext.finishCacheActivity();
- }
- }
-
- /**
- * Remove all the pojos from the underlying cache store locally
- * without replication.
- *
- * @param realId the session id with any jvmRoute removed
- */
- public void removePojosLocal(String realId)
- {
- if(log_.isTraceEnabled())
- {
- log_.trace("removePojoLocal(): session id: " +realId);
- }
- // Construct the fqn.
- Fqn fqn = getAttributeFqn(realId);
- try {
- // Ignore any cache notifications that our own work generates
- SessionReplicationContext.startCacheActivity();
- cacheWrapper_.removeLocalSubtree(fqn);
- }
- finally {
- SessionReplicationContext.finishCacheActivity();
- }
- }
-
- /**
- * Remove all the pojos from the underlying cache store locally
- * without replication.
- *
- * @param realId the session id with any jvmRoute removed
- */
- public void removePojoLocal(String realId, String key)
- {
- if(log_.isTraceEnabled())
- {
- log_.trace("removePojoLocal(): session id: " + realId + " key: " +key);
- }
- // Construct the fqn.
- Fqn fqn = getFieldFqn(realId, key);
- try {
- // Ignore any cache notifications that our own work generates
- SessionReplicationContext.startCacheActivity();
- cacheWrapper_.removeLocalSubtree(fqn);
- }
- finally {
- SessionReplicationContext.finishCacheActivity();
- }
- }
-
- public Set getPojoKeys(String realId)
- {
- Set keys = null;
- Fqn fqn = getAttributeFqn(realId);
- try
- {
- keys = getChildrenNames(fqn);
- }
- catch (CacheException e)
- {
- log_.error("getPojoKeys(): Exception getting keys for session " + realId, e);
- }
-
- return keys;
- }
-
-
- /**
- *
- * @param realId the session id with any jvmRoute removed
- * @param key the attribute key
- * @return Pojo that is associated with the attribute
- */
- public Object getPojo(String realId, String key)
- {
- if(log_.isTraceEnabled())
- {
- log_.trace("getPojo(): session id: " +realId + " key: " +key);
- }
- // Construct the fqn.
- Fqn fqn = getFieldFqn(realId, key);
-
- PojoCacheThreadContext ctx = pojoCache_.getThreadContext();
- try
- {
- ctx.setGravitationEnabled(true);
- return pojoCache_.find(fqn.toString());
- }
- catch (CacheException e)
- {
- throw new RuntimeException("JBossCacheService: exception occurred in cache getPojo ... ", e);
- }
- finally
- {
- ctx.clear();
- }
- }
-
- /**
- * Recursively adds session as observer to the pojo graph. Assumes the
- * whole object graph has Subject "introduction" declared. If a portion
- * of the graph isn't a Subject, the recursion does not continue below
- * that part of the graph.
- *
- * @param session the session
- * @param pojo the pojo. Can be <code>null</code>.
- */
- public void addObserver(Observer session, Object pojo)
- {
- addObserver(session, pojo, new HashSet());
- }
-
- private void addObserver(Observer session, Object pojo, Set processed)
- {
- if ( pojo instanceof Collection )
- {
- if(log_.isTraceEnabled())
- {
- log_.trace("addObserver(): pojo of type " +pojo.getClass().getName() + " is a Collection; trying to observe elements");
- }
- Collection col = (Collection)pojo;
- for (Iterator i = col.iterator(); i.hasNext();) {
- // If not a managed pojo, will return anyway
- addObserver(session, i.next(), processed);
- }
- }
- else if (pojo instanceof Map)
- {
- if(log_.isTraceEnabled())
- {
- log_.trace("addObserver(): pojo of type " +pojo.getClass().getName() + " is a Map; trying to observe entries");
- }
- for (Iterator i = ((Map)pojo).entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry) i.next();
-
- // Walk thru key and value
- addObserver(session, entry.getKey(), processed);
- addObserver(session, entry.getValue(), processed);
- }
- }
-
- if(! (pojo instanceof Subject) )
- {
- if(log_.isTraceEnabled())
- {
- log_.trace("addObserver(): pojo of type " +pojo.getClass().getName() + " is not a Subject");
- }
- return; // No need to add observer since it is primitive.
- }
-
- Subject subject = (Subject)pojo;
- subject.addObserver(session);
-
- if(log_.isTraceEnabled())
- {
- log_.trace("addObserver(): session: " +session + " pojo name: " +pojo.getClass().getName());
- }
-
- // Examine each field of the type and its superclasses to see if
- // we need to add the observer to the pojo held by that field
- // Traverse recursively
-
- // First identify and cache the names of all the class'
- // non-immediate fields
- Class type = pojo.getClass();
- Set complexFields = (Set) typeMap.get(type);
- if (complexFields == null)
- {
- complexFields = Util.parseComplexFields(type);
- typeMap.put(type, complexFields);
- }
-
- if (complexFields.size() == 0)
- return;
-
- // Store a ref to the pojo to avoid cyclic additions
- processed.add(pojo);
-
- for (Iterator iter = complexFields.iterator(); iter.hasNext();)
- {
- String fieldName = (String) iter.next();
- Class curType = type;
- while (curType != null)
- {
- try
+ for (String id : ids)
+ {
+ if (!InternalConstant.JBOSS_INTERNAL_STRING.equals(id))
{
- Field field = curType.getDeclaredField(fieldName);
- boolean accessible = field.isAccessible();
- Object value = null;
- try
- {
- field.setAccessible(true);
-
- value=field.get(pojo);
- // Continue recursively unless we've already handled this value
- if (value != null && !processed.contains(value))
- addObserver(session, value, processed);
- break;
- }
- catch(IllegalAccessException e)
- {
- throw new RuntimeException("field access failed", e);
- }
- finally
- {
- field.setAccessible(accessible);
- }
+ map.put(id, owner);
}
- catch (NoSuchFieldException e)
- {
- // Check if the field is declared in a superclass
- curType = curType.getSuperclass();
- if (curType == null)
- throw new RuntimeException("Field " + fieldName +
- " does not exist", e);
- }
}
}
}
-
- /**
- * Recursively removes session as observer to the pojo graph. Assumes the
- * whole object graph has Subject "introduction" declared. If a portion
- * of the graph isn't a Subject, the recursion does not continue below
- * that part of the graph.
- *
- * @param session the session
- * @param pojo the pojo to stop observing. Can be <code>null</code>.
- */
- public void removeObserver(Observer session, Object pojo)
- {
- removeObserver(session, pojo, new HashSet());
- }
-
- private void removeObserver(Observer session, Object pojo, Set stack)
- {
- if ( pojo instanceof Collection )
- {
- Collection col = (Collection)pojo;
- for (Iterator i = col.iterator(); i.hasNext();) {
- Object obj = i.next();
- // If not a managed pojo, will return anyway
- removeObserver(session, obj, stack);
- }
-
- return;
- }
- else if (pojo instanceof Map)
- {
- Map map = (Map)pojo;
- for (Iterator i = map.keySet().iterator(); i.hasNext();) {
- Object key = i.next();
- Object value = map.get(key);
-
- // Walk thru key and value
- removeObserver(session, key, stack);
- removeObserver(session, value, stack);
- }
-
- return;
- }
- // BRIAN 3/14 changed this from checking Advised to checking Subject
- // since that is what we cast to below
- if(! (pojo instanceof Subject) )
- {
- return; // No need to add observer since it is primitive.
- }
-
- Subject subject = (Subject)pojo;
- try
- {
- subject.removeObserver(session);
- }
- catch (PojoCacheAlreadyDetachedException e)
- {
- // We've hit a stale pojo; can't continue further
- // This will regularly happen when we handle notifications
- // of remote attribute removals and remote invalidations
- if(log_.isTraceEnabled())
- {
- log_.trace("removeObserver(): found detached in session: " +session + " pojo name: " +pojo.getClass().getName());
- }
- return;
- }
-
- if(log_.isTraceEnabled())
- {
- log_.trace("removeObserver(): session: " +session + " pojo name: " +pojo.getClass().getName());
- }
-
- // Examine each field of the type and its superclasses to see if
- // we need to remove the observer from the pojo held by that field
- // Traverse recursively
-
- // First identify and cache the names of all the class'
- // non-immediate fields
- Class type = pojo.getClass();
- Set complexFields = (Set) typeMap.get(type);
- if (complexFields == null)
- {
- complexFields = Util.parseComplexFields(type);
- typeMap.put(type, complexFields);
- }
-
- if (complexFields.size() == 0)
- return;
-
- // Store a ref to the pojo to avoid cyclic removals
- stack.add(pojo);
-
- for (Iterator iter = complexFields.iterator(); iter.hasNext();)
- {
- String fieldName = (String) iter.next();
- Class curType = type;
- while (curType != null)
- {
- try
- {
- Field field = curType.getDeclaredField(fieldName);
- boolean accessible = field.isAccessible();
- Object value = null;
- try
- {
- field.setAccessible(true);
-
- value=field.get(pojo);
- // Continue recursively unless we've already handled this value
- if (value != null && !stack.contains(value))
- removeObserver(session, value, stack);
- break;
- }
- catch (PojoCacheAlreadyDetachedException e)
- {
- // We've hit a stale proxy; can't continue further
- // This will regularly happen when we handle notifications
- // of remote attribute removals and remote invalidations
- if(log_.isTraceEnabled())
- {
- log_.trace("removeObserver(): found detached pojo in field " + field.getName() + " in object graph under session: " +session + " pojo name: " +pojo.getClass().getName());
- }
- break;
- }
- catch(IllegalAccessException e)
- {
- throw new RuntimeException("field access failed", e);
- }
- finally
- {
- field.setAccessible(accessible);
- }
- }
- catch (NoSuchFieldException e)
- {
- // Check if the field is declared in a superclass
- curType = curType.getSuperclass();
- if (curType == null)
- throw new RuntimeException("Field " + fieldName +
- " does not exist", e);
- }
- }
- }
- }
public boolean isCachePassivationEnabled()
{
@@ -1036,48 +559,11 @@
public void processEviction()
{
- if (evictionAlgorithm_ != null)
- {
- try
- {
- evictionAlgorithm_.backgroundProcess(evictionRegion_);
- }
- catch (EvictionException e)
- {
- log_.error("Problem handling eviction for region " + evictionRegion_, e);
- }
- }
+
}
-
- private Fqn getFieldFqn(String id, String key)
- {
- return getFieldFqn(hostName_, webAppPath_, id, key);
- }
-
- public static Fqn getFieldFqn(String hostName, String contextPath, String sessionId, String attributeKey)
- {
- List list = new ArrayList(6);
- list.add(SESSION);
- list.add(hostName);
- list.add(contextPath);
- list.add(sessionId);
- list.add(ATTRIBUTE);
- // Guard against string with delimiter.
- breakKeys(attributeKey, list);
- return new Fqn(list);
- }
- private static void breakKeys(String key, List list)
+ protected Fqn getWebappFqn()
{
- StringTokenizer token = new StringTokenizer(key, FQN_DELIMITER);
- while(token.hasMoreTokens())
- {
- list.add(token.nextToken());
- }
- }
-
- private Fqn getWebappFqn()
- {
// /SESSION/hostname/webAppPath
Object[] objs = new Object[]{SESSION, hostName_, webAppPath_};
return new Fqn(objs);
@@ -1105,7 +591,7 @@
return new Fqn(objs);
}
- private Fqn getAttributeFqn(String id)
+ protected Fqn getAttributeFqn(String id)
{
return getAttributeFqn(hostName_, webAppPath_, id);
}
@@ -1249,34 +735,5 @@
}
}
-
- private void initializeFieldGranularityEviction(ClassLoader regionCL)
- {
- if (manager_.getReplicationGranularity() == ReplicationGranularity.FIELD)
- {
- int maxNodes = Math.max(0, manager_.getPassivationMaxObjects());
- int maxIdle = Math.max(0, manager_.getPassivationMaxObjectIdleTime());
- if (maxNodes > 0 || maxIdle > 0)
- {
- EvictionPolicyConfig epc = getEvictionPolicyConfig(maxIdle, maxNodes);
- evictionRegion_ = plainCache_.getRegion(getWebappFqn(), true);
- evictionRegion_.setEvictionPolicy(epc);
- EvictionPolicy policy = evictionRegion_.getEvictionPolicy();
- evictionAlgorithm_ = (JBossWebManagedLRUAlgorithm) policy.getEvictionAlgorithm();
-
- // Assign the classloader to this region as well
- evictionRegion_.registerContextClassLoader(regionCL);
- }
- }
- }
-
- private EvictionPolicyConfig getEvictionPolicyConfig(int timeToLiveSeconds, int maxNodes)
- {
- JBossWebManagedLRUConfiguration epc = new JBossWebManagedLRUConfiguration();
- epc.setEvictionPolicyClass(JBossWebManagedLRUPolicy.class.getName());
- epc.setTimeToLiveSeconds(timeToLiveSeconds);
- epc.setMaxNodes(maxNodes);
- return epc;
- }
}
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-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheWrapper.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -29,7 +29,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.lock.TimeoutException;
-import org.jboss.cache.pojo.PojoCache;
public class JBossCacheWrapper
{
@@ -37,13 +36,11 @@
private static final String RETRY_FAIL_MSG =
"Continued to catch TimeoutException during " +
RETRY + " retry attempts. Giving up.";
- private PojoCache pojoCache_;
private Cache plainCache_;
- JBossCacheWrapper(PojoCache cache)
+ JBossCacheWrapper(Cache cache)
{
- pojoCache_ = cache;
- plainCache_ = pojoCache_.getCache();
+ plainCache_ = cache;
}
/**
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java 2008-04-21 01:04:46 UTC (rev 72468)
@@ -32,6 +32,10 @@
import java.util.Set;
import org.jboss.aop.Advised;
+import org.jboss.cache.Cache;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.ha.cachemanager.CacheManagerLocator;
+import org.jboss.ha.cachemanager.PojoCacheManager;
/**
* Utility methods related to JBoss distributed sessions.
@@ -61,6 +65,62 @@
Character.TYPE,
Class.class}));
+
+ public static PojoCache findPojoCache(String cacheConfigName) throws ClusteringNotSupportedException
+ {
+ PojoCacheManager pcm = getManagerForCache(cacheConfigName);
+
+ try
+ {
+ return pcm.getPojoCache(cacheConfigName, true);
+ }
+ catch (RuntimeException re)
+ {
+ throw re;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Problem accessing cache " + cacheConfigName, e);
+ }
+ }
+
+ public static Cache findPlainCache(String cacheConfigName) throws ClusteringNotSupportedException
+ {
+ PojoCacheManager pcm = getManagerForCache(cacheConfigName);
+
+ try
+ {
+ return pcm.getCache(cacheConfigName, true);
+ }
+ catch (RuntimeException re)
+ {
+ throw re;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Problem accessing cache " + cacheConfigName, e);
+ }
+ }
+
+ private static PojoCacheManager getManagerForCache(String cacheConfigName)
+ throws ClusteringNotSupportedException
+ {
+ PojoCacheManager pcm = null;
+ try
+ {
+ pcm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ }
+ catch (Throwable t)
+ {
+ throw new ClusteringNotSupportedException("Could not access CacheManager for JBossWeb clustering", t);
+ }
+
+ if (!pcm.getConfigurationNames().contains(cacheConfigName))
+ throw new IllegalStateException("CacheManager does not recognize config " + cacheConfigName);
+
+ return pcm;
+ }
+
/**
* Returns a session id with any trailing jvmRoute removed.
*
Modified: trunk/tomcat/src/resources/war-deployers-beans.xml
===================================================================
--- trunk/tomcat/src/resources/war-deployers-beans.xml 2008-04-21 00:57:30 UTC (rev 72467)
+++ trunk/tomcat/src/resources/war-deployers-beans.xml 2008-04-21 01:04:46 UTC (rev 72468)
@@ -35,10 +35,11 @@
<property name="relativeOrder">2002</property>
- <!--<property name="cacheSource">jboss.cache:service=TomcatClusteringCache</property>-->
+ <!-- Default session cache config used by distributable webapps -->
+ <property name="cacheName">standard-session-cache</property>
+ <!-- Default session cache config used by FIELD granularity distributable webapps -->
+ <property name="fieldGranularityCacheName">field-granularity-session-cache</property>
- <property name="cacheName">jboss.cache:service=TomcatClusteringCache</property>
-
<!--
The following two properties define when sessions are replicated to
the other nodes.
@@ -87,7 +88,7 @@
</bean>
<!--
- Adds to distributable webapps dependencies on any needed clustering services.
+ Adds to distributable webapps a dependency on needed clustering services.
With this deployer in place, webapps marked <distributable/> will not
deploy completely in the absence of needed clustering support services.
@@ -99,7 +100,12 @@
behavior of distributable webapps in the 'default' config in AS 4.x.
-->
<bean name="WebAppClusteringDependencyDeployer"
- class="org.jboss.web.tomcat.service.deployers.ClusteringDependencyDeployer"/>
+ class="org.jboss.web.tomcat.service.deployers.ClusteringDependencyDeployer">
+
+ <!-- Clustered webapps get their cache from this service -->
+ <property name="clusterCacheDependency">jboss.cache:service=CacheManager</property>
+
+ </bean>
<!-- The WebMetaData to service mbean deployer -->
<bean name="WarDeployer" class="org.jboss.web.tomcat.service.deployers.TomcatDeployer">
More information about the jboss-cvs-commits
mailing list