[jboss-cvs] JBossAS SVN: r58587 - trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Nov 18 06:43:28 EST 2006
Author: bstansberry at jboss.com
Date: 2006-11-18 06:43:27 -0500 (Sat, 18 Nov 2006)
New Revision: 58587
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/CacheListener.java
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheManager.java
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheService.java
trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheWrapper.java
Log:
Update to JBC 2 API
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/CacheListener.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/CacheListener.java 2006-11-18 11:42:18 UTC (rev 58586)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/CacheListener.java 2006-11-18 11:43:27 UTC (rev 58587)
@@ -21,16 +21,18 @@
*/
package org.jboss.web.tomcat.tc6.session;
+import java.util.Map;
+
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
-import org.jboss.cache.AbstractTreeCacheListener;
+import org.jboss.cache.AbstractCacheListener;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.logging.Logger;
-import org.jboss.metadata.WebMetaData;
import org.jgroups.View;
-public class CacheListener extends AbstractTreeCacheListener
+public class CacheListener extends AbstractCacheListener
{
// Element within an FQN that is JSESSION
private static final int JSESSION_FQN_INDEX = 0;
@@ -68,23 +70,18 @@
manager_ = manager;
hostname_ = hostname;
webapp_ = webapp;
- int granularity = manager_.getReplicationGranularity();
- fieldBased_ = (granularity == WebMetaData.REPLICATION_GRANULARITY_FIELD);
+ ReplicationGranularity granularity = manager_.getReplicationGranularity();
+ fieldBased_ = (granularity == ReplicationGranularity.FIELD);
// TODO decide if disdaining local activity is always good for REPL_ASYNC
- disdainLocalActivity_ = (granularity == WebMetaData.REPLICATION_GRANULARITY_SESSION);; // for now
+ disdainLocalActivity_ = (granularity == ReplicationGranularity.SESSION);; // for now
}
// --------------- TreeCacheListener methods ------------------------------------
- public void nodeCreated(Fqn fqn)
+ @Override
+ public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
{
- // No-op
- }
-
- public void nodeRemoved(Fqn fqn)
- {
- // Ignore our own activity
- if (SessionReplicationContext.isLocallyActive())
+ if (pre || isLocal)
return;
boolean isBuddy = isBuddyFqn(fqn);
@@ -107,41 +104,32 @@
manager_.processRemoteInvalidation(sessId);
}
}
-
- /**
- * Called when a node is loaded into memory via the CacheLoader. This is not the same
- * as {@link #nodeCreated(Fqn)}.
- */
- public void nodeLoaded(Fqn fqn)
+
+ @Override
+ public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
{
- }
-
- public void nodeModified(Fqn fqn)
- {
- nodeDirty(fqn);
- }
-
- private void nodeDirty(Fqn fqn)
- {
- // If checking for local activity has a higher likelihood of
- // catching unwanted notifications than checking fqn size,
- // do it first
- if (disdainLocalActivity_)
- {
- if (SessionReplicationContext.isLocallyActive())
- return;
- }
+ if (pre || isLocal)
+ return;
+// // If checking for local activity has a higher likelihood of
+// // catching unwanted notifications than checking fqn size,
+// // do it first
+// if (disdainLocalActivity_)
+// {
+// if (SessionReplicationContext.isLocallyActive())
+// return;
+// }
+
boolean isBuddy = isBuddyFqn(fqn);
// We only care if there is a chance this is for a session root
if (!isFqnSessionRootSized(fqn, isBuddy))
return;
- if (!disdainLocalActivity_)
- {
- if (SessionReplicationContext.isLocallyActive())
- return;
- }
+// if (!disdainLocalActivity_)
+// {
+// if (SessionReplicationContext.isLocallyActive())
+// return;
+// }
// We only care if this is for our webapp
if (!isFqnForOurWebapp(fqn, isBuddy))
@@ -149,6 +137,7 @@
// Query if we have version value in the distributed cache.
// If we have a version value, compare the version and invalidate if necessary.
+ // TODO get the key from the passed in data map!!
Integer version = (Integer)cacheWrapper_.get(fqn, JBossCacheService.VERSION_KEY);
if(version != null)
{
@@ -191,40 +180,35 @@
}
}
- public void nodeVisited(Fqn fqn)
+ @Override
+ public void cacheStarted(CacheSPI cache)
{
- // no-op
- }
-
- public void cacheStarted(TreeCache cache)
- {
// TODO will need to synchronize this with local sessions
}
- public void cacheStopped(TreeCache cache)
+ @Override
+ public void cacheStopped(CacheSPI cache)
{
// TODO will need to synchronize this with local sessions
}
+ @Override
public void viewChange(View new_view)
{
// We don't care for this event.
}
-
- public void nodeEvicted(Fqn fqn)
- {
- // We don't care for this event.
- }
- public void nodeActivate(Fqn fqn, boolean pre)
+ @Override
+ public void nodeActivated(Fqn fqn, boolean pre)
{
- //no-op
- // we don't need to handle node activation notification since the session manager will do upon
+ // we don't need to handle node activation notification since the
+ // session manager will notify any servlet API listeners upon
// loading the session from the distrubted store.
}
// FIXME why would there be a notification of passivation on another node?
- public void nodePassivate(Fqn fqn, boolean pre)
+ @Override
+ public void nodePassivated(Fqn fqn, boolean pre)
{
if (!pre || SessionReplicationContext.isLocallyActive())
return;
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheManager.java 2006-11-18 11:42:18 UTC (rev 58586)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheManager.java 2006-11-18 11:43:27 UTC (rev 58587)
@@ -263,7 +263,7 @@
* @see WebMetaData#REPLICATION_GRANULARITY_FIELD
* @see WebMetaData#REPLICATION_GRANULARITY_SESSION
*/
- public int getReplicationGranularity()
+ public ReplicationGranularity getReplicationGranularity()
{
return replicationGranularity_;
}
@@ -280,17 +280,7 @@
// otherwise screws up standalone TC integration!!
if (started_ && this.replGranularityString_ == null)
{
- switch (this.replicationGranularity_)
- {
- case WebMetaData.REPLICATION_GRANULARITY_ATTRIBUTE:
- this.replGranularityString_ = "ATTRIBUTE";
- break;
- case WebMetaData.REPLICATION_GRANULARITY_SESSION:
- this.replGranularityString_ = "SESSION";
- break;
- case WebMetaData.REPLICATION_GRANULARITY_FIELD:
- this.replGranularityString_ = "FIELD";
- }
+ this.replGranularityString_ = replicationGranularity_.toString();
}
return replGranularityString_;
}
@@ -319,17 +309,7 @@
// otherwise screws up standalone TC integration!!
if (started_ && this.replTriggerString_ == null)
{
- switch (this.invalidateSessionPolicy_)
- {
- case WebMetaData.SESSION_INVALIDATE_SET:
- this.replTriggerString_ = "SET";
- break;
- case WebMetaData.SESSION_INVALIDATE_SET_AND_GET:
- this.replTriggerString_ = "SET_AND_GET";
- break;
- case WebMetaData.SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET:
- this.replTriggerString_ = "SET_AND_NON_PRIMITIVE_GET";
- }
+ this.replTriggerString_ = invalidateSessionPolicy_.toString();
}
return this.replTriggerString_;
}
@@ -680,6 +660,11 @@
stored = true;
stats_.updateReplicationStats(realId, elapsed);
}
+ else if (log_.isTraceEnabled())
+ {
+ log_.trace("Session " + session.getIdInternal() +
+ " did not require replication.");
+ }
}
}
@@ -757,10 +742,10 @@
ClusteredSession session = null;
switch (replicationGranularity_)
{
- case (WebMetaData.REPLICATION_GRANULARITY_ATTRIBUTE):
+ case ATTRIBUTE:
session = new AttributeBasedClusteredSession(this);
break;
- case (WebMetaData.REPLICATION_GRANULARITY_FIELD):
+ case FIELD:
session = new FieldBasedClusteredSession(this);
break;
default:
@@ -1070,7 +1055,7 @@
}
catch (Exception exn)
{
- exn.printStackTrace();
+ log_.error("Caught exception rolling back transaction", exn);
}
// We will need to alert Tomcat of this exception.
if (ex instanceof RuntimeException)
@@ -1124,7 +1109,7 @@
{
// If we are using SESSION granularity, we don't want to initiate a TX
// for a single put
- boolean notSession = (replicationGranularity_ != WebMetaData.REPLICATION_GRANULARITY_SESSION);
+ boolean notSession = (replicationGranularity_ != ReplicationGranularity.SESSION);
boolean doTx = false;
try
{
@@ -1148,18 +1133,19 @@
}
catch (Exception ex)
{
- if (log_.isDebugEnabled())
- log_.debug("processSessionRepl(): failed with exception", ex);
+ log_.debug("processSessionRepl(): failed with exception", ex);
try
{
-// if(doTx)
- // Let's set it no matter what.
+ //if(doTx)
+ // Let's setRollbackOnly no matter what.
+ // (except if there's no tx due to SESSION (JBAS-3840))
+ if (notSession)
tm.setRollbackOnly();
}
catch (Exception exn)
{
- exn.printStackTrace();
+ log_.error("Caught exception rolling back transaction", exn);
}
// We will need to alert Tomcat of this exception.
@@ -1586,10 +1572,7 @@
return;
}
- if (log_.isInfoEnabled())
- {
- log_.info("Manager is about to start");
- }
+ log_.info("Manager is about to start");
// Notify our interested LifecycleListeners
lifecycle_.fireLifecycleEvent(BEFORE_START_EVENT, this);
@@ -1613,31 +1596,30 @@
// Validate attributes
- if ("SET_AND_GET".equalsIgnoreCase(replTriggerString_))
- this.invalidateSessionPolicy_ = WebMetaData.SESSION_INVALIDATE_SET_AND_GET;
- else if ("SET_AND_NON_PRIMITIVE_GET".equalsIgnoreCase(replTriggerString_))
- this.invalidateSessionPolicy_ = WebMetaData.SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
- else if ("SET".equalsIgnoreCase(replTriggerString_))
- this.invalidateSessionPolicy_ = WebMetaData.SESSION_INVALIDATE_SET;
- else
+ try
+ {
+ this.invalidateSessionPolicy_ = InvalidateSessionPolicy.fromString(replTriggerString_);
+ }
+ catch (IllegalArgumentException iae)
+ {
throw new LifecycleException("replication-trigger value set to a " +
"non-valid value: '" +
replTriggerString_ +
"' (should be ['SET_AND_GET', " +
"'SET_AND_NON_PRIMITIVE_GET', 'SET'])");
+ }
- if ("SESSION".equalsIgnoreCase(replGranularityString_))
- this.replicationGranularity_ = WebMetaData.REPLICATION_GRANULARITY_SESSION;
- else if ("ATTRIBUTE".equalsIgnoreCase(replGranularityString_))
- this.replicationGranularity_ = WebMetaData.REPLICATION_GRANULARITY_ATTRIBUTE;
- else if ("FIELD".equalsIgnoreCase(replGranularityString_))
- this.replicationGranularity_ = WebMetaData.REPLICATION_GRANULARITY_FIELD;
- else
+ try
+ {
+ }
+ catch (IllegalArgumentException iae)
+ {
throw new LifecycleException("replication-granularity value set to " +
"a non-valid value: '" +
replGranularityString_ +
"' (should be ['SESSION', " +
"'ATTRIBUTE' or 'FIELD'])");
+ }
// Create the JBossCacheService
try
@@ -1811,7 +1793,7 @@
// Add batch replication valve if needed.
// TODO -- should we add this even if not FIELD in case a cross-context
// call traverses a field-based webapp?
- if (replicationGranularity_ == WebMetaData.REPLICATION_GRANULARITY_FIELD &&
+ if (replicationGranularity_ == ReplicationGranularity.FIELD &&
Boolean.TRUE.equals(replicationFieldBatchMode_))
{
Valve batchValve = new BatchReplicationClusteredSessionValve(this);
@@ -1830,8 +1812,8 @@
private void initSnapshotManager()
{
String ctxPath = ((Context) container_).getPath();
- if ("instant".equals(snapshotMode_) || replicationGranularity_
- == WebMetaData.REPLICATION_GRANULARITY_FIELD)
+ if ("instant".equals(snapshotMode_)
+ || replicationGranularity_== ReplicationGranularity.FIELD)
{
snapshotManager_ = new InstantSnapshotManager(this, ctxPath);
}
@@ -1899,7 +1881,7 @@
*/
private void validateFieldMarshalling()
{
- if (replicationGranularity_ == WebMetaData.REPLICATION_GRANULARITY_FIELD
+ if (replicationGranularity_ == ReplicationGranularity.FIELD
&& !proxy_.isMarshallingAvailable())
{
// BES 16/8/2006 -- throw ISE, not ClusteringNotSupportedException, as a
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheService.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheService.java 2006-11-18 11:42:18 UTC (rev 58586)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheService.java 2006-11-18 11:43:27 UTC (rev 58587)
@@ -21,7 +21,6 @@
*/
package org.jboss.web.tomcat.tc6.session;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -44,14 +43,17 @@
import org.apache.catalina.Context;
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.aop.PojoCacheMBean;
+import org.jboss.cache.Node;
+import org.jboss.cache.Region;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.jmx.PojoCacheJmxWrapperMBean;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.transaction.BatchModeTransactionManager;
import org.jboss.invocation.MarshalledValue;
-import org.jboss.invocation.MarshalledValueInputStream;
-import org.jboss.invocation.MarshalledValueOutputStream;
import org.jboss.logging.Logger;
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.serial.io.MarshalledObject;
@@ -77,7 +79,8 @@
static final String VERSION_KEY = "VERSION";
static final String FQN_DELIMITER = "/";
- private PojoCacheMBean proxy_;
+ private PojoCache pojoCache_;
+ private Cache plainCache_;
private ObjectName cacheServiceName_;
// name of webapp's virtual host(JBAS-2194).
@@ -104,9 +107,13 @@
try
{
cacheServiceName_ = new ObjectName(treeCacheObjectName);
- // Create Proxy-Object for this service
- proxy_ = (PojoCacheMBean) MBeanProxyExt.create(PojoCacheMBean.class,
- cacheServiceName_);
+ // Get the pojo cache
+ PojoCacheJmxWrapperMBean mbean = (PojoCacheJmxWrapperMBean) MBeanProxyExt.create(PojoCacheJmxWrapperMBean.class,
+ cacheServiceName_);
+ if (mbean != null)
+ {
+ pojoCache_ = mbean.getPojoCache();
+ }
}
catch (Throwable t)
{
@@ -118,7 +125,7 @@
throw new ClusteringNotSupportedException(str, t);
}
- if (proxy_ == null)
+ if (pojoCache_ == null)
{
String str = "Could not access TreeCache service " +
(cacheServiceName_ == null ? "<null>" : cacheServiceName_.toString()) +
@@ -126,10 +133,11 @@
log_.debug(str);
throw new ClusteringNotSupportedException(str);
}
-
- cacheWrapper_ = new JBossCacheWrapper(proxy_);
- useTreeCacheMarshalling_ = proxy_.getUseRegionBasedMarshalling();
+ plainCache_ = pojoCache_.getCache();
+ cacheWrapper_ = new JBossCacheWrapper(pojoCache_);
+
+ useTreeCacheMarshalling_ = plainCache_.getConfiguration().isUseRegionBasedMarshalling();
}
public void start(ClassLoader tcl, JBossCacheManager manager)
@@ -159,20 +167,20 @@
// Listen for cache changes
cacheListener_ = new CacheListener(cacheWrapper_, manager_, hostName_, webAppPath_);
- proxy_.addTreeCacheListener(cacheListener_);
+ plainCache_.addCacheListener(cacheListener_);
// register the tcl and bring over the state for the webapp
Object[] objs = new Object[]{SESSION, hostName_, webAppPath_};
Fqn pathFqn = new Fqn( objs );
- String fqnStr = pathFqn.toString();
try {
if(useTreeCacheMarshalling_)
{
log_.debug("UseMarshalling is true. We will register the fqn: " +
- fqnStr + " with class loader" +tcl +
+ pathFqn + " with class loader" +tcl +
" and activate the webapp's Region");
- proxy_.registerClassLoader(fqnStr, tcl);
- proxy_.activateRegion(fqnStr);
+ Region region = plainCache_.getRegion(pathFqn, true);
+ region.registerContextClassLoader(tcl);
+ region.activate();
}
} catch (Exception ex)
{
@@ -180,44 +188,47 @@
}
// We require the cache tm to be BatchModeTransactionManager now.
- tm = proxy_.getTransactionManager();
+ tm = plainCache_.getTransactionManager();
if( ! (tm instanceof BatchModeTransactionManager) )
{
- throw new RuntimeException("JBossCacheService.start(): JBossCacheAop transaction manager is not type BatchModeTransactionManager." +
+ throw new RuntimeException("JBossCacheService.start(): JBossCacheAop transaction manager is not of type BatchModeTransactionManager." +
" Please check the tc6-cluster-service.xml TransactionManagerClassLookup field.");
}
if(isCachePassivationEnabled())
{
- log_.debug("JBossCacheService.start(): JBossCache passivation is enabled");
+ log_.debug("JBossCache passivation is enabled");
}
else
{
- log_.debug("JBossCacheService.start(): JBossCache passivation is disabled");
+ log_.debug("JBossCache passivation is disabled");
}
}
public void stop()
{
- proxy_.removeTreeCacheListener(cacheListener_);
+ plainCache_.removeCacheListener(cacheListener_);
// Construct the fqn
Object[] objs = new Object[]{SESSION, hostName_, webAppPath_};
Fqn pathFqn = new Fqn( objs );
- String fqnStr = pathFqn.toString();
if(useTreeCacheMarshalling_)
{
log_.debug("UseMarshalling is true. We will inactivate the fqn: " +
- fqnStr + " and un-register its classloader");
+ pathFqn + " and un-register its classloader");
try {
- proxy_.inactivateRegion(fqnStr);
- proxy_.unregisterClassLoader(fqnStr);
+ Region region = plainCache_.getRegion(pathFqn, false);
+ if (region != null)
+ {
+ region.deactivate();
+ region.unregisterContextClassLoader();
+ }
}
catch (Exception e)
{
- log_.error("Exception during inactivation of webapp region " + fqnStr +
+ log_.error("Exception during inactivation of webapp region " + pathFqn +
" or un-registration of its class loader", e);
}
}
@@ -390,7 +401,7 @@
public boolean exists(String realId)
{
Fqn fqn = getSessionFqn(realId);
- return proxy_.exists(fqn);
+ return plainCache_.hasChild(fqn);
}
public Object getAttribute(String realId, String key)
@@ -457,7 +468,9 @@
Fqn fqn = getAttributeFqn(realId);
try
{
- keys = proxy_.getKeys(fqn);
+ Node node = plainCache_.getChild(fqn);
+ if (node != null)
+ keys = node.getKeys();
}
catch (CacheException e)
{
@@ -470,6 +483,8 @@
/**
* Return all attributes associated with this session id.
*
+ * TODO use Node.getData() and just copy the map
+ *
* @param realId the session id with any jvmRoute removed
* @return the attributes, or any empty Map if none are found.
*/
@@ -501,20 +516,36 @@
public Map getSessionIds() throws CacheException
{
Map result = new HashMap();
- Set owners = proxy_.getChildrenNames(BUDDY_BACKUP_FQN);
- if (owners != null)
+
+ Node bbRoot = plainCache_.getChild(BUDDY_BACKUP_FQN);
+ if (bbRoot != null)
{
- for (Iterator it = owners.iterator(); it.hasNext();)
+ Set owners = bbRoot.getChildren();
+ if (owners != null)
{
- Object owner = it.next();
- Set ids = proxy_.getChildrenNames(getWebappFqn(owner));
- storeSessionOwners(ids, owner, result);
+ for (Iterator it = owners.iterator(); it.hasNext();)
+ {
+ Node owner = (Node) it.next();
+ Node webRoot = owner.getChild(getWebappFqn());
+ if (webRoot != null)
+ {
+ Set ids = webRoot.getChildrenNames();
+ storeSessionOwners(ids, owner, result);
+ }
+ }
}
}
- storeSessionOwners(proxy_.getChildrenNames(getWebappFqn()), null, result);
+
+ storeSessionOwners(getChildrenNames(getWebappFqn()), null, result);
return result;
}
+
+ private Set getChildrenNames(Fqn fqn)
+ {
+ Node node = plainCache_.getChild(fqn);
+ return (node == null ? null : node.getChildrenNames());
+ }
private void storeSessionOwners(Set ids, Object owner, Map map)
{
@@ -547,7 +578,7 @@
try {
// Ignore any cache notifications that our own work generates
SessionReplicationContext.startCacheActivity();
- return proxy_.putObject(fqn, pojo);
+ return pojoCache_.attach(fqn.toString(), pojo);
} catch (CacheException e) {
throw new RuntimeException("JBossCacheService: exception occurred in cache setPojo ... ", e);
}
@@ -573,7 +604,7 @@
try {
// Ignore any cache notifications that our own work generates
SessionReplicationContext.startCacheActivity();
- return proxy_.removeObject(fqn);
+ return pojoCache_.detach(fqn.toString());
} catch (CacheException e) {
throw new RuntimeException("JBossCacheService: exception occurred in cache removePojo ... ", e);
}
@@ -636,7 +667,7 @@
Fqn fqn = getAttributeFqn(realId);
try
{
- keys = proxy_.getChildrenNames(fqn);
+ keys = getChildrenNames(fqn);
}
catch (CacheException e)
{
@@ -664,7 +695,7 @@
try
{
- return proxy_.getObject(fqn);
+ return pojoCache_.find(fqn.toString());
}
catch (CacheException e)
{
@@ -695,8 +726,6 @@
// If not a managed pojo, will return anyway
addObserver(session, i.next(), processed);
}
-
- return;
}
else if (pojo instanceof Map)
{
@@ -708,8 +737,6 @@
addObserver(session, entry.getKey(), processed);
addObserver(session, entry.getValue(), processed);
}
-
- return;
}
if(! (pojo instanceof Subject) )
@@ -906,10 +933,10 @@
public boolean isCachePassivationEnabled()
{
- if(proxy_.getCacheLoader() != null)
+ CacheLoaderConfig clc = plainCache_.getConfiguration().getCacheLoaderConfig();
+ if(clc != null)
{
- return (proxy_.getCacheLoaderPassivation() &&
- !proxy_.getCacheLoaderShared());
+ return (clc.isPassivation() && !clc.isShared());
}
else
{
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheWrapper.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheWrapper.java 2006-11-18 11:42:18 UTC (rev 58586)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheWrapper.java 2006-11-18 11:43:27 UTC (rev 58587)
@@ -21,30 +21,36 @@
*/
package org.jboss.web.tomcat.tc6.session;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
-import org.jboss.cache.aop.PojoCacheMBean;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
import org.jboss.cache.config.Option;
import org.jboss.cache.lock.TimeoutException;
+import org.jboss.cache.pojo.PojoCache;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
public class JBossCacheWrapper
{
static final Option GRAVITATE_OPTION = new Option();
-
+ static final Option LOCAL_OPTION = new Option();
static
{
GRAVITATE_OPTION.setForceDataGravitation(true);
+ LOCAL_OPTION.setCacheModeLocal(true);
}
private static final int RETRY = 3;
- private PojoCacheMBean proxy_;
-
- JBossCacheWrapper(PojoCacheMBean cache)
+ private PojoCache pojoCache_;
+ private Cache plainCache_;
+
+ JBossCacheWrapper(PojoCache cache)
{
- proxy_ = cache;
+ pojoCache_ = cache;
+ plainCache_ = pojoCache_.getCache();
}
/**
@@ -71,13 +77,23 @@
Exception ex = null;
for (int i = 0; i < RETRY; i++)
{
+ InvocationContext ctx = null;
+ Option existing = null;
try
{
+
Object value = null;
if (gravitate)
- value = proxy_.get(fqn, id, GRAVITATE_OPTION);
+ {
+ ctx = plainCache_.getInvocationContext();
+ existing = ctx.getOptionOverrides();
+ ctx.setOptionOverrides(GRAVITATE_OPTION);
+ value = plainCache_.get(fqn, id);
+ }
else
- value = proxy_.get(fqn, id);
+ {
+ value = plainCache_.get(fqn, id);
+ }
return value;
}
catch (TimeoutException e)
@@ -90,6 +106,11 @@
throw (RuntimeException) e;
throw new RuntimeException("JBossCacheService: exception occurred in cache get ... ", e);
}
+ finally
+ {
+ if (ctx != null)
+ ctx.setOptionOverrides(existing);
+ }
}
throw new RuntimeException("JBossCacheService: exception occurred in cache get after retry ... ", ex);
}
@@ -109,7 +130,7 @@
{
try
{
- proxy_.put(fqn, id, value);
+ plainCache_.put(fqn, id, value);
return;
}
catch (TimeoutException e)
@@ -138,7 +159,7 @@
{
try
{
- proxy_.put(fqn, map);
+ plainCache_.put(fqn, map);
return;
}
catch (TimeoutException e)
@@ -167,7 +188,7 @@
{
try
{
- return proxy_.remove(fqn, id);
+ return plainCache_.remove(fqn, id);
}
catch (TimeoutException e)
{
@@ -193,7 +214,7 @@
{
try
{
- proxy_.remove(fqn);
+ plainCache_.removeNode(fqn);
return;
}
catch (TimeoutException e)
@@ -218,11 +239,12 @@
Exception ex = null;
for (int i = 0; i < RETRY; i++)
{
+ InvocationContext ctx = plainCache_.getInvocationContext();
+ Option existing = ctx.getOptionOverrides();
try
{
- Option localOverride = new Option();
- localOverride.setCacheModeLocal(true);
- proxy_.remove(fqn, localOverride);
+ ctx.setOptionOverrides(LOCAL_OPTION);
+ plainCache_.removeNode(fqn);
return;
}
catch (TimeoutException e)
@@ -233,6 +255,10 @@
{
throw new RuntimeException("JBossCacheService: exception occurred in cache removeLocal ... ", e);
}
+ finally
+ {
+ ctx.setOptionOverrides(existing);
+ }
}
throw new RuntimeException("JBossCacheService: exception occurred in cache removeLocal after retry ... ", ex);
}
@@ -249,7 +275,7 @@
{
try
{
- proxy_.evict(fqn);
+ plainCache_.evict(fqn, false);
return;
}
catch (TimeoutException e)
@@ -271,25 +297,26 @@
{
try
{
- // Evict the node itself first, since if it stores a Pojo
- // that will do everything
- proxy_.evict(fqn);
+// // Evict the node itself first, since if it stores a Pojo
+// // that will do everything
+// plainCache_.evict(fqn);
+//
+// // next do a depth first removal; this ensure all nodes
+// // are removed, not just their data map
+// Set children = plainCache_.getChildrenNames(fqn);
+// if (children != null)
+// {
+// for (Iterator it = children.iterator(); it.hasNext(); )
+// {
+// Fqn child = new Fqn(fqn, it.next());
+// plainCache_.evict(child);
+// }
+//
+// plainCache_.evict(fqn);
+// }
+// return;
+ plainCache_.evict(fqn, true);
- // next do a depth first removal; this ensure all nodes
- // are removed, not just their data map
- Set children = proxy_.getChildrenNames(fqn);
- if (children != null)
- {
- for (Iterator it = children.iterator(); it.hasNext(); )
- {
- Fqn child = new Fqn(fqn, it.next());
- proxy_.evict(child);
- }
-
- proxy_.evict(fqn);
- }
- return;
-
}
catch (TimeoutException e)
{
@@ -319,18 +346,22 @@
// that will do everything
removeLocal(fqn);
- // next do a depth first removal; this ensure all nodes
+ // next do a depth first removal; this ensures all nodes
// are removed, not just their data map
- Set children = proxy_.getChildrenNames(fqn);
- if (children != null)
+ Node base = plainCache_.getChild(fqn);
+ if (base != null)
{
- for (Iterator it = children.iterator(); it.hasNext(); )
+ Set children = base.getChildren();
+ if (children != null)
{
- Fqn child = new Fqn(fqn, it.next());
- removeLocal(child);
+ for (Iterator it = children.iterator(); it.hasNext(); )
+ {
+ Node child = (Node) it.next();
+ removeLocalSubtree(child.getFqn());
+ }
+
+ removeLocal(fqn);
}
-
- removeLocal(fqn);
}
return;
More information about the jboss-cvs-commits
mailing list