[jboss-cvs] JBossAS SVN: r106956 - projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 20 17:28:37 EDT 2010
Author: pferraro
Date: 2010-07-20 17:28:37 -0400 (Tue, 20 Jul 2010)
New Revision: 106956
Removed:
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/CacheListener.java
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/PassivationListener.java
Modified:
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/DistributedCacheManagerImpl.java
Log:
Implement skeleton session ownership api. Move cache listeners into DCM impl itself.
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/CacheListener.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/CacheListener.java 2010-07-20 21:16:52 UTC (rev 106955)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/CacheListener.java 2010-07-20 21:28:37 UTC (rev 106956)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ha.web.tomcat.service.session.distributedcache.impl;
-
-import org.infinispan.atomic.AtomicMap;
-import org.infinispan.notifications.Listener;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
-import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
-import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
-
-/**
- * @author Paul Ferraro
- *
- */
- at Listener
-public class CacheListener
-{
- private final LocalDistributableSessionManager manager;
-
- public CacheListener(LocalDistributableSessionManager manager)
- {
- this.manager = manager;
- }
-
- @CacheEntryRemoved
- public void removed(CacheEntryRemovedEvent event)
- {
- if (event.isPre() || event.isOriginLocal()) return;
-
- this.manager.notifyRemoteInvalidation((String) event.getKey());
- }
-
- @CacheEntryModified
- public void modified(CacheEntryModifiedEvent event)
- {
- if (event.isPre() || event.isOriginLocal()) return;
-
- @SuppressWarnings("unchecked")
- AtomicMap<Object, Object> data = (AtomicMap<Object, Object>) event.getValue();
-
- Integer version = (Integer) data.get(AtomicMapEntry.VERSION.key());
- Long timestamp = (Long) data.get(AtomicMapEntry.TIMESTAMP.key());
- DistributableSessionMetadata metadata = (DistributableSessionMetadata) data.get(AtomicMapEntry.METADATA.key());
-
- this.manager.sessionChangedInDistributedCache((String) event.getKey(), null, version.intValue(), timestamp.longValue(), metadata);
- }
-}
Modified: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/DistributedCacheManagerImpl.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/DistributedCacheManagerImpl.java 2010-07-20 21:16:52 UTC (rev 106955)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/DistributedCacheManagerImpl.java 2010-07-20 21:28:37 UTC (rev 106956)
@@ -35,6 +35,13 @@
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.manager.CacheContainer;
import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryActivated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.infinispan.notifications.cachelistener.event.CacheEntryActivatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
import org.infinispan.remoting.transport.jgroups.SuspectException;
import org.infinispan.transaction.tm.BatchModeTransactionManager;
import org.infinispan.util.concurrent.TimeoutException;
@@ -45,10 +52,12 @@
import org.jboss.web.tomcat.service.session.distributedcache.spi.IncomingDistributableSessionData;
import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingDistributableSessionData;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.SessionOwnershipSupport;
/**
* @author Paul Ferraro
*/
+ at Listener
public class DistributedCacheManagerImpl<T extends OutgoingDistributableSessionData> implements DistributedCacheManager<T>, CacheInvoker
{
static String mask(String sessionId)
@@ -79,8 +88,6 @@
private Cache<String, AtomicMap<Object, Object>> cache;
private BatchingManager batchingManager;
private boolean passivationEnabled = false;
- private Object cacheListener;
- private Object passivationListener;
private volatile boolean forceSynchronous = false;
@@ -101,7 +108,8 @@
// JBAS-3941 -- context path can be multi-level, but we don't
// want that turning into a multilevel Fqn, so escape it
// Use '-' which is legal in a filesystem path
- String path = this.getContextPath();
+ String context = this.manager.getContextName();
+ String path = context.isEmpty() || context.equals("/") ? "ROOT" : context.startsWith("/") ? context.substring(1) : context;
String cacheName = host + "/" + path;
String templateCacheName = this.manager.getReplicationConfig().getCacheName();
@@ -124,15 +132,8 @@
this.batchingManager = new BatchingManagerImpl(tm);
- this.cacheListener = new CacheListener(this.manager);
- this.cache.addListener(this.cacheListener);
+ this.cache.addListener(this);
- if (this.manager.isPassivationEnabled())
- {
- this.passivationListener = new PassivationListener(this.manager);
- this.cache.addListener(this.passivationListener);
- }
-
CacheLoaderManagerConfig loaderManagerConfig = this.cache.getConfiguration().getCacheLoaderManagerConfig();
this.passivationEnabled = (loaderManagerConfig != null) ? loaderManagerConfig.isPassivation() && !loaderManagerConfig.isShared() : false;
@@ -141,13 +142,8 @@
@Override
public void stop()
{
- this.cache.removeListener(this.cacheListener);
+ this.cache.removeListener(this);
- if (this.passivationListener != null)
- {
- this.cache.removeListener(this.passivationListener);
- }
-
this.cache.stop();
}
@@ -368,15 +364,6 @@
this.forceSynchronous = forceSynchronous;
}
- private String getContextPath()
- {
- String context = this.manager.getContextName();
-
- if (context.isEmpty() || context.equals("/")) return "ROOT";
-
- return context.startsWith("/") ? context.substring(1) : context;
- }
-
/**
* {@inheritDoc}
* @see org.jboss.ha.web.tomcat.service.session.distributedcache.impl.CacheInvoker#invoke(org.jboss.ha.web.tomcat.service.session.distributedcache.impl.CacheInvoker.Operation)
@@ -428,4 +415,46 @@
throw new RuntimeException(String.format("Aborting cache operation after %d retries.", Integer.valueOf(this.backOffIntervals.length + 1)), exception);
}
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager#getSessionOwnershipSupport()
+ */
+ @Override
+ public SessionOwnershipSupport getSessionOwnershipSupport()
+ {
+ return null;
+ }
+
+ @CacheEntryRemoved
+ public void removed(CacheEntryRemovedEvent event)
+ {
+ if (event.isPre() || event.isOriginLocal()) return;
+
+ this.manager.notifyRemoteInvalidation((String) event.getKey());
+ }
+
+ @CacheEntryModified
+ public void modified(CacheEntryModifiedEvent event)
+ {
+ if (event.isPre() || event.isOriginLocal()) return;
+
+ @SuppressWarnings("unchecked")
+ AtomicMap<Object, Object> data = (AtomicMap<Object, Object>) event.getValue();
+
+ Integer version = AtomicMapEntry.VERSION.get(data);
+ Long timestamp = AtomicMapEntry.TIMESTAMP.get(data);
+ DistributableSessionMetadata metadata = AtomicMapEntry.METADATA.get(data);
+
+ this.manager.sessionChangedInDistributedCache((String) event.getKey(), null, version.intValue(), timestamp.longValue(), metadata);
+ }
+
+ @CacheEntryActivated
+ public void activated(CacheEntryActivatedEvent event)
+ {
+ if (this.manager.isPassivationEnabled())
+ {
+ this.manager.sessionActivated();
+ }
+ }
}
Deleted: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/PassivationListener.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/PassivationListener.java 2010-07-20 21:16:52 UTC (rev 106955)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/web/tomcat/service/session/distributedcache/impl/PassivationListener.java 2010-07-20 21:28:37 UTC (rev 106956)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ha.web.tomcat.service.session.distributedcache.impl;
-
-import org.infinispan.notifications.Listener;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryActivated;
-import org.infinispan.notifications.cachelistener.event.CacheEntryActivatedEvent;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
-
-/**
- * @author Paul Ferraro
- *
- */
- at Listener
-public class PassivationListener
-{
- private final LocalDistributableSessionManager manager;
-
- public PassivationListener(LocalDistributableSessionManager manager)
- {
- this.manager = manager;
- }
-
- @CacheEntryActivated
- public void activated(CacheEntryActivatedEvent event)
- {
- this.manager.sessionActivated();
- }
-}
More information about the jboss-cvs-commits
mailing list