今天在Javalobby看到一个关于集群的一个trick.
假如在一台node中的session中存有一个List对象.
如果你是这样使用的话,
List l = (List)session.getAttribute("list");
l.add("Denny");
这个session不会引发session复制. 所有你还需要把这个List set回session中.
If you have an ArrayList in the session representing shoppingcart objects and if you just call getAttribute() to retrieve theArrayList and then add or change something without calling thesetAttribute(……………) then the container may not know that you have addedor changed something in the ArrayList. So the session will not bereplicated.
ok 就讲这么多了.
官方指南
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html
下面的这个不错, 带了一个例子, 自己实现了两个load balancing的算法. 用的是Filter Clustering and Load Balancing in Tomcat 5, Part 1
http://www.onjava.com/pub/a/onjava/2004/03/31/clustering.html?page=1
Clustering and Load Balancing in Tomcat 5, Part 2
http://www.onjava.com/pub/a/onjava/2004/04/14/clustering.html?page=1