geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r488272 - in /geronimo/server/trunk: ./ modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/ modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/ modules/geronimo-jetty6-builder/src/main/j...
Date Mon, 18 Dec 2006 14:07:45 GMT
Author: gdamour
Date: Mon Dec 18 06:07:44 2006
New Revision: 488272

URL: http://svn.apache.org/viewvc?view=rev&rev=488272
Log:
* Move to 2.0M3-SNAPSHOT version of WADI dependencies;
* Migrate BasicWADISessionManager to new WADI API;
* Move GBean definition of the session timeout before the clustering
configuration such that clustering builders can retrieve this
session timeout;
* Add Session.onEndAccess contract. This is a notification of the
session performed by clients when they are done with their
data accesses. Implementations can implement this method to queue a 
replication; and
* Honor David J.'s TODOs in ClusteredSessionManager.

This fixes GERONIMO-2669 fix o.a.g.j.ClusteredSessionManager to match 
changes in Jetty AbstractSessionManager

Modified:
    geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
    geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java
    geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Session.java
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/AbstractClusteredPreHandler.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java
    geronimo/server/trunk/pom.xml

Modified: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java?view=diff&rev=488272&r1=488271&r2=488272
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
(original)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
Mon Dec 18 06:07:44 2006
@@ -16,13 +16,7 @@
  */
 package org.apache.geronimo.clustering.wadi;
 
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import javax.servlet.ServletContext;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -35,55 +29,27 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.codehaus.wadi.Collapser;
 import org.codehaus.wadi.Contextualiser;
 import org.codehaus.wadi.Emoter;
 import org.codehaus.wadi.Evicter;
 import org.codehaus.wadi.Immoter;
 import org.codehaus.wadi.Invocation;
 import org.codehaus.wadi.InvocationException;
-import org.codehaus.wadi.Manager;
-import org.codehaus.wadi.ManagerConfig;
 import org.codehaus.wadi.Motable;
 import org.codehaus.wadi.PoolableInvocationWrapperPool;
 import org.codehaus.wadi.SessionPool;
-import org.codehaus.wadi.Streamer;
+import org.codehaus.wadi.core.ConcurrentMotableMap;
 import org.codehaus.wadi.group.Dispatcher;
-import org.codehaus.wadi.impl.AbsoluteEvicter;
-import org.codehaus.wadi.impl.ClusterContextualiser;
 import org.codehaus.wadi.impl.ClusteredManager;
-import org.codehaus.wadi.impl.DummyContextualiser;
-import org.codehaus.wadi.impl.HashingCollapser;
-import org.codehaus.wadi.impl.HybridRelocater;
 import org.codehaus.wadi.impl.MemoryContextualiser;
-import org.codehaus.wadi.impl.SerialContextualiserFrontingMemory;
-import org.codehaus.wadi.impl.SimpleSessionPool;
-import org.codehaus.wadi.impl.SimpleStreamer;
-import org.codehaus.wadi.impl.SimpleValuePool;
-import org.codehaus.wadi.impl.StatelessContextualiser;
-import org.codehaus.wadi.replication.contextualizer.ReplicaAwareContextualiser;
-import org.codehaus.wadi.replication.manager.ReplicaterAdapterFactory;
-import org.codehaus.wadi.replication.manager.ReplicationManager;
+import org.codehaus.wadi.impl.StackContext;
 import org.codehaus.wadi.replication.manager.ReplicationManagerFactory;
-import org.codehaus.wadi.replication.manager.basic.SessionReplicationManager;
-import org.codehaus.wadi.replication.storage.ReplicaStorage;
 import org.codehaus.wadi.replication.storage.ReplicaStorageFactory;
 import org.codehaus.wadi.replication.strategy.BackingStrategyFactory;
-import org.codehaus.wadi.servicespace.ServiceRegistry;
+import org.codehaus.wadi.servicespace.ServiceSpace;
 import org.codehaus.wadi.servicespace.ServiceSpaceName;
-import org.codehaus.wadi.servicespace.basic.BasicServiceSpace;
 import org.codehaus.wadi.web.WebSession;
-import org.codehaus.wadi.web.WebSessionPool;
-import org.codehaus.wadi.web.impl.AtomicallyReplicableSessionFactory;
-import org.codehaus.wadi.web.impl.DistributableAttributesFactory;
-import org.codehaus.wadi.web.impl.DistributableValueFactory;
-import org.codehaus.wadi.web.impl.DummyRouter;
-import org.codehaus.wadi.web.impl.DummyStatefulHttpServletRequestWrapperPool;
-import org.codehaus.wadi.web.impl.StandardHttpProxy;
-import org.codehaus.wadi.web.impl.StandardSessionWrapperFactory;
-import org.codehaus.wadi.web.impl.WebSessionToSessionPoolAdapter;
 
