httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r472114 - in /httpd/httpd/branches/2.2.x: CHANGES STATUS docs/manual/mod/mod_proxy_balancer.xml modules/proxy/mod_proxy_balancer.c
Date Tue, 07 Nov 2006 13:49:10 GMT
Author: jim
Date: Tue Nov  7 05:49:09 2006
New Revision: 472114

URL: http://svn.apache.org/viewvc?view=rev&rev=472114
Log:
Merge r417238, r437773, r446929, r453630 from trunk:

* Add the following environment variables to expose the information
* about
  the route, the sticky session and the worker used during a request to
  other modules:

  BALANCER_SESSION_STICKY
  BALANCER_SESSION_ROUTE
  BALANCER_NAME
  BALANCER_WORKER_NAME
  BALANCER_WORKER_ROUTE

PR: 39806
Submitted by: Brian <brectanu gmail.com>
Reviewed by: rpluem


fix validation error


* Set the new environment variable BALANCER_ROUTE_CHANGED if a worker with a
  route different from the one supplied by the client had been chosen or if
  the client supplied no routing information for a balancer with sticky
  sessions.


* mod_proxy_balancer: Document BALANCER_ROUTE_CHANGED environment variable.

Submitted by: Brian Rectanus <brectanu gmail.com>
Reviewed by: rpluem

Reviewed by: jim

Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy_balancer.xml
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?view=diff&rev=472114&r1=472113&r2=472114
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Tue Nov  7 05:49:09 2006
@@ -1,6 +1,15 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.4
 
+  *) mod_proxy_balancer: Set the new environment variable BALANCER_ROUTE_CHANGED
+     if a worker with a route different from the one supplied by the client
+     had been chosen or if the client supplied no routing information for
+     a balancer with sticky sessions. [Ruediger Pluem]
+
+  *) mod_proxy_balancer: Add information about the route, the sticky session
+     and the worker used during a request as environment variables. PR 39806.
+     [Brian <brectanu gmail.com>]
+
   *) mod_proxy: Don't try to use dead backend connection. PR 37770.
      [Olivier BOEL <ob dorrboel.com>] 
 

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?view=diff&rev=472114&r1=472113&r2=472114
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Tue Nov  7 05:49:09 2006
@@ -77,22 +77,6 @@
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * mod_proxy_balancer: Implement new environment variables
-                         BALANCER_NAME
-                         BALANCER_WORKER_NAME
-                         BALANCER_WORKER_ROUTE
-                         BALANCER_SESSION_STICKY
-                         BALANCER_SESSION_ROUTE
-                         BALANCER_ROUTE_CHANGED
-      Trunk versions of patch:
-        http://svn.apache.org/viewvc?view=rev&revision=417238 (including docs)
-        http://svn.apache.org/viewvc?view=rev&revision=437773 (docs)
-        http://svn.apache.org/viewvc?view=rev&revision=446929
-        http://svn.apache.org/viewvc?view=rev&revision=453630 (docs)
-      2.2.x version of patch:
-        Trunk version works
-      +1: rpluem, mturk, jim
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
 
     * mpm_winnt: Fix return values from wait_for_many_objects.

Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy_balancer.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy_balancer.xml?view=diff&rev=472114&r1=472113&r2=472114
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy_balancer.xml (original)
+++ httpd/httpd/branches/2.2.x/docs/manual/mod/mod_proxy_balancer.xml Tue Nov  7 05:49:09
2006
@@ -271,6 +271,59 @@
 
 </section>
 
