fhanik 2004/01/12 20:22:28
Modified:modules/cluster/src/share/org/apache/catalina/cluster/session
DeltaManager.java DeltaRequest.java
DeltaSession.java
modules/cluster/src/share/org/apache/catalina/cluster/tcp
PooledSocketSender.java ReplicationTransmitter.java
SimpleTcpCluster.java
Log:
Fixed a bug in a dead lock with the pooled socket sender when a member crashes
Recycling the delta request objects to avoid object instantiation, although I
actually think this is slower
Fixed the call back with the session and the delta request execution
Revision ChangesPath
1.5 +9 -10
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
Index: DeltaManager.java
===
RCS file:
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DeltaManager.java 13 Jan 2004 00:07:18 - 1.4
+++ DeltaManager.java 13 Jan 2004 04:22:28 - 1.5
@@ -406,24 +406,23 @@
}
-private DeltaRequest loadDeltaRequest(byte[] data) throws
+private DeltaRequest loadDeltaRequest(DeltaSession session, byte[] data) throws
ClassNotFoundException, IOException {
ByteArrayInputStream fis = null;
ReplicationStream ois = null;
Loader loader = null;
ClassLoader classLoader = null;
fis = new ByteArrayInputStream(data);
-BufferedInputStream bis = new BufferedInputStream(fis);
ois = new ReplicationStream(fis,container.getLoader().getClassLoader());
-DeltaRequest dreq = (DeltaRequest)ois.readObject();
+session.getDeltaRequest().readExternal(ois);
ois.close();
-return dreq;
+return session.getDeltaRequest();
}
private byte[] unloadDeltaRequest(DeltaRequest deltaRequest) throws IOException
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
-oos.writeObject(deltaRequest);
+deltaRequest.writeExternal(oos);
oos.flush();
oos.close();
return bos.toByteArray();
@@ -874,8 +873,8 @@
}
case SessionMessage.EVT_SESSION_DELTA : {
byte[] delta = msg.getSession();
- DeltaRequest dreq = loadDeltaRequest(delta);
DeltaSession session =
(DeltaSession)findSession(msg.getSessionID());
+ DeltaRequest dreq = loadDeltaRequest(session,delta);
dreq.execute(session);
session.setPrimarySession(false);
1.4 +71 -23
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java
Index: DeltaRequest.java
===
RCS file:
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DeltaRequest.java 13 Jan 2004 00:07:18 - 1.3
+++ DeltaRequest.java 13 Jan 2004 04:22:28 - 1.4
@@ -66,7 +66,9 @@
/**
* This class is used to track the series of actions that happens when
- * a request is executed. These actions will then
+ * a request is executed. These actions will then translate into invokations of
methods
+ * on the actual session.
+ * This class is NOT thread safe. One DeltaRequest per session
* @author a href=mailto:[EMAIL PROTECTED]Filip Hanik/a
* @version 1.0
*/
@@ -95,6 +97,8 @@
private String sessionId;
private LinkedList actions = new LinkedList();
+private LinkedList actionPool = new LinkedList();
+
private boolean recordAllActions = false;
public DeltaRequest() {
@@ -140,7 +144,13 @@
int action,
String name,
Object value) {
-AttributeInfo info = new AttributeInfo(type,action,name,value);
+AttributeInfo info = null;
+if ( this.actionPool.size() 0 ) {
+info = (AttributeInfo)actionPool.removeFirst();
+info.init(type,action,name,value);
+} else {
+info = new AttributeInfo(type, action, name, value);
+}
//if we have already done something to this attribute, make sure
//we don't send multiple actions across the wire
if ( !recordAllActions)