-import EDU.oswego.cs.dl.util.concurrent.Sync;
 import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
 
 /**
@@ -101,7 +67,7 @@
     private final CopyOnWriteArrayList listeners;
 
     private ClusteredManager manager;
-    private BasicServiceSpace serviceSpace;
+    private ServiceSpace serviceSpace;
 
     public BasicWADISessionManager(WADISessionManagerConfigInfo configInfo,
             ReplicationManagerFactory repManagerFactory, 
@@ -119,69 +85,28 @@
 
     public void doStart() throws Exception {
         Dispatcher underlyingDisp = dispatcherHolder.getDispatcher();
-
-        serviceSpace = new BasicServiceSpace(new ServiceSpaceName(configInfo.getServiceSpaceURI()),
underlyingDisp);
-
-        boolean strictOrdering = true;
-        Streamer streamer = new SimpleStreamer();
-        Collapser collapser = new HashingCollapser(1024, 10000);
-        Map mmap = Collections.synchronizedMap(new HashMap());
-        WebSessionPool sessionPool = new SimpleSessionPool(new AtomicallyReplicableSessionFactory());
-
-        // end of contextualiser stack
-        Contextualiser contextualiser = new DummyContextualiser();
-
-        // replica aware contextualiser
-         ReplicationManager replicationManager = repManagerFactory.factory(serviceSpace,
backingStrategyFactory);
-         ReplicationManager sessionRepManager = new SessionReplicationManager(replicationManager,
sessionPool);
-         contextualiser = new ReplicaAwareContextualiser(contextualiser, sessionRepManager);
-
-        // cluster aware contextualiser
-        contextualiser = new ClusterContextualiser(contextualiser, collapser, new HybridRelocater(5000,
5000, true));
-
-        contextualiser = new StatelessContextualiser(contextualiser, Pattern.compile("GET|POST",
2), true, 
-                Pattern.compile(".*\\.(JPG|JPEG|GIF|PNG|ICO|HTML|HTM)", 2), false);
-
-        // in-memory contextualiser
-        Evicter mevicter = new AbsoluteEvicter(configInfo.getSweepInterval(), strictOrdering,
-                configInfo.getSessionTimeoutSeconds());
-        SessionPool contextPool = new WebSessionToSessionPoolAdapter(sessionPool);
-        PoolableInvocationWrapperPool requestPool = new DummyStatefulHttpServletRequestWrapperPool();
-        contextualiser = new MotionTracker(contextualiser, mevicter, mmap, streamer, contextPool,
requestPool);
-
-        contextualiser = new SerialContextualiserFrontingMemory(contextualiser, collapser);
-
-        // Manager
-        manager = new ClusteredManager(sessionPool, 
-                new DistributableAttributesFactory(), 
-                new SimpleValuePool(new DistributableValueFactory()), 
-                new StandardSessionWrapperFactory(), 
-                null, 
-                contextualiser,
-                mmap, 
-                new DummyRouter(), 
-                false, 
-                streamer, 
-                true,
-                new ReplicaterAdapterFactory(replicationManager, sessionPool),
-                new StandardHttpProxy("jsessionid"), 
-                serviceSpace, 
-                configInfo.getNumPartitions(), 
-                collapser);
-
-        manager.init(new ManagerConfig() {
-            public void callback(Manager manager) {
-            }
-
-            public ServletContext getServletContext() {
-                return null;
+        
+        ServiceSpaceName serviceSpaceName = new ServiceSpaceName(configInfo.getServiceSpaceURI());
+        StackContext stackContext = new StackContext(serviceSpaceName,
+                underlyingDisp,
+                configInfo.getSessionTimeoutSeconds(),
+                configInfo.getNumPartitions(),
+                configInfo.getSweepInterval(),
+                repManagerFactory,
+                repStorageFactory,
+                backingStrategyFactory) {
+            @Override
+            protected MemoryContextualiser newMemoryContextualiser(Contextualiser next,
+                    ConcurrentMotableMap mmap,
+                    Evicter mevicter,
+                    PoolableInvocationWrapperPool requestPool) {
+                return new MotionTracker(next, mevicter, mmap, contextPool, requestPool);
             }
-        });
+        };
+        stackContext.build();
 
-        ServiceRegistry serviceRegistry = serviceSpace.getServiceRegistry();
-        serviceRegistry.register(ReplicaStorage.NAME, repStorageFactory.factory(serviceSpace));
-        serviceRegistry.register(ReplicationManager.NAME, replicationManager);
-        serviceRegistry.register(ClusteredManager.NAME, manager);
+        serviceSpace = stackContext.getServiceSpace();
+        manager = stackContext.getManager();
 
         serviceSpace.start();
     }
@@ -241,12 +166,14 @@
 
     private class MotionTracker extends MemoryContextualiser {
         private final Immoter immoter;
-
         private final Emoter emoter;
 
-        public MotionTracker(Contextualiser next, Evicter evicter, Map map, Streamer streamer,
SessionPool pool,
+        public MotionTracker(Contextualiser next,
+                Evicter evicter,
+                ConcurrentMotableMap map,
+                SessionPool pool,
                 PoolableInvocationWrapperPool requestPool) {
-            super(next, evicter, map, streamer, pool, requestPool);
+            super(next, evicter, map, pool, requestPool);
 
             Immoter immoterDelegate = super.getImmoter();
             immoter = new InboundSessionTracker(immoterDelegate);
@@ -279,22 +206,10 @@
         public OutboundSessionTracker(Emoter delegate) {
             this.delegate = delegate;
         }
-
-        public void commit(String arg0, Motable arg1) {
-            notifyOutboundSessionMigration((WebSession) arg1);
-            delegate.commit(arg0, arg1);
-        }
-
-        public String getInfo() {
-            return delegate.getInfo();
-        }
-
-        public boolean prepare(String arg0, Motable arg1, Motable arg2) {
-            return delegate.prepare(arg0, arg1, arg2);
-        }
-
-        public void rollback(String arg0, Motable arg1) {
-            delegate.rollback(arg0, arg1);
+        
+        public boolean emote(Motable emotable, Motable immotable) {
+            notifyOutboundSessionMigration((WebSession) emotable);
+            return delegate.emote(emotable, immotable);
         }
     }
 
@@ -303,31 +218,24 @@
 
         public InboundSessionTracker(Immoter delegate) {
             this.delegate = delegate;
+            
         }
 
-        public void commit(String arg0, Motable arg1) {
-            notifyInboundSessionMigration((WebSession) arg1);
-            delegate.commit(arg0, arg1);
-        }
-
-        public boolean contextualise(Invocation arg0, String arg1, Motable arg2, Sync arg3)
throws InvocationException {
-            return delegate.contextualise(arg0, arg1, arg2, arg3);
-        }
-
-        public String getInfo() {
-            return delegate.getInfo();
-        }
-
-        public Motable nextMotable(String arg0, Motable arg1) {
-            return delegate.nextMotable(arg0, arg1);
+        public boolean immote(Motable emotable, Motable immotable) {
+            boolean success = delegate.immote(emotable, immotable);
+            if (success) {
+                notifyInboundSessionMigration((WebSession) immotable);
+            }
+            return success;
         }
-
-        public boolean prepare(String arg0, Motable arg1, Motable arg2) {
-            return delegate.prepare(arg0, arg1, arg2);
+        
+        
+        public boolean contextualise(Invocation arg0, String arg1, Motable arg2) throws InvocationException
{
+            return delegate.contextualise(arg0, arg1, arg2);
         }
 
-        public void rollback(String arg0, Motable arg1) {
-            delegate.rollback(arg0, arg1);
+        public Motable newMotable() {
+            return delegate.newMotable();
         }
     }
 

Modified: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java?view=diff&rev=488272&r1=488271&r2=488272
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java
(original)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java
Mon Dec 18 06:07:44 2006
@@ -38,7 +38,7 @@
     }
 
     public String getSessionId() {
-        return session.getId();
+        return session.getName();
     }
 
     public void release() {
@@ -63,6 +63,10 @@
 
     public Map getState() {
         return state;
+    }
+    
+    public void onEndAccess() {
+        session.onEndProcessing();
     }
     
     private class StateMap implements Map {

Modified: geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Session.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Session.java?view=diff&rev=488272&r1=488271&r2=488272
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Session.java
(original)
+++ geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Session.java
Mon Dec 18 06:07:44 2006
@@ -75,4 +75,11 @@
      */
     void release();
     
