[Jboss-cvs] JBossAS SVN: r56321 - branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Aug 27 23:40:55 EDT 2006
Author: bstansberry at jboss.com
Date: 2006-08-27 23:40:53 -0400 (Sun, 27 Aug 2006)
New Revision: 56321
Modified:
branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/InstantSnapshotManager.java
branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/IntervalSnapshotManager.java
branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/SnapshotManager.java
Log:
SPass the session itself to the SnapshotManager
Modified: branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/InstantSnapshotManager.java
===================================================================
--- branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/InstantSnapshotManager.java 2006-08-28 03:40:09 UTC (rev 56320)
+++ branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/InstantSnapshotManager.java 2006-08-28 03:40:53 UTC (rev 56321)
@@ -21,7 +21,6 @@
*/
package org.jboss.web.tomcat.tc5.session;
-import org.apache.catalina.Session;
/**
* A concrete implementation of the snapshot manager interface
@@ -41,20 +40,19 @@
/**
* Instant replication of the modified session
*/
- public void snapshot(String id)
+ public void snapshot(ClusteredSession session)
{
- try
+ if (session != null)
{
- // find the session that has been modified
- AbstractJBossManager mgr = getManager();
- Session session = mgr.findSession(id);
- if (session != null)
- mgr.storeSession(session);
+ try
+ {
+ getManager().storeSession(session);
+ }
+ catch (Exception e)
+ {
+ getLog().warn("Failed to replicate session " + session.getIdInternal(), e);
+ }
}
- catch (Exception e)
- {
- getLog().warn("Failed to replicate sessionID:" + id, e);
- }
}
public void start()
Modified: branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/IntervalSnapshotManager.java
===================================================================
--- branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/IntervalSnapshotManager.java 2006-08-28 03:40:09 UTC (rev 56320)
+++ branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/IntervalSnapshotManager.java 2006-08-28 03:40:53 UTC (rev 56321)
@@ -24,7 +24,6 @@
import java.util.LinkedHashSet;
import java.util.Set;
-import org.apache.catalina.Session;
import org.jboss.logging.Logger;
/**
@@ -48,6 +47,9 @@
// the distribute thread
protected Thread thread = null;
+ // Is session processing allowed?
+ protected boolean processingAllowed = false;
+
// has the thread finished?
protected boolean threadDone = false;
@@ -65,18 +67,19 @@
/**
* Store the modified session in a hashmap for the distributor thread
*/
- public void snapshot(String id)
+ public void snapshot(ClusteredSession session)
{
try
- {
+ {
+ // Don't hold a ref to the session for a long time
synchronized (sessions)
{
- sessions.add(id);
+ sessions.add(session);
}
}
catch (Exception e)
{
- log.warn("Failed to replicate sessionID:" + id, e);
+ log.error("Failed to queue session " + session + " for replication", e);
}
}
@@ -85,26 +88,28 @@
*/
protected void processSessions()
{
- String[] ids = null;
+ ClusteredSession[] toProcess = null;
synchronized (sessions)
{
- ids = new String[sessions.size()];
- ids = (String[]) sessions.toArray(ids);
+ toProcess = new ClusteredSession[sessions.size()];
+ toProcess = (ClusteredSession[]) sessions.toArray(toProcess);
sessions.clear();
}
AbstractJBossManager mgr = getManager();
- for (int i = 0; i < ids.length; i++)
+ for (int i = 0; i < toProcess.length; i++)
{
+ // Confirm we haven't been stopped
+ if (!processingAllowed)
+ break;
+
try
{
- Session session = mgr.findSession(ids[i]);
- if (session != null)
- mgr.storeSession(session);
+ mgr.storeSession(toProcess[i]);
}
catch (Exception e)
{
- getLog().error("Caught exception processing session " + ids[i], e);
+ getLog().error("Caught exception processing session " + toProcess[i].getRealId(), e);
}
}
}
@@ -114,6 +119,7 @@
*/
public void start()
{
+ processingAllowed = true;
startThread();
}
@@ -122,6 +128,7 @@
*/
public void stop()
{
+ processingAllowed = false;
stopThread();
synchronized (sessions)
{
Modified: branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/SnapshotManager.java
===================================================================
--- branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/SnapshotManager.java 2006-08-28 03:40:09 UTC (rev 56320)
+++ branches/Branch_4_0/tomcat/src/main/org/jboss/web/tomcat/tc5/session/SnapshotManager.java 2006-08-28 03:40:53 UTC (rev 56321)
@@ -54,7 +54,7 @@
* Tell the snapshot manager which session was modified and
* must be replicated
*/
- public abstract void snapshot(String id);
+ public abstract void snapshot(ClusteredSession session);
/**
* Start the snapshot manager
More information about the jboss-cvs-commits
mailing list