tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filip Hanik - Dev" <devli...@hanik.com>
Subject Re: Tomcat 5 Clustering VERY slow - waitForAck problem
Date Thu, 29 Apr 2004 14:44:22 GMT
>HashMap map = (HashMap)session.getAttribute("map");
>map.put("key","value");

Code like this will work if you run the SimpleTcpReplicationManager with useDirtyFlag=false.
The delta manager doesn't care for useDirtyFlag since it always replicated deltas only, and
deltas are determined by you calling
setAttribute/removeAttribute.

So with DeltaManager, the rule is, in order for your value to be replicated, setAttribute
or removeAttribute has to be called.

Using SimpleTcpReplicationManager with useDirtyFlag=false works, but beware, adds a LOT of
overhead.

Filip
----- Original Message -----
From: "Greg Hall" <greg.hall@evo-mail.com>
To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
Sent: Thursday, April 29, 2004 3:23 AM
Subject: Re: Tomcat 5 Clustering VERY slow - waitForAck problem


Many thanks for the help: LD_ASSUME_KERNEL=2.4 solved the problem.

However, with clustering working, I have now found another problem: A
HashMap stored in the session is only replicated in one direction, i.e.

HashMap map = (HashMap)session.getAttribute("map");
map.put("key","value");

when run on server A, is replicated to server B,  but if the same code
(different key / value) is run on server B, the "map" is not replicated
back.

This is apparent with "useDirtyFlag" set to both true or false.

I have attached a servlet I used to verify this behaviour, which adds
any request parameters directly to the session and to the HashMap
contained in the session, and displays both in the browser window(s). I
tested without a load balancer.

I can of course force the replication, i.e.

HashMap map = (HashMap)session.getAttribute("map");
map.put("key","value");
session.put("map", map);

but I don't think this is how it's intended to work ?

Any idea's ?

Regards,
Greg.




Filip Hanik - Dev wrote:

>set
>
>export LD_ASSUME_KERNEL=2.4
>
>then try again
>
>Filip
>----- Original Message -----
>From: "Greg Hall" <greg.hall@evo-mail.com>
>To: <tomcat-user@jakarta.apache.org>
>Sent: Wednesday, April 28, 2004 3:36 AM
>Subject: Tomcat 5 Clustering VERY slow - waitForAck problem
>
>
>Hi,
>
>I have set up clustering between 2 Tomcat servers. The session
>replication  works but  is VERY slow. It appears  that the sending
>server does not receive an acknowledgement via the TCP socket and times
>out after 15 secs. The message I get is  as follows:
>
>27-Apr-2004 21:51:54 org.apache.catalina.cluster.tcp.SocketSender waitForAck
>WARNING: Wasn't able to read acknowledgement from server in 15000 ms.
>Disconnecting socket, and trying again.
>
>Tomcat is running on Sun's VM 1.4.2_02 on RedHat Linux 9.
>
>Any help greatly appreciated.
>
>Regards,
>Greg.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>




--------------------------------------------------------------------------------



import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

/**
 *  A Servlet designed to test CLustering
 *
 *@author     Greg Hall
 *@created    24 April 2004
 */
public class Controller extends HttpServlet {

/**
*  Description of the Method
*
*@param  request               Description of the Parameter
*@param  response              Description of the Parameter
*@exception  ServletException  Description of the Exception
*@exception  IOException       Description of the Exception
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {

doGet(request, response);
}


/**
*  Description of the Method
*
*@param  request               Description of the Parameter
*@param  response              Description of the Parameter
*@exception  ServletException  Description of the Exception
*@exception  IOException       Description of the Exception
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {

HttpSession session = request.getSession();

boolean isNew = false;
HashMap myMap = (HashMap) session.getAttribute("mymap");
if (myMap == null) {
isNew = true;
myMap = new HashMap();
session.setAttribute("mymap", myMap);
}
// force session replication
//session.setAttribute("mymap", myMap);

Map map = request.getParameterMap();
Iterator i = map.keySet().iterator();
while (i.hasNext()) {
String key = (String) i.next();
String[] value = (String[]) map.get(key);
//writer.write(key + " = " + value[0] + "<br />");
session.setAttribute(key, value[0]);
myMap.put(key, value[0]);
}

Writer writer = response.getWriter();
writer.write("<html><body>Session attributes:<br />");

Enumeration e = session.getAttributeNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
//if (name.equals("mymap")) continue;
//String attr = (String) session.getAttribute(name);
Object attr = session.getAttribute(name);
writer.write(name + " = " + attr + "<br />");
}

writer.write("<h2>My Map attributes</h2>");
if (isNew) {
writer.write("<p>New Map created</p>");
}
i = myMap.keySet().iterator();
while (i.hasNext()) {
String key = (String) i.next();
writer.write(key + " = " + myMap.get(key) + "<br />");
}

writer.write("</body></html>");
writer.flush();
}


/**
*  Description of the Method
*
*@exception  ServletException  Description of the Exception
*/
public void init() throws ServletException {

}
}





--------------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message