+    /**
+     * Notifies the session that state accesses are now completed. 
+     * <p>
+     * When state accesses end, the underlying local SessionManager may decide to replicate
synchronously or
+     * asynchronously the current state to remote SessionManagers.
+     */
+    void onEndAccess();
 }

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java?view=diff&rev=488272&r1=488271&r2=488272
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
Mon Dec 18 06:07:44 2006
@@ -404,6 +404,11 @@
             // configure listeners.
             configureListeners(webApp, webModuleData);
 
+            webModuleData.setAttribute(JettyWebAppContext.GBEAN_ATTR_SESSION_TIMEOUT,
+                    (webApp.getSessionConfigArray().length == 1 && webApp.getSessionConfigArray(0).getSessionTimeout()
!= null) ?
+                            new Integer(webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue()
* 60) :
+                            defaultSessionTimeoutSeconds);
+
             Boolean distributable = webApp.getDistributableArray().length == 1 ? Boolean.TRUE
: Boolean.FALSE;
             webModuleData.setAttribute("distributable", distributable);
             if (Boolean.TRUE == distributable) {
@@ -416,11 +421,6 @@
             } else {
                 configureNoClustering(moduleContext, webModuleData);
             }
-
-            webModuleData.setAttribute("sessionTimeoutSeconds",
-                    (webApp.getSessionConfigArray().length == 1 && webApp.getSessionConfigArray(0).getSessionTimeout()
!= null) ?
-                            new Integer(webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue()
* 60) :
-                            defaultSessionTimeoutSeconds);
 
             // configure mime mappings.
             configureMimeMappings(webApp, webModuleData);

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/AbstractClusteredPreHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/AbstractClusteredPreHandler.java?view=diff&rev=488272&r1=488271&r2=488272
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/AbstractClusteredPreHandler.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/AbstractClusteredPreHandler.java
Mon Dec 18 06:07:44 2006
@@ -18,14 +18,13 @@
 
 import java.io.IOException;
 
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
 
 import org.apache.geronimo.clustering.ClusteredInvocation;
 import org.apache.geronimo.clustering.ClusteredInvocationException;
 import org.apache.geronimo.jetty6.AbstractPreHandler;
