glenn 2003/01/02 09:12:55 Modified: jk/native CHANGES.txt jk/native/common jk_lb_worker.c jk_util.c jk_util.h jk/xdocs/jk workershowto.xml Log: Add new lb property sticky_session. If set to 0, requests with session id's do not have to be routed back to the same Tomcat worker. This is to support the new Tomcat Session Manager code which supports persistance of session data across multiple Tomcat instances, such as JavaGroup's. Revision Changes Path 1.9 +4 -1 jakarta-tomcat-connectors/jk/native/CHANGES.txt Index: CHANGES.txt =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/CHANGES.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- CHANGES.txt 2 Jan 2003 13:00:59 -0000 1.8 +++ CHANGES.txt 2 Jan 2003 17:12:55 -0000 1.9 @@ -6,6 +6,9 @@ [glenn] * Apache 2/1.3, if Tomcat returns an error but not content, let Apache handle processing the error returned by Tomcat. + * Added the load balancer sticky_session property. If set to 0 + requests with servlet SESSION ID's can be routed to any Tomcat + worker. Default is 1, sessions are sticky. Changes with JK 1.2.2: * tomcat_trend.pl updated script to support changed logging of 1.12 +9 -3 jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c Index: jk_lb_worker.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- jk_lb_worker.c 30 Oct 2002 21:17:34 -0000 1.11 +++ jk_lb_worker.c 2 Jan 2003 17:12:55 -0000 1.12 @@ -103,6 +103,7 @@ jk_worker_t worker; int in_local_worker_mode; int local_worker_only; + int sticky_session; }; typedef struct lb_worker lb_worker_t; @@ -254,8 +255,12 @@ worker_record_t *rc = NULL; double lb_min = 0.0; unsigned i; - char *session_route = get_session_route(s); - + char *session_route = NULL; + + if (p->sticky_session) { + session_route = get_session_route(s); + } + if(session_route) { for(i = 0 ; i < p->num_of_workers ; i++) { if(0 == strcmp(session_route, p->lb_workers[i].name)) { @@ -421,6 +426,7 @@ unsigned num_of_workers; p->in_local_worker_mode = JK_FALSE; p->local_worker_only = jk_get_local_worker_only_flag(props, p->name); + p->sticky_session = jk_get_is_sticky_session(props, p->name); if(jk_get_lb_worker_list(props, p->name, 1.19 +15 -1 jakarta-tomcat-connectors/jk/native/common/jk_util.c Index: jk_util.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_util.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- jk_util.c 16 Sep 2002 08:26:46 -0000 1.18 +++ jk_util.c 2 Jan 2003 17:12:55 -0000 1.19 @@ -89,6 +89,7 @@ #define SOCKET_KEEPALIVE_OF_WORKER ("socket_keepalive") #define LOAD_FACTOR_OF_WORKER ("lbfactor") #define BALANCED_WORKERS ("balanced_workers") +#define STICKY_SESSION ("sticky_session") #define LOCAL_WORKER_ONLY_FLAG ("local_worker_only") #define LOCAL_WORKER_FLAG ("local_worker") #define WORKER_AJP12 ("ajp12") @@ -499,6 +500,19 @@ sprintf(buf, "%s.%s.%s", PREFIX_OF_WORKER, wname, LOAD_FACTOR_OF_WORKER); return map_get_double(m, buf, DEFAULT_LB_FACTOR); +} + +int jk_get_is_sticky_session(jk_map_t *m, + const char *wname) { + int rc = JK_TRUE; + char buf[1024]; + if (m && wname) { + int value; + sprintf(buf, "%s.%s.%s", PREFIX_OF_WORKER, wname, STICKY_SESSION); + value = map_get_int(m, buf, 0); + if (!value) rc = JK_FALSE; + } + return rc; } int jk_get_is_local_worker(jk_map_t *m, 1.9 +4 -1 jakarta-tomcat-connectors/jk/native/common/jk_util.h Index: jk_util.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_util.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- jk_util.h 16 Sep 2002 08:26:46 -0000 1.8 +++ jk_util.h 2 Jan 2003 17:12:55 -0000 1.9 @@ -134,6 +134,9 @@ double jk_get_lb_factor(jk_map_t *m, const char *wname); +int jk_get_is_sticky_session(jk_map_t *m, + const char *wname); + int jk_get_is_local_worker(jk_map_t *m, const char *wname); 1.10 +8 -5 jakarta-tomcat-connectors/jk/xdocs/jk/workershowto.xml Index: workershowto.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/xdocs/jk/workershowto.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- workershowto.xml 26 Nov 2002 16:08:48 -0000 1.9 +++ workershowto.xml 2 Jan 2003 17:12:55 -0000 1.10 @@ -300,11 +300,14 @@ <p> The overall result is that workers managed by the same lb worker are load-balanced (based on their lbfactor and current user session) and also fall-backed so a single Tomcat process death will not "kill" the entire site. The following table specifies properties that the lb worker can accept: -</p> - -<p> -<b>balanced_workers</b> is a comma separated list of workers that the load balancer need to manage. -These workers should not appear in the worker.list property. +<ul> +<li><b>balanced_workers</b> is a comma separated list of workers that the load balancer need to manage. +These workers should not appear in the worker.list property.</li> +<li><b>sticky_session</b> specifies whether requests with SESSION ID's should be routed back to the same +Tomcat worker. If sticky_session is an int and is not 0 it is set to JK_TRUE and sessions are sticky, otherwise +sticky_session is set to false. Set sticky_session to JK_FALSE when Tomcat is using a Session Manager which +can persist session data across multiple instances of Tomcat. By default sticky_session is set to JK_TRUE.</li> +</ul> </p> <screen>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>