[jboss-cvs] JBossAS SVN: r80772 - in trunk: testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 10 18:19:18 EST 2008
Author: bstansberry at jboss.com
Date: 2008-11-10 18:19:18 -0500 (Mon, 10 Nov 2008)
New Revision: 80772
Modified:
trunk/component-matrix/pom.xml
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionBasedMaxUnreplicatedIntervalTestCase.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/testutil/CacheConfigTestSetup.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockDistributedCacheManager.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockJBossManager.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockSession.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/AttributeBasedClusteredSession.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedClusteredSession.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionBasedClusteredSession.java
Log:
[JBAS-5945] Break apart ClusteredSession.initAfterLoad()
[JBAS-6079] Upgrade ha-server-cache-spi and -jbc
[JBAS-6183] ATTRIBUTE granularity clustered session stores attribute in same JBC node as metadata
[JBAS-6184] Eliminate a JBC Fqn level in clustered session caching
[JBAS-6186] Use JBossWebMetaData to drive DistributedCacheManagerFactory
Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/component-matrix/pom.xml 2008-11-10 23:19:18 UTC (rev 80772)
@@ -64,8 +64,8 @@
<version.org.jboss.cache.core>3.0.0.CR4</version.org.jboss.cache.core>
<version.org.jboss.cache.pojo>3.0.0.CR4</version.org.jboss.cache.pojo>
<version.org.jboss.cluster>1.1.0.GA</version.org.jboss.cluster>
- <version.org.jboss.cluster.cache.spi>1.0.0.GA</version.org.jboss.cluster.cache.spi>
- <version.org.jboss.cluster.cache.jbc>1.0.1.CR1</version.org.jboss.cluster.cache.jbc>
+ <version.org.jboss.cluster.cache.spi>1.1.0.GA</version.org.jboss.cluster.cache.spi>
+ <version.org.jboss.cluster.cache.jbc>1.1.0.GA</version.org.jboss.cluster.cache.jbc>
<version.org.jboss.integration>5.0.1.GA</version.org.jboss.integration>
<version.org.jboss.jbossxb>2.0.0.GA</version.org.jboss.jbossxb>
<version.org.jboss.metadata>1.0.0.CR5</version.org.jboss.metadata>
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionBasedMaxUnreplicatedIntervalTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionBasedMaxUnreplicatedIntervalTestCase.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionBasedMaxUnreplicatedIntervalTestCase.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -39,12 +39,11 @@
import org.jboss.test.JBossTestCase;
import org.jboss.test.cluster.testutil.CacheConfigTestSetup;
import org.jboss.test.cluster.testutil.SessionTestUtil;
+import org.jboss.test.cluster.web.CacheHelper;
import org.jboss.test.cluster.web.mocks.BasicRequestHandler;
import org.jboss.test.cluster.web.mocks.MutableObject;
import org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler;
import org.jboss.web.tomcat.service.session.JBossCacheManager;
-import org.jboss.web.tomcat.service.session.distributedcache.impl.jbc.JBossCacheService;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
/**
* Tests of handling of ClusteredSession.maxUnreplicatedInterval. This base
@@ -226,12 +225,12 @@
SetAttributesRequestHandler setHandler1 = new SetAttributesRequestHandler(allAttributes, false);
SessionTestUtil.invokeRequest(jbcm0, setHandler1, null);
- Fqn session1Fqn = Fqn.fromString("/JSESSION/localhost/" + warname + "/" + setHandler1.getSessionId());
+ Fqn session1Fqn = Fqn.fromString(SessionTestUtil.getSessionFqn(warname, setHandler1.getSessionId()));
SetAttributesRequestHandler setHandler2 = new SetAttributesRequestHandler(allAttributes, false);
SessionTestUtil.invokeRequest(jbcm0, setHandler2, null);
- Fqn session2Fqn = Fqn.fromString("/JSESSION/localhost/" + warname + "/" + setHandler2.getSessionId());
+ Fqn session2Fqn = Fqn.fromString(SessionTestUtil.getSessionFqn(warname, setHandler2.getSessionId()));
// Overage the sessions
Thread.sleep(3010);
@@ -239,8 +238,8 @@
jbcm1.backgroundProcess();
// Confirm they are still there
// FIXME -- avoid direct cache operations
- assertNotNull(pojoCaches[1].getCache().get(session1Fqn, DistributedCacheManager.VERSION_KEY));
- assertNotNull(pojoCaches[1].getCache().get(session2Fqn, DistributedCacheManager.VERSION_KEY));
+ assertNotNull(pojoCaches[1].getCache().get(session1Fqn, CacheHelper.VERSION_KEY));
+ assertNotNull(pojoCaches[1].getCache().get(session2Fqn, CacheHelper.VERSION_KEY));
// Access one to prove it gets expired once the manager can see its real timestamp
BasicRequestHandler getHandler = new BasicRequestHandler(allAttributes.keySet(), false);
@@ -253,7 +252,7 @@
// one is still there and overaged. Try to force it out
jbcm1.backgroundProcess();
// FIXME -- avoid direct cache operations
- assertNull(pojoCaches[1].getCache().get(session2Fqn, JBossCacheService.VERSION_KEY));
+ assertNull(pojoCaches[1].getCache().get(session2Fqn, CacheHelper.VERSION_KEY));
}
protected JBossCacheManager[] getCacheManagers(String warname, int maxInactive, int maxUnreplicated)
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-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -86,12 +86,13 @@
String sessionID = getSessionID(client, servers_[0]);
// Strip off the jvmRoute, if there is one
sessionID = stripJvmRoute(sessionID);
- String sessionFqn = "/JSESSION/localhost" + warName_ + sessionID;
+ String sessionFqn = SessionTestUtil.getSessionFqn(warName_.replaceAll("/", ""), sessionID);
MBeanServerConnection[] adaptors = getAdaptors();
// Get the session from the cache
Object origVersion = SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn);
+ assertNotNull("sessionID has an original version", origVersion);
// Modify the POJO stored in the session, but don't touch the
// session attributes (a reference to the POJO is stored in the
@@ -118,8 +119,7 @@
}
// Should match the one on server0
- assertTrue("Session body was replicated",
- newVersion.equals(replVersion));
+ assertEquals("Session body was replicated", newVersion, replVersion);
}
public void testObserverRemoval() throws Exception
@@ -138,7 +138,7 @@
String sessionID = getSessionID(client, servers_[0]);
// Strip off the jvmRoute, if there is one
sessionID = stripJvmRoute(sessionID);
- String sessionFqn = "/JSESSION/localhost" + warName_ + sessionID;
+ String sessionFqn = SessionTestUtil.getSessionFqn(warName_.replaceAll("/", ""), sessionID);
this.sleepThread(DEFAULT_SLEEP);
@@ -157,6 +157,7 @@
// Get the session from the cache
Object origVersion = SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn);
+ assertNotNull("sessionID has an original version", origVersion);
// Modify the POJO that was originally stored in the session
// (a reference to the POJO is stored in the servlet context)
@@ -207,5 +208,4 @@
replVersion, newReplVersion);
}
-
}
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-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -109,8 +109,8 @@
adaptor0_ = adaptors[0];
adaptor1_ = adaptors[1];
- Object[] names = {"JSESSION", "localhost", getWarName() };
- Fqn fqn = new Fqn(names);
+ Object[] names = {"JSESSION", SessionTestUtil.getContextHostPath("localhost", getWarName()) };
+ Fqn fqn = Fqn.fromElements(names);
warFqn_ = fqn.toString();
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -77,10 +77,10 @@
try
{
jgSupport.setUpProperties();
-
+ long now = System.currentTimeMillis();
for (int i = 0; i < pojoCaches.length; i++)
{
- String cacheStore = (passivationDir == null ? null : new File(passivationDir, String.valueOf(i)).getAbsolutePath());
+ String cacheStore = (passivationDir == null ? null : new File(passivationDir, String.valueOf( now + i)).getAbsolutePath());
pojoCaches[i] = SessionTestUtil.createCache(local, cacheStore, totalReplication, marshalling, null);
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -327,6 +327,16 @@
{
return Boolean.parseBoolean(System.getProperty("jbosstest.cluster.web.cache.br", "false"));
}
+
+ public static String getSessionFqn(String contextPath, String sessionId)
+ {
+ return "/JSESSION/" + SessionTestUtil.getContextHostPath("localhost", contextPath) + "/" + sessionId;
+ }
+
+ public static String getContextHostPath(String hostname, String contextPath)
+ {
+ return contextPath + "_" + hostname;
+ }
/**
* Loops, continually calling {@link #areCacheViewsComplete(org.jboss.cache.Cache[])}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -25,6 +25,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.management.ObjectName;
@@ -62,7 +63,7 @@
public static final ObjectName OBJECT_NAME =
ObjectNameFactory.create("jboss.test:service=WebTestCacheHelper");
- private static final String VERSION_KEY = "V";
+ public static final Integer VERSION_KEY = new Integer(0);
private String cacheConfigName;
private Cache cache;
@@ -108,7 +109,8 @@
public Object getSessionVersion(String sessionFqn)
{
- return getCache().get(Fqn.fromString(sessionFqn), VERSION_KEY);
+ AtomicInteger version = (AtomicInteger) getCache().get(Fqn.fromString(sessionFqn), VERSION_KEY);
+ return version == null ? null : new Integer(version.get());
}
public Object getBuddySessionVersion(String sessionFqn) throws Exception
@@ -124,7 +126,8 @@
Node session = buddy.getChild(fqn);
if (session != null)
{
- result = session.get(VERSION_KEY);
+ AtomicInteger version = (AtomicInteger) session.get(VERSION_KEY);
+ result = version == null ? null : new Integer(version.get());
break;
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockDistributedCacheManager.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockDistributedCacheManager.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockDistributedCacheManager.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -28,14 +28,14 @@
import org.jboss.web.tomcat.service.session.distributedcache.spi.BatchingManager;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSession;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.FieldBasedDistributedCacheManager;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionData;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
/**
* @author Brian Stansberry
*
*/
-public class MockDistributedCacheManager implements FieldBasedDistributedCacheManager
+public class MockDistributedCacheManager implements DistributedCacheManager
{
public static final MockDistributedCacheManager INSTANCE = new MockDistributedCacheManager();
@@ -70,9 +70,9 @@
return null;
}
- public Map getSessionData(String realId, String dataOwner)
+ public DistributableSessionData getSessionData(String realId, String dataOwner, boolean includeAttributes)
{
- return Collections.EMPTY_MAP;
+ return null;
}
public Map<String, String> getSessionIds()
@@ -90,7 +90,7 @@
return null;
}
- public void putAttribute(String realId, Map map)
+ public void putAttribute(String realId, Map<String, Object> map)
{
// no-op
}
@@ -100,7 +100,7 @@
// no-op
}
- public void putSession(String realId, DistributableSession session)
+ public void putSession(DistributableSession session)
{
// no-op
}
@@ -110,6 +110,11 @@
return null;
}
+ public void removeAttributeLocal(String realId, String key)
+ {
+ // no-op
+ }
+
public void removeAttributes(String realId)
{
// no-op
@@ -120,12 +125,12 @@
// no-op
}
- public void removeSession(String realId, boolean removeRegion)
+ public void removeSession(String realId)
{
// no-op
}
- public void removeSessionLocal(String realId, boolean removeRegion)
+ public void removeSessionLocal(String realId)
{
// no-op
}
@@ -135,7 +140,7 @@
// no-op
}
- public void start(ClassLoader tcl, LocalDistributableSessionManager manager)
+ public void start()
{
// no-op
}
@@ -145,34 +150,14 @@
// no-op
}
- public Object getPojo(String realId, String key)
+ public boolean getSupportsAttributeOperations()
{
- return null;
+ return true;
}
- public Set getPojoKeys(String realId)
+ public void sessionCreated(DistributableSession session)
{
- return Collections.EMPTY_SET;
- }
-
- public Object removePojo(String realId, String key)
- {
- return null;
- }
-
- public void removePojoLocal(String realId, String key)
- {
// no-op
}
- public void removePojosLocal(String realId)
- {
- // no-op
- }
-
- public Object setPojo(String realId, String key, Object pojo, DistributableSession session)
- {
- return null;
- }
-
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockJBossManager.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockJBossManager.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockJBossManager.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -34,7 +34,6 @@
import org.jboss.web.tomcat.service.session.ClusteredManager;
import org.jboss.web.tomcat.service.session.distributedcache.spi.ClusteringNotSupportedException;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.FieldBasedDistributedCacheManager;
import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy;
import org.jboss.web.tomcat.service.session.notification.LegacyClusteredSessionNotificationPolicy;
@@ -53,8 +52,7 @@
*
*/
public MockJBossManager()
- {
- // TODO Auto-generated constructor stub
+ {
}
public String getJvmRoute()
@@ -257,11 +255,6 @@
return MockDistributedCacheManager.INSTANCE;
}
- public FieldBasedDistributedCacheManager getFieldBasedDistributedCacheManager()
- {
- return MockDistributedCacheManager.INSTANCE;
- }
-
public int getMaxUnreplicatedInterval()
{
return -1;
@@ -269,7 +262,6 @@
public ClusteredSessionNotificationPolicy getNotificationPolicy()
{
- // TODO Auto-generated method stub
return new LegacyClusteredSessionNotificationPolicy();
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockSession.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockSession.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockSession.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -25,7 +25,6 @@
import javax.servlet.http.HttpSession;
import org.apache.catalina.session.StandardSessionFacade;
-import org.jboss.web.tomcat.service.session.ClusteredManager;
import org.jboss.web.tomcat.service.session.ClusteredSession;
import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCause;
@@ -82,12 +81,6 @@
}
@Override
- public void initAfterLoad(ClusteredManager manager, ClusteredSessionNotificationCause cause)
- {
-
- }
-
- @Override
public void processSessionReplication()
{
}
@@ -100,11 +93,6 @@
@Override
public void removeMyselfLocal()
{
- }
-
- @Override
- protected void populateAttributes()
- {
}
@Override
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/AttributeBasedClusteredSession.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/AttributeBasedClusteredSession.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/AttributeBasedClusteredSession.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -42,7 +42,7 @@
* @version $Revision: 56542 $
*/
class AttributeBasedClusteredSession
- extends ClusteredSession<DistributedCacheManager>
+ extends ClusteredSession
{
static final long serialVersionUID = -5625209785550936713L;
/**
@@ -89,46 +89,25 @@
clearAttrChangedMaps();
}
- @Override
- public void removeMyself()
- {
- // This is a shortcut to remove session and it's child attributes.
- getDistributedCacheManager().removeSession(getRealId(), false);
- }
-
- @Override
- public void removeMyselfLocal()
- {
- // Need to evict attribute first before session to clean up everything.
- // BRIAN -- the attributes *are* already evicted, but we leave the
- // removeAttributesLocal 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.
- getDistributedCacheManager().removeAttributesLocal(getRealId());
- getDistributedCacheManager().removeSessionLocal(getRealId(), false);
- }
-
// -------------------------------------------- Overridden Protected Methods
- /**
- * Populate the attributes stored in the distributed store to local transient ones.
- */
- @Override
- protected void populateAttributes()
- {
- Map map = getDistributedCacheManager().getAttributes(getRealId());
- Map<String, Object> attributes = getAttributesInternal();
-
- // Preserve any local attributes that were excluded from replication
- Map excluded = removeExcludedAttributes(attributes);
- if (excluded != null)
- map.putAll(excluded);
-
- attributes.clear();
- attributes.putAll(map);
- attrModifiedMap_.clear();
- attrRemovedMap_.clear();
- }
+// /**
+// * Populate the attributes stored in the distributed store to local transient ones.
+// */
+// @Override
+// protected void populateAttributes(Map<String, Object> distributedCacheAttributes)
+// {
+// Map<String, Object> existing = getAttributesInternal();
+// Map<String, Object> excluded = removeExcludedAttributes(existing);
+// existing.clear();
+//
+// existing.putAll(distributedCacheAttributes);
+// if (excluded != null)
+// existing.putAll(excluded);
+//
+// attrModifiedMap_.clear();
+// attrRemovedMap_.clear();
+// }
@Override
protected Object getAttributeInternal(String name)
@@ -147,8 +126,8 @@
@Override
protected Object removeAttributeInternal(String name,
- boolean localCall,
- boolean localOnly)
+ boolean localCall,
+ boolean localOnly)
{
Object result = getAttributesInternal().remove(name);
if (localCall && !replicationExcludes.contains(name))
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -55,6 +55,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
@@ -79,13 +80,12 @@
import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.ReplicationTrigger;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSession;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionData;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionTimestamp;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
import org.jboss.web.tomcat.service.session.notification.ClusteredSessionManagementStatus;
import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCause;
import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy;
-import org.jboss.web.tomcat.service.session.notification.LegacyClusteredSessionNotificationPolicy;
/**
* Abstract base class for session clustering based on StandardSession. Different session
@@ -96,7 +96,7 @@
*
* @version $Revision: 58585 $
*/
-public abstract class ClusteredSession<D extends DistributedCacheManager>
+public abstract class ClusteredSession
implements HttpSession, Session, DistributableSession
{
// --------------------------------------------------------------- Constants
@@ -169,7 +169,7 @@
/**
* The collection of user data attributes associated with this Session.
*/
- private Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
+ private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
/**
@@ -203,7 +203,7 @@
* certain IllegalStateException tests. NOTE: This value is not
* included in the serialized version of this object.
*/
- private transient boolean expiring = false;
+ private volatile transient boolean expiring = false;
/**
@@ -222,7 +222,7 @@
/**
* The last accessed time for this Session.
*/
- private long lastAccessedTime = creationTime;
+ private volatile long lastAccessedTime = creationTime;
/**
@@ -239,7 +239,7 @@
/**
* Our proxy to the distributed cache.
*/
- private transient D distributedCacheManager;
+ private transient DistributedCacheManager distributedCacheManager;
/**
* The maximum time interval, in seconds, between client requests before
@@ -258,7 +258,7 @@
/**
* Flag indicating whether this session is valid or not.
*/
- private boolean isValid = false;
+ private volatile boolean isValid = false;
/**
@@ -266,7 +266,7 @@
* and event listeners. <b>IMPLEMENTATION NOTE:</b> This object is
* <em>not</em> saved and restored across session serializations!
*/
- private transient Map notes = new Hashtable();
+ private final transient Map notes = new Hashtable();
/**
@@ -288,13 +288,13 @@
/**
* The current accessed time for this session.
*/
- private long thisAccessedTime = creationTime;
+ private volatile long thisAccessedTime = creationTime;
/**
* The access count for this session.
*/
- private transient AtomicInteger accessCount = null;
+ private final transient AtomicInteger accessCount;
/**
* Policy controlling whether reading/writing attributes requires
@@ -320,26 +320,26 @@
* we can store it in JBoss Cache w/o concern that a transaction
* rollback will revert the cached ref to an older object.
*/
- private transient DistributableSessionTimestamp timestamp = new DistributableSessionTimestamp();
+ private final transient AtomicLong timestamp = new AtomicLong(0);
/**
* Object wrapping other metadata for this session. Create once and mutate so
* we can store it in JBoss Cache w/o concern that a transaction
* rollback will revert the cached ref to an older object.
*/
- private transient DistributableSessionMetadata metadata = new DistributableSessionMetadata();
+ private volatile transient DistributableSessionMetadata metadata = new DistributableSessionMetadata();
/**
* The last version that was passed to {@link #setDistributedVersion} or
* <code>0</code> if <code>setIsOutdated(false)</code> was subsequently called.
*/
- private transient int outdatedVersion;
+ private volatile transient int outdatedVersion;
/**
* The last time {@link #setIsOutdated setIsOutdated(true)} was called or
* <code>0</code> if <code>setIsOutdated(false)</code> was subsequently called.
*/
- private transient long outdatedTime;
+ private volatile transient long outdatedTime;
/**
* Version number to track cache invalidation. If any new version number is
@@ -361,7 +361,7 @@
/**
* Timestamp when we were last replicated.
*/
- private transient long lastReplicated;
+ private volatile transient long lastReplicated;
/**
* Maximum number of milliseconds this session
@@ -405,21 +405,12 @@
protected ClusteredSession(ClusteredManager manager)
{
super();
- this.manager = manager;
-
+
// Initialize access count
- if (ACTIVITY_CHECK) {
- accessCount = new AtomicInteger();
- }
-
- invalidationPolicy = manager.getReplicationTrigger();
- this.useJK = manager.getUseJK();
+ accessCount = ACTIVITY_CHECK ? new AtomicInteger() : null;
this.firstAccess = true;
- int maxUnrep = manager.getMaxUnreplicatedInterval() * 1000;
- setMaxUnreplicatedInterval(maxUnrep);
- this.notificationPolicy = manager.getNotificationPolicy();
- establishDistributedCacheManager();
+ setManager(manager);
}
// ---------------------------------------------------------------- Session
@@ -518,6 +509,15 @@
throw new IllegalArgumentException("manager must implement ClusteredManager");
this.manager = (ClusteredManager) manager;
+
+
+ this.invalidationPolicy = this.manager.getReplicationTrigger();
+ this.useJK = this.manager.getUseJK();
+
+ int maxUnrep = this.manager.getMaxUnreplicatedInterval() * 1000;
+ setMaxUnreplicatedInterval(maxUnrep);
+ this.notificationPolicy = this.manager.getNotificationPolicy();
+ establishDistributedCacheManager();
}
public int getMaxInactiveInterval()
@@ -1011,6 +1011,16 @@
}
// ---------------------------------------------------- DistributableSession
+
+ /**
+ * Gets the session id with any appended jvmRoute info removed.
+ *
+ * @see #getUseJK()
+ */
+ public String getRealId()
+ {
+ return realId;
+ }
public boolean getCreateRegionForSession()
{
@@ -1039,9 +1049,9 @@
// can override.
}
- public int getVersion()
+ public AtomicInteger getVersion()
{
- return version.get();
+ return version;
}
public boolean getMustReplicateTimestamp()
@@ -1060,9 +1070,9 @@
return exceeds;
}
- public DistributableSessionTimestamp getSessionTimestamp()
+ public AtomicLong getSessionTimestamp()
{
- this.timestamp.setTimestamp(this.thisAccessedTime);
+ this.timestamp.set(this.thisAccessedTime);
return this.timestamp;
}
@@ -1097,24 +1107,27 @@
return null;
}
- public void update(Integer version, DistributableSessionTimestamp timestamp,
- DistributableSessionMetadata metadata, Map attributes)
+ /**
+ * {@inheritDoc}
+ */
+ public void update(DistributableSessionData sessionData)
{
- assert version != null : "version is null";
- assert timestamp != null : "timestamp is null";
assert metadata != null : "metadata is null";
- this.version.set(version.intValue());
+ this.version.set(sessionData.getVersion());
- this.lastAccessedTime = this.thisAccessedTime = timestamp.getTimestamp();
- this.timestamp = timestamp;
+ long ts = sessionData.getTimestamp();
+ this.lastAccessedTime = this.thisAccessedTime = ts;
+ this.timestamp.set(ts);
- this.id = metadata.getId();
- this.creationTime = metadata.getCreationTime();
- this.maxInactiveInterval = metadata.getMaxInactiveInterval();
- this.isNew = metadata.isNew();
- this.isValid = metadata.isValid();
- this.metadata = metadata;
+ DistributableSessionMetadata md = sessionData.getMetadata();
+ // TODO -- get rid of these field and delegate to metadata
+ this.id = md.getId();
+ this.creationTime = md.getCreationTime();
+ this.maxInactiveInterval = md.getMaxInactiveInterval();
+ this.isNew = md.isNew();
+ this.isValid = md.isValid();
+ this.metadata = md;
// Get our id without any jvmRoute appended
parseRealId(id);
@@ -1134,12 +1147,12 @@
// a heavy cost.
this.lastReplicated = this.creationTime;
- this.notificationPolicy = new LegacyClusteredSessionNotificationPolicy();
-
this.clusterStatus = new ClusteredSessionManagementStatus(this.realId, true, null, null);
checkAlwaysReplicateTimestamp();
+ populateAttributes(sessionData.getSessionAttributes());
+
// TODO uncomment when work on JBAS-1900 is completed
// // Session notes -- for FORM auth apps, allow replicated session
// // to be used without requiring a new login
@@ -1164,42 +1177,13 @@
// super.removeNote(Constants.SESS_PASSWORD_NOTE);
// }
- // we ignore the attributes
+ // We are no longer outdated vis a vis distributed cache
+ clearOutdated();
}
// ------------------------------------------------------------------ Public
/**
- * This is called after loading a session to initialize the transient values.
- *
- * @param manager
- * @param cause the cause of the load
- */
- public void initAfterLoad(ClusteredManager manager, ClusteredSessionNotificationCause cause)
- {
- // Our manager, notification policy and proxy may have been lost
- // if we were replicated, so reestablish them
- this.manager = manager;
- this.notificationPolicy = manager.getNotificationPolicy();
- establishDistributedCacheManager();
-
- // Since attribute map may be transient, we may need to populate it
- // from the underlying store.
- populateAttributes();
-
- if (cause == ClusteredSessionNotificationCause.ACTIVATION)
- {
- this.needsPostReplicateActivation = true;
- }
-
- // Notify all attributes of type HttpSessionActivationListener (SRV 7.7.2)
- this.notifyDidActivate(cause);
-
- // We are no longer outdated vis a vis distributed cache
- clearOutdated();
- }
-
- /**
* Increment our version and propagate ourself to the distributed cache.
*/
public synchronized void processSessionReplication()
@@ -1207,11 +1191,11 @@
// Replicate the session.
if (log.isTraceEnabled())
{
- log.trace("processSessionRepl(): session is dirty. Will increment " +
+ log.trace("processSessionReplication(): session is dirty. Will increment " +
"version from: " + getVersion() + " and replicate.");
}
version.incrementAndGet();
- distributedCacheManager.putSession(getRealId(), this);
+ distributedCacheManager.putSession(this);
// Allow subclasses to replicate attributes if needed
replicateAttributes();
@@ -1225,21 +1209,17 @@
/**
* Remove myself from the distributed cache.
*/
- public abstract void removeMyself();
+ public void removeMyself()
+ {
+ getDistributedCacheManager().removeSession(getRealId());
+ }
/**
* Remove myself from the <t>local</t> instance of the distributed cache.
*/
- public abstract void removeMyselfLocal();
-
- /**
- * Gets the session id with any appended jvmRoute info removed.
- *
- * @see #getUseJK()
- */
- public String getRealId()
+ public void removeMyselfLocal()
{
- return realId;
+ getDistributedCacheManager().removeSessionLocal(getRealId());
}
/**
@@ -1315,7 +1295,7 @@
*/
public boolean setVersionFromDistributedCache(int version)
{
- boolean outdated = getVersion() < version;
+ boolean outdated = getVersion().get() < version;
if (outdated)
{
this.outdatedVersion = version;
@@ -1610,6 +1590,11 @@
*/
public void notifyDidActivate(ClusteredSessionNotificationCause cause)
{
+ if (cause == ClusteredSessionNotificationCause.ACTIVATION)
+ {
+ this.needsPostReplicateActivation = true;
+ }
+
// Notify interested session event listeners
fireSessionEvent(Session.SESSION_ACTIVATED_EVENT, null);
@@ -1677,17 +1662,39 @@
// ----------------------------------------------------- Protected Methods
- protected abstract Object getAttributeInternal(String name);
-
protected abstract Object setAttributeInternal(String name, Object value);
protected abstract Object removeAttributeInternal(String name, boolean localCall, boolean localOnly);
+
+ protected Object getAttributeInternal(String name)
+ {
+ Object result = getAttributesInternal().get(name);
+
+ // Do dirty check even if result is null, as w/ SET_AND_GET null
+ // still makes us dirty (ensures timely replication w/o using ACCESS)
+ if (isGetDirty(result))
+ {
+ sessionAttributesDirty();
+ }
+
+ return result;
+ }
/**
* Extension point for subclasses to load the attribute map from the
* distributed cache.
*/
- protected abstract void populateAttributes();
+ protected void populateAttributes(Map<String, Object> distributedCacheAttributes)
+ {
+ Map<String, Object> existing = getAttributesInternal();
+ Map<String, Object> excluded = removeExcludedAttributes(existing);
+
+ existing.clear();
+
+ existing.putAll(distributedCacheAttributes);
+ if (excluded != null)
+ existing.putAll(excluded);
+ }
protected final Map<String, Object> getAttributesInternal()
{
@@ -1699,12 +1706,12 @@
return manager;
}
- protected final D getDistributedCacheManager()
+ protected final DistributedCacheManager getDistributedCacheManager()
{
return distributedCacheManager;
}
- protected final void setDistributedCacheManager(D distributedCacheManager)
+ protected final void setDistributedCacheManager(DistributedCacheManager distributedCacheManager)
{
this.distributedCacheManager = distributedCacheManager;
}
@@ -1791,7 +1798,7 @@
{
if (distributedCacheManager == null)
{
- distributedCacheManager = (D) getManagerInternal().getDistributedCacheManager();
+ distributedCacheManager = getManagerInternal().getDistributedCacheManager();
// still null???
if (distributedCacheManager == null)
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-11-10 22:54:45 UTC (rev 80771)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedClusteredSession.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -22,16 +22,9 @@
package org.jboss.web.tomcat.service.session;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
-import javax.servlet.http.HttpSessionActivationListener;
-
import org.jboss.aop.Advised;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.FieldBasedDistributedCacheManager;
-
/**
* <p>
* Implementation of a clustered session for JBossCacheManager. The replication granularity
@@ -56,7 +49,7 @@
* @version $Revision: 58586 $
*/
class FieldBasedClusteredSession
- extends ClusteredSession<FieldBasedDistributedCacheManager>
+ extends ClusteredSession
{
/** The serialVersionUID */
private static final long serialVersionUID = 8347544395334247623L;
@@ -121,121 +114,9 @@
needRegion_ = false;
}
- // The superclass version of processSessionRepl is fine; it will remove
- // the session metadata, and any attribute changes have been picked up
- // for replication as they were made; no need to do anything here
-// public synchronized void processSessionRepl()
-// {
-// super.processSessionRepl();
-// }
- @Override
- public void removeMyself()
- {
- // This is a shortcut to remove session and it's child attributes.
- // Note that there is no need to remove attribute first since caller
- // will do that already.
- getDistributedCacheManager().removeSession(getRealId(), true);
- }
-
- @Override
- public void removeMyselfLocal()
- {
- // Need to evict attribute first before session to clean up everything.
- // Note that there is no need to remove attributes first since caller
- // will do that already.
- // BRIAN -- the attributes *are* already evicted, but we leave the
- // 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.
- String myRealId = getRealId();
- getDistributedCacheManager().removePojosLocal(myRealId);
- getDistributedCacheManager().removeSessionLocal(myRealId, true);
- }
-
// --------------------------------------------- Overridden Protected Methods
-
- /**
- * Populate the attributes stored in the distributed store to the local
- * transient map. Add ourself as an Observer to newly found attributes and
- * remove ourself as an Observer to existing attributes that are no longer
- * in the distributed store.
- */
- @Override
- protected void populateAttributes()
- {
- Map<String, Object> attributes = getAttributesInternal();
- String myRealId = getRealId();
-
- // Preserve any local attributes that were excluded from replication
- Map excluded = removeExcludedAttributes(attributes);
-
- FieldBasedDistributedCacheManager dcm = getDistributedCacheManager();
- Set keys = dcm.getPojoKeys(myRealId);
- Set oldKeys = new HashSet(attributes.keySet());
-
- // Since we are going to touch each attribute, might as well
- // check if we have any HttpSessionActivationListener
- boolean hasListener = false;
-
- if (keys != null)
- {
- oldKeys.removeAll(keys); // only keys that no longer exist are left
- for (Iterator it = keys.iterator(); it.hasNext(); )
- {
- String name = (String) it.next();
-
- Object newAttrib = dcm.getPojo(myRealId, name);
- if (newAttrib != null)
- {
- attributes.put(name, newAttrib);
-
- // Check if we have a listener
- if (newAttrib instanceof HttpSessionActivationListener)
- hasListener = true;
- }
- else
- {
- // This shouldn't happen -- if we had a key, newAttrib s/b not null
- attributes.remove(name);
- }
- }
- }
-
- setHasActivationListener(hasListener);
-
- // Cycle through remaining old keys and remove them
- for (Iterator it = oldKeys.iterator(); it.hasNext(); )
- {
- attributes.remove(it.next());
- }
-
- // Restore any excluded attributes
- if (excluded != null)
- attributes.putAll(excluded);
- }
-
- @Override
- protected Object getAttributeInternal(String name)
- {
- // Check the local map first.
- Object result = getAttributesInternal().get(name);
-
- // NOTE -- we no longer check with the store. Attributes are only
- // loaded from store during populateAttributes() call at beginning
- // of request when we notice we are outdated.
-
- // Do dirty check even if result is null, as w/ SET_AND_GET null
- // still makes us dirty (ensures timely replication w/o using ACCESS)
- if (isGetDirty(result))
- {
- sessionAttributesDirty();
- }
-
- return result;
- }
-
/**
* Overrides the superclass to treat classes implementing Subject
* as "immutable", since as an Observer we will detect any changes
@@ -256,9 +137,9 @@
if (localCall && !replicationExcludes.contains(name))
{
if (localOnly)
- getDistributedCacheManager().removePojoLocal(getRealId(), name);
+ getDistributedCacheManager().removeAttributeLocal(getRealId(), name);
else
- getDistributedCacheManager().removePojo(getRealId(), name);
+ getDistributedCacheManager().removeAttribute(getRealId(), name);
sessionAttributesDirty();
}
@@ -286,20 +167,16 @@
@Override
protected Object setAttributeInternal(String key, Object value)
{
- Object oldVal = null;
if (!replicationExcludes.contains(key))
{
String myRealId = getRealId();
- oldVal = getDistributedCacheManager().setPojo(myRealId, key, value, this);
+ getDistributedCacheManager().putAttribute(myRealId, key, value);
- if(value != null)
+ // Special case for Collection classes.
+ if( value instanceof Map || value instanceof Collection)
{
- // Special case for Collection classes.
- if( value instanceof Map || value instanceof Collection)
- {
- // We need to obtain the proxy first.
- value = getDistributedCacheManager().getPojo(myRealId, key);
- }
+ // We need to obtain the proxy first.
+ value = getDistributedCacheManager().getAttribute(myRealId, key);
}
// Only mark session dirty if we can replicate the attribute
@@ -307,8 +184,6 @@
}
// Still need to put it in the map to track locally.
- oldVal = getAttributesInternal().put(key, value);
-
- return oldVal;
+ return getAttributesInternal().put(key, value);
}
}
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-11-10 22:54:45 UTC (rev 80771)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -40,6 +40,7 @@
import org.apache.catalina.Session;
import org.apache.catalina.Valve;
import org.apache.catalina.core.ContainerBase;
+import org.jboss.logging.Logger;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.jboss.ReplicationConfig;
import org.jboss.metadata.web.jboss.ReplicationGranularity;
@@ -48,8 +49,8 @@
import org.jboss.util.loading.ContextClassLoaderSwitcher;
import org.jboss.web.tomcat.service.session.distributedcache.spi.BatchingManager;
import org.jboss.web.tomcat.service.session.distributedcache.spi.ClusteringNotSupportedException;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionData;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionTimestamp;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactory;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManagerFactoryFactory;
@@ -138,6 +139,8 @@
private String notificationPolicyClass_;
private ClusteredSessionNotificationPolicy notificationPolicy_;
+
+ private ReplicationConfig replicationConfig_;
// ---------------------------------------------------------- Constructors
@@ -168,29 +171,26 @@
{
super.init(name, webMetaData);
- ReplicationConfig repCfg = webMetaData.getReplicationConfig();
- if (repCfg != null)
- {
- replicationTrigger_ = repCfg.getReplicationTrigger();
- replicationGranularity_ = repCfg.getReplicationGranularity();
- }
+ this.replicationConfig_ = webMetaData.getReplicationConfig();
+ this.replicationTrigger_ = replicationConfig_.getReplicationTrigger();
+ this.replicationGranularity_ = replicationConfig_.getReplicationGranularity();
// Only configure JK usage if it was explicitly set; otherwise
// wait until we're starting when we can check for a jvmRoute
// in our containing Engine
- Boolean jk = repCfg.getUseJK();
+ Boolean jk = replicationConfig_.getUseJK();
if (jk != null)
{
this.useJK_ = jk;
}
- Boolean batch = repCfg.getReplicationFieldBatchMode();
+ Boolean batch = replicationConfig_.getReplicationFieldBatchMode();
this.replicationFieldBatchMode_ = (batch == null ? Boolean.TRUE : batch);
- setSnapshotMode(repCfg.getSnapshotMode());
- Integer snapshotInt = repCfg.getSnapshotInterval();
+ setSnapshotMode(replicationConfig_.getSnapshotMode());
+ Integer snapshotInt = replicationConfig_.getSnapshotInterval();
setSnapshotInterval(snapshotInt == null ? 0 : snapshotInt.intValue());
- Integer maxUnrep = repCfg.getMaxUnreplicatedInterval();
+ Integer maxUnrep = replicationConfig_.getMaxUnreplicatedInterval();
if (maxUnrep != null)
{
this.maxUnreplicatedInterval_ = maxUnrep.intValue();
@@ -203,9 +203,9 @@
" and snapshotMode is " + snapshotMode_ +
" and snapshotInterval is " + snapshotInterval_);
- this.cacheConfigName_ = repCfg.getCacheName();
+ this.cacheConfigName_ = replicationConfig_.getCacheName();
- this.notificationPolicyClass_ = repCfg.getSessionNotificationPolicy();
+ this.notificationPolicyClass_ = replicationConfig_.getSessionNotificationPolicy();
// Initing the proxy would be better in start, but we do it here so we
// can detect ClusteringNotSupportedException at this deploy stage
@@ -406,6 +406,9 @@
}
session.setId(sessionId); // Setting the id leads to a call to add()
+
+ getDistributedCacheManager().sessionCreated(session);
+
session.tellNew(ClusteredSessionNotificationCause.CREATE);
if (trace_)
@@ -618,6 +621,9 @@
@Override
public void start() throws LifecycleException
{
+ // Identify ourself more clearly
+ log_ = Logger.getLogger(getClass().getName() + "." + getContainer().getName());
+
if (embedded_)
{
startEmbedded();
@@ -627,7 +633,7 @@
startUnembedded();
}
- log_.debug("JBossCacheManager for " + getContainer().getName() + " started");
+ log_.debug("Started");
}
/**
@@ -859,7 +865,7 @@
return reportSessionIds(ids);
}
- // -------------------------------- Callbacks from Distributed Caching Layer
+ // --------------------------------------- LocalDistributableSessionManager
public String getContextName()
{
@@ -871,6 +877,16 @@
return getContainer().getParent().getName();
}
+ public ClassLoader getApplicationClassLoader()
+ {
+ return tcl_;
+ }
+
+ public ReplicationConfig getReplicationConfig()
+ {
+ return replicationConfig_;
+ }
+
/**
* Notifies the manager that a session in the distributed cache has
* been invalidated
@@ -975,7 +991,7 @@
public boolean sessionChangedInDistributedCache(String realId,
String dataOwner,
int distributedVersion,
- DistributableSessionTimestamp timestamp,
+ long timestamp,
DistributableSessionMetadata metadata)
{
boolean updated = true;
@@ -994,10 +1010,9 @@
}
else
{
- long lastMod = timestamp == null ? System.currentTimeMillis() : timestamp.getTimestamp();
int maxLife = metadata == null ? getMaxInactiveInterval() : metadata.getMaxInactiveInterval();
- Object existing = unloadedSessions_.put(realId, new OwnedSessionUpdate(dataOwner, lastMod, maxLife, false));
+ Object existing = unloadedSessions_.put(realId, new OwnedSessionUpdate(dataOwner, timestamp, maxLife, false));
if (existing == null)
{
calcActiveSessions();
@@ -1491,7 +1506,7 @@
{
ClusteredSessionNotificationCause cause = passivated ? ClusteredSessionNotificationCause.ACTIVATION
: ClusteredSessionNotificationCause.FAILOVER;
- session.initAfterLoad(this, cause);
+ session.notifyDidActivate(cause);
}
}
catch (Exception ex)
@@ -1762,6 +1777,11 @@
// Create the JBossCacheService
try
{
+ if (replicationConfig_ == null)
+ {
+ synthesizeReplicationConfig();
+ }
+
if (proxy_ == null)
{
initCacheProxy();
@@ -1770,7 +1790,7 @@
// We need to pass the classloader that is associated with this
// web app so de-serialization will work correctly.
tcl_ = container_.getLoader().getClassLoader();
- proxy_.start(tcl_, this);
+ proxy_.start();
}
catch (Throwable t)
{
@@ -1815,15 +1835,22 @@
*/
private void initCacheProxy() throws ClusteringNotSupportedException
{
- if (ReplicationGranularity.FIELD == replicationGranularity_)
- {
- proxy_ = distributedCacheManagerFactory.getFieldBasedDistributedCacheManager(cacheConfigName_);
- }
- else
- {
- proxy_ = distributedCacheManagerFactory.getDistributedCacheManager(cacheConfigName_);
- }
+ proxy_ = distributedCacheManagerFactory.getDistributedCacheManager(this);
}
+
+ private void synthesizeReplicationConfig()
+ {
+ ReplicationConfig cfg = new ReplicationConfig();
+ cfg.setReplicationGranularity(replicationGranularity_);
+ cfg.setReplicationTrigger(replicationTrigger_);
+ cfg.setUseJK(useJK_);
+ cfg.setCacheName(cacheConfigName_);
+ cfg.setSnapshotMode(snapshotMode_);
+ cfg.setSnapshotInterval(Integer.valueOf(snapshotInterval_));
+ cfg.setMaxUnreplicatedInterval(Integer.valueOf(maxUnreplicatedInterval_));
+ cfg.setSessionNotificationPolicy(notificationPolicyClass_);
+ this.replicationConfig_ = cfg;
+ }
private void initClusteredSessionNotificationPolicy()
{
@@ -1871,13 +1898,13 @@
String realId = entry.getKey();
String owner = entry.getValue();
- DistributableSessionTimestamp ts = null;
+ long ts = -1;
DistributableSessionMetadata md = null;
try
{
- Map sessionData = proxy_.getSessionData(realId, owner);
- ts = (DistributableSessionTimestamp) sessionData.get(DistributedCacheManager.TIMESTAMP_KEY);
- md = (DistributableSessionMetadata) sessionData.get(DistributedCacheManager.METADATA_KEY);
+ DistributableSessionData sessionData = proxy_.getSessionData(realId, owner, false);
+ ts = sessionData.getTimestamp();
+ md = sessionData.getMetadata();
}
catch (Exception e)
{
@@ -1886,7 +1913,7 @@
log_.debug("Problem reading metadata for session " + realId + " -- " + e.toString());
}
- long lastMod = ts == null ? System.currentTimeMillis() : ts.getTimestamp();
+ long lastMod = ts == -1 ? System.currentTimeMillis() : ts;
int maxLife = md == null ? getMaxInactiveInterval() : md.getMaxInactiveInterval();
OwnedSessionUpdate osu = new OwnedSessionUpdate(owner, lastMod, maxLife, false);
@@ -2129,7 +2156,7 @@
}
else
{
- proxy_.removeSessionLocal(realId, false);
+ proxy_.removeSessionLocal(realId);
}
}
catch (Exception e)
@@ -2166,7 +2193,7 @@
initCacheProxy();
}
- proxy_.start(tcl_, this);
+ proxy_.start();
batchingManager = proxy_.getBatchingManager();
if(batchingManager == null)
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionBasedClusteredSession.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionBasedClusteredSession.java 2008-11-10 22:54:45 UTC (rev 80771)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/SessionBasedClusteredSession.java 2008-11-10 23:19:18 UTC (rev 80772)
@@ -24,11 +24,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionTimestamp;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
-
/**
* Implementation of a ClusteredSession where the replication granularity level
* is session based; that is, we replicate the entire attribute map whenever a
@@ -43,7 +39,7 @@
* @version $Revision: 56542 $
*/
class SessionBasedClusteredSession
- extends ClusteredSession<DistributedCacheManager>
+ extends ClusteredSession
{
static final long serialVersionUID = 3200976125245487256L;
@@ -69,17 +65,6 @@
return (info);
}
- @Override
- public void removeMyself()
- {
- getDistributedCacheManager().removeSession(getRealId(), false);
- }
-
- @Override
- public void removeMyselfLocal()
- {
- getDistributedCacheManager().removeSessionLocal(getRealId(), false);
- }
@Override
public Map<String, Object> getSessionAttributeMap()
@@ -89,54 +74,35 @@
return attrs;
}
- @Override
- public void update(Integer version, DistributableSessionTimestamp timestamp,
- DistributableSessionMetadata metadata, Map updatedAttrs)
- {
- // A new session may not have sent over any attributes
- if (updatedAttrs == null)
- {
- updatedAttrs = new HashMap();
- }
-
- super.update(version, timestamp, metadata, updatedAttrs);
-
- Map existing = getAttributesInternal();
- Map excluded = removeExcludedAttributes(existing);
- if (excluded != null)
- updatedAttrs.putAll(excluded);
- existing.clear();
-
- existing.putAll(updatedAttrs);
- }
-
// -------------------------------------------- Overridden Protected Methods
- /**
- * Does nothing -- all attributes are populated already
- */
- @Override
- protected void populateAttributes()
- {
- // no-op
- }
+// @Override
+// protected void populateAttributes(Map<String, Object> distributedCacheAttributes)
+// {
+// Map<String, Object> existing = getAttributesInternal();
+// Map<String, Object> excluded = removeExcludedAttributes(existing);
+// existing.clear();
+//
+// existing.putAll(distributedCacheAttributes);
+// if (excluded != null)
+// existing.putAll(excluded);
+// }
- @Override
- protected Object getAttributeInternal(String name)
- {
- Object result = getAttributesInternal().get(name);
+// @Override
+// protected Object getAttributeInternal(String name)
+// {
+// Object result = getAttributesInternal().get(name);
+//
+// // Do dirty check even if result is null, as w/ SET_AND_GET null
+// // still makes us dirty (ensures timely replication w/o using ACCESS)
+// if (isGetDirty(result))
+// {
+// sessionAttributesDirty();
+// }
+//
+// return result;
+// }
- // Do dirty check even if result is null, as w/ SET_AND_GET null
- // still makes us dirty (ensures timely replication w/o using ACCESS)
- if (isGetDirty(result))
- {
- sessionAttributesDirty();
- }
-
- return result;
-
- }
-
@Override
protected Object removeAttributeInternal(String name,
boolean localCall,
More information about the jboss-cvs-commits
mailing list