-import org.mortbay.jetty.Handler;
 import org.mortbay.jetty.HttpException;
 
 /**
@@ -35,11 +34,6 @@
 
     public void handle(String target, HttpServletRequest request, HttpServletResponse response,
int dispatch)
             throws IOException, ServletException {
-//        if (dispatch != Handler.REQUEST) {
-//            next.handle(target, request, response, dispatch);
-//            return;
-//        }
-//        
         ClusteredInvocation invocation = newClusteredInvocation(target, request, response,
dispatch);
         try {
             invocation.invoke();
@@ -70,10 +64,6 @@
             this.request = request;
             this.response = response;
             this.dispatch = dispatch;
-            //TODO figure out if the normal SessionHandler will set the requestedSessionId
correctly.
-            //My (djencks) guess is yes it will.
-//            GeronimoServletHttpRequest servletHttpRequest = (GeronimoServletHttpRequest)
request.getWrapper();
-//            servletHttpRequest.setRequestedSessionId(pathParams);
         }
 
         protected void invokeLocally() throws ClusteredInvocationException {

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java?view=diff&rev=488272&r1=488271&r2=488272
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionManager.java
Mon Dec 18 06:07:44 2006
@@ -20,6 +20,7 @@
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 
 import org.apache.geronimo.clustering.SessionAlreadyExistException;
 import org.apache.geronimo.clustering.SessionListener;
@@ -43,7 +44,7 @@
         workerName = workerName.replaceAll(" ", "");
         HashSessionIdManager sessionIdManager = new HashSessionIdManager();
         sessionIdManager.setWorkerName(workerName);
-        setMetaManager(sessionIdManager);
+        setIdManager(sessionIdManager);
 
         sessionManager.registerListener(new MigrationListener());
 
@@ -57,16 +58,21 @@
     }
 
     @Override
+    public void complete(HttpSession session) {
+        ClusteredSession clusteredSession = (ClusteredSession) session;
+        clusteredSession.session.onEndAccess();
+    }
+    
+    @Override
     protected void addSession(Session session) {
-        //todo gianni fixme
+        ClusteredSession clusteredSession = (ClusteredSession) session;
         synchronized (idToSession) {
-            idToSession.put(session.getId(), (ClusteredSession) session);
+            idToSession.put(clusteredSession.getClusterId(), clusteredSession);
         }
     }
 
     @Override
     protected void removeSession(String idInCluster) {
-        //todo gianni fixme
         synchronized (idToSession) {
             idToSession.remove(idInCluster);
         }
@@ -74,7 +80,6 @@
 
     @Override
     protected Session getSession(String idInCluster) {
-        //todo gianni fixme
         synchronized (idToSession) {
             return idToSession.get(idInCluster);
         }
@@ -82,38 +87,33 @@
 
     @Override
     public int getSessions() {
-        //todo gianni fixme
         synchronized (idToSession) {
             return idToSession.size();
         }
     }
 
-
-    /**
-     * @deprecated. Need to review if it is needed.
-     */
     @Override
     public Map getSessionMap() {
-        //todo gianni fixme
-        return idToSession;
+        throw new AssertionError("getSessionMap is never used.");
     }
 
     @Override
     protected void invalidateSessions() {
-        //todo gianni fixme
+        synchronized (idToSession) {
+            idToSession.clear();
+        }
     }
 