+<section id="environment">
+    <title>Exported Environment Variables</title>
+    <p>At present there are 6 environment variables exported:</p>
+
+    <dl>
+    <!-- ============= BALANCER_SESSION_STICKY =============== -->
+    <dt><var><a name="balancer_session_sticky" id="balancer_session_sticky">BALANCER_SESSION_STICKY</a></var></dt>
+    <dd>
+    <p>This is assigned the <var>stickysession</var> value used in the
current
+    request.  It is the cookie or parameter name used for sticky sessions</p>
+    </dd>
+
+    <!-- ============= BALANCER_SESSION_ROUTE ================ -->
+    <dt><var><a name="balancer_session_route" id="balancer_session_route">BALANCER_SESSION_ROUTE</a></var></dt>
+    <dd>
+    <p>This is assigned the <var>route</var> parsed from the current 
+    request.</p>
+    </dd>
+
+    <!-- ============= BALANCER_NAME ========================= -->
+    <dt><var><a name="balancer_name" id="balancer_name">BALANCER_NAME</a></var></dt>
+    <dd>
+    <p>This is assigned the name of the balancer used for the current 
+    request. The value is something like <code>balancer://foo</code>.</p>
+    </dd>
+
+    <!-- ============= BALANCER_WORKER_NAME ================== -->
+    <dt><var><a name="balancer_worker_name" id="balancer_worker_name">BALANCER_WORKER_NAME</a></var></dt>
+    <dd>
+    <p>This is assigned the name of the worker used for the current request.
+    The value is something like <code>http://hostA:1234</code>.</p>
+    </dd>
+
+    <!-- ============= BALANCER_WORKER_ROUTE ================= -->
+    <dt><var><a name="balancer_worker_route" id="balancer_worker_route">BALANCER_WORKER_ROUTE</a></var></dt>
+    <dd>
+    <p>This is assigned the <var>route</var> of the worker that will be

+    used for the current request.</p>
+    </dd>
+
+    <!-- ============= BALANCER_ROUTE_CHANGED ================= -->
+    <dt><var><a name="balancer_route_changed" id="balancer_route_changed">BALANCER_ROUTE_CHANGED</a></var></dt>
+    <dd>
+    <p>This is set to 1 if the session route does not match the
+    worker route (BALANCER_SESSION_ROUTE != BALANCER_WORKER_ROUTE) or the
+    session does not yet have an established route.  This can be used to
+    determine when/if the client needs to be sent an updated route
+    when sticky sessions are used.</p>
+    </dd>
+    </dl>
+
+</section>
+
 <section id="enable">
     <title>Enabling Balancer Manager Support</title>
     <p>This module <em>requires</em> the service of 

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c?view=diff&rev=472114&r1=472113&r2=472114
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_balancer.c Tue Nov  7 05:49:09 2006
@@ -260,6 +260,16 @@
          * Find the worker that has this route defined.
          */
         worker = find_route_worker(balancer, *route, r);
+        if (worker && strcmp(*route, worker->s->route)) {
+            /*
+             * Notice that the route of the worker chosen is different from
+             * the route supplied by the client.
+             */
+            apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "proxy: BALANCER: Route changed from %s to %s",
+                         *route, worker->s->route);
+        }
         return worker;
     }
     else
@@ -417,9 +427,28 @@
 
             return HTTP_SERVICE_UNAVAILABLE;
         }
+        if ((*balancer)->sticky && runtime) {
+            /*
+             * This balancer has sticky sessions and the client either has not
+             * supplied any routing information or all workers for this route
+             * including possible redirect and hotstandby workers are in error
+             * state, but we have found another working worker for this
+             * balancer where we can send the request. Thus notice that we have
+             * changed the route to the backend.
+             */
+            apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
+        }
         *worker = runtime;
     }
 
+    /* Add balancer/worker info to env. */
+    apr_table_setn(r->subprocess_env,
+                   "BALANCER_NAME", (*balancer)->name);
+    apr_table_setn(r->subprocess_env,
+                   "BALANCER_WORKER_NAME", (*worker)->name);
+    apr_table_setn(r->subprocess_env,
+                   "BALANCER_WORKER_ROUTE", (*worker)->s->route);
+
     /* Rewrite the url from 'balancer://url'
      * to the 'worker_scheme://worker_hostname[:worker_port]/url'
      * This replaces the balancers fictional name with the
@@ -430,6 +459,12 @@
     if (route) {
         apr_table_setn(r->notes, "session-sticky", (*balancer)->sticky);
         apr_table_setn(r->notes, "session-route", route);
+
+        /* Add session info to env. */
+        apr_table_setn(r->subprocess_env,
+                       "BALANCER_SESSION_STICKY", (*balancer)->sticky);
+        apr_table_setn(r->subprocess_env,
+                       "BALANCER_SESSION_ROUTE", route);
     }
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy: BALANCER (%s) worker (%s) rewritten to %s",



Mime
View raw message