Author: rjung
Date: Sun Oct 23 11:38:18 2011
New Revision: 1187868
URL: http://svn.apache.org/viewvc?rev=1187868&view=rev
Log:
HTTPD: Allow to choose a sticky worker using the environment
variable JK_ROUTE. This can be used if sessions and routes
are send with the request in a non-standard way.
Modified:
tomcat/jk/trunk/native/apache-1.3/mod_jk.c
tomcat/jk/trunk/native/apache-2.0/mod_jk.c
tomcat/jk/trunk/native/common/jk_lb_worker.c
tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
tomcat/jk/trunk/xdocs/reference/apache.xml
Modified: tomcat/jk/trunk/native/apache-1.3/mod_jk.c
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-1.3/mod_jk.c?rev=1187868&r1=1187867&r2=1187868&view=diff
==============================================================================
--- tomcat/jk/trunk/native/apache-1.3/mod_jk.c (original)
+++ tomcat/jk/trunk/native/apache-1.3/mod_jk.c Sun Oct 23 11:38:18 2011
@@ -81,6 +81,7 @@
#define JK_ENV_REPLY_TIMEOUT ("JK_REPLY_TIMEOUT")
#define JK_ENV_STICKY_IGNORE ("JK_STICKY_IGNORE")
#define JK_ENV_STATELESS ("JK_STATELESS")
+#define JK_ENV_ROUTE ("JK_ROUTE")
#define JK_ENV_WORKER_NAME ("JK_WORKER_NAME")
#define JK_NOTE_WORKER_NAME ("JK_WORKER_NAME")
#define JK_NOTE_WORKER_TYPE ("JK_WORKER_TYPE")
@@ -683,6 +684,7 @@ static int init_ws_service(apache_privat
const char *reply_timeout = NULL;
const char *sticky_ignore = NULL;
const char *stateless = NULL;
+ const char *route = NULL;
rule_extension_t *e;
/* Copy in function pointers (which are really methods) */
@@ -785,6 +787,12 @@ static int init_ws_service(apache_privat
if (conf->options & JK_OPT_DISABLEREUSE)
s->disable_reuse = 1;
+ /* get route if known */
+ route = ap_table_get(r->subprocess_env, JK_ENV_ROUTE);
+ if (route && *route) {
+ s->route = route;
+ }
+
/* get server name */
/* s->server_name = (char *)(r->hostname ? r->hostname :
r->server->server_hostname); */
/* XXX : a la jk2 */
Modified: tomcat/jk/trunk/native/apache-2.0/mod_jk.c
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-2.0/mod_jk.c?rev=1187868&r1=1187867&r2=1187868&view=diff
==============================================================================
--- tomcat/jk/trunk/native/apache-2.0/mod_jk.c (original)
+++ tomcat/jk/trunk/native/apache-2.0/mod_jk.c Sun Oct 23 11:38:18 2011
@@ -116,6 +116,7 @@
#define JK_ENV_REPLY_TIMEOUT ("JK_REPLY_TIMEOUT")
#define JK_ENV_STICKY_IGNORE ("JK_STICKY_IGNORE")
#define JK_ENV_STATELESS ("JK_STATELESS")
+#define JK_ENV_ROUTE ("JK_ROUTE")
#define JK_ENV_WORKER_NAME ("JK_WORKER_NAME")
#define JK_NOTE_WORKER_NAME ("JK_WORKER_NAME")
#define JK_NOTE_WORKER_TYPE ("JK_WORKER_TYPE")
@@ -738,6 +739,7 @@ static int init_ws_service(apache_privat
const char *reply_timeout = NULL;
const char *sticky_ignore = NULL;
const char *stateless = NULL;
+ const char *route = NULL;
rule_extension_t *e;
/* Copy in function pointers (which are really methods) */
@@ -839,6 +841,12 @@ static int init_ws_service(apache_privat
if (conf->options & JK_OPT_DISABLEREUSE)
s->disable_reuse = 1;
+ /* get route if known */
+ route = apr_table_get(r->subprocess_env, JK_ENV_ROUTE);
+ if (route && *route) {
+ s->route = route;
+ }
+
/* get server name */
s->server_name = get_env_string(r, (char *)ap_get_server_name(r),
conf->local_name_indicator, 0);
Modified: tomcat/jk/trunk/native/common/jk_lb_worker.c
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_lb_worker.c?rev=1187868&r1=1187867&r2=1187868&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_lb_worker.c (original)
+++ tomcat/jk/trunk/native/common/jk_lb_worker.c Sun Oct 23 11:38:18 2011
@@ -492,6 +492,18 @@ static char *get_cookie(jk_ws_service_t
static char *get_sessionid(jk_ws_service_t *s, lb_worker_t *p, jk_logger_t *l)
{
char *val;
+
+ /* If the web server sets a route, ignore the real session id
+ * and fake a new one for that route.
+ */
+ if (s->route) {
+ size_t sz = strlen(s->route) + 1;
+ val = jk_pool_alloc(s->pool, sz + 1);
+ val[0] = '.';
+ memcpy(val + 1, s->route, sz);
+ return val;
+ }
+
val = get_path_param(s, p->session_path);
if (!val) {
val = get_cookie(s, p->session_cookie);
Modified: tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml?rev=1187868&r1=1187867&r2=1187868&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml Sun Oct 23 11:38:18 2011
@@ -45,6 +45,11 @@
<subsection name="Native">
<changelog>
<add>
+ HTTPD: Allow to choose a sticky worker using the environment
+ variable JK_ROUTE. This can be used if sessions and routes
+ are send with the request in a non-standard way. (rjung)
+ </add>
+ <add>
URI Map: Add "sticky_ignore" extension attributes to uri worker map.
It allows to disable stickyness for individual mounts. (rjung)
</add>
Modified: tomcat/jk/trunk/xdocs/reference/apache.xml
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/reference/apache.xml?rev=1187868&r1=1187867&r2=1187868&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/reference/apache.xml (original)
+++ tomcat/jk/trunk/xdocs/reference/apache.xml Sun Oct 23 11:38:18 2011
@@ -1112,14 +1112,28 @@ variable <b>no-jk</b>.
</Location>
</source>
</subsection>
-<subsection name="More Environment Variables">
+<subsection name="Advanced Environment Variables">
+<p>
+Environment variables allow to overwrite the default behaviour
+of mod_jk depending on request properties like e.g. the request URI,
+header values or cookie. This can be done using the <b>SetEnvIf</b> or
+<b>RewriteRule</b> directives.
+</p>
+<p>
+The environment variable
+<b>JK_ROUTE</b> can be set to explicitely choose a member of a
+load balancer worker. The value must be equal to the
+route attribute of the member, or if that attribute is not
+used, equal to the member name. Note that this is only needed if
+session IDs and routes are encoded in a non standard way in the
+request. Stickyness using the Java Servlet compliant way of encoding
+the IDs is supported by default.
+This is available since version 1.2.33.
+</p>
<p>
The environment variable
<b>JK_REPLY_TIMEOUT</b> can be set to dynamically define a reply timeout.
The value must be given in milliseconds.
-You can use <b>SetEnvIf</b> or <b>RewriteRule</b>
-for more complex rules to change the <b>JK_REPLY_TIMEOUT</b> according
-to request properties like e.g. the request URI.
This is available since version 1.2.27.
</p>
<p>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]