-
     private class MigrationListener implements SessionListener {
 
         public void notifyInboundSessionMigration(org.apache.geronimo.clustering.Session
session) {
-            addSession(new ClusteredSession(session), false);
+            addSession(new MigratedClusteredSession(session), false);
         }
 
         public void notifyOutboundSessionMigration(org.apache.geronimo.clustering.Session
session) {
             ClusteredSession clusteredSession;
             synchronized (idToSession) {
-                clusteredSession = (ClusteredSession) idToSession.remove(session.getSessionId());
+                clusteredSession = idToSession.remove(session.getSessionId());
             }
             if (null == clusteredSession) {
                 throw new AssertionError("Session [" + session + "] is undefined");
@@ -128,26 +128,64 @@
         protected ClusteredSession(HttpServletRequest request) {
             super(request);
             try {
-                this.session = sessionManager.createSession(getId());
+                this.session = sessionManager.createSession(getClusterId());
             } catch (SessionAlreadyExistException e) {
                 throw (IllegalStateException) new IllegalStateException().initCause(e);
             }
             synchronized (idToSession) {
-                idToSession.put(getId(), this);
+                idToSession.put(getClusterId(), this);
             }
+            forceDefinitionOfSessionValues();
         }
 
         protected ClusteredSession(org.apache.geronimo.clustering.Session session) {
             super(session.getSessionId());
             this.session = session;
-            synchronized (idToSession) {
-                idToSession.put(getId(), this);
-            }
+            forceDefinitionOfSessionValues();
         }
 
         @Override
         protected Map newAttributeMap() {
             return session.getState();
+        }
+
+        @Override
+        protected String getClusterId() {
+            return super.getClusterId();
+        }
+        
+        @Override
+        public void invalidate() throws IllegalStateException {
+            super.invalidate();
+            session.release();
+        }
+        
+        private void forceDefinitionOfSessionValues() {
+            String TOKEN = "GeronimoIntegration_forceDefinitionOfSessionValues";
+            setAttribute(TOKEN, TOKEN);
+            removeAttribute(TOKEN);
+        }
+    }
+    
+    public class MigratedClusteredSession extends ClusteredSession {
+        private final String clusterId;
+        
+        protected MigratedClusteredSession(org.apache.geronimo.clustering.Session session)
{
+            super(session);
+            clusterId = session.getSessionId();
+            synchronized (idToSession) {
+                idToSession.put(clusterId, this);
+            }
+        }
+        
+        /**
+         * Implementation note: we need to override this method as the constructor Session(String)
has a bug:
+         * it should also set _clusterId. W/o this override, this Session is bound to the
null key during inbound
+         * session migration.
+         */
+        @Override
+        protected String getClusterId() {
+            return clusterId;
         }
     }
 

Modified: geronimo/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/pom.xml?view=diff&rev=488272&r1=488271&r2=488272
==============================================================================
--- geronimo/server/trunk/pom.xml (original)
+++ geronimo/server/trunk/pom.xml Mon Dec 18 06:07:44 2006
@@ -882,19 +882,19 @@
             <dependency>
                 <groupId>org.codehaus.wadi</groupId>
                 <artifactId>wadi-core</artifactId>
-                <version>2.0M2</version>
+                <version>2.0M3-SNAPSHOT</version>
             </dependency>
 
             <dependency>
                 <groupId>org.codehaus.wadi</groupId>
                 <artifactId>wadi-group</artifactId>
-                <version>2.0M2</version>
+                <version>2.0M3-SNAPSHOT</version>
             </dependency>
 
             <dependency>
                 <groupId>org.codehaus.wadi</groupId>
                 <artifactId>wadi-tribes</artifactId>
-                <version>2.0M2</version>
+                <version>2.0M3-SNAPSHOT</version>
             </dependency>
 
             <dependency>



Mime
View raw message