httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1066076 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy_balancer.c
Date Tue, 01 Feb 2011 16:00:01 GMT
Author: jim
Date: Tue Feb  1 16:00:01 2011
New Revision: 1066076

URL: http://svn.apache.org/viewvc?rev=1066076&view=rev
Log:
We can now change lbmethod at runtime.

Provide a stub for other balancer-related params to
be adjusted as well, like timeout, sticky, etc...

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1066076&r1=1066075&r2=1066076&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Feb  1 16:00:01 2011
@@ -1155,11 +1155,11 @@ static void * create_proxy_config(apr_po
     ps->reverse = NULL;
     ps->domain = NULL;
 #if 0
-    id = ap_proxy_hashfunc(apr_psprintf(p, "%pp-%" APR_TIME_T_FMT, ps->noproxies, apr_time_now()),
PROXY_HASHFUNC_DEFAULT);
+    id = ap_proxy_hashfunc(apr_psprintf(p, "%pp-%" APR_TIME_T_FMT, ps, apr_time_now()), PROXY_HASHFUNC_DEFAULT);
 #else
-    id = ap_proxy_hashfunc(apr_psprintf(p, "%pp", ps->noproxies), PROXY_HASHFUNC_DEFAULT);
+    id = ap_proxy_hashfunc(apr_psprintf(p, "%pp", ps), PROXY_HASHFUNC_DEFAULT);
 #endif
-    ps->id = apr_psprintf(p, "cnf_%x", id);
+    ps->id = apr_psprintf(p, "s%x", id);
     ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */
     ps->viaopt_set = 0; /* 0 means default */
     ps->req = 0;
@@ -2395,8 +2395,8 @@ static int proxy_status_hook(request_rec
              "<tr><th>Stat</th><td>Worker status</td></tr>\n"
              "<tr><th>Route</th><td>Session Route</td></tr>\n"
              "<tr><th>Redir</th><td>Session Route Redirection</td></tr>\n"
-             "<tr><th>F</th><td>Load Balancer Factor in %</td></tr>\n"
-             "<tr><th>Acc</th><td>Number of requests</td></tr>\n"
+             "<tr><th>F</th><td>Load Balancer Factor</td></tr>\n"
+             "<tr><th>Acc</th><td>Number of uses</td></tr>\n"
              "<tr><th>Wr</th><td>Number of bytes transferred</td></tr>\n"
              "<tr><th>Rd</th><td>Number of bytes read</td></tr>\n"
              "</table>", r);

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=1066076&r1=1066075&r2=1066076&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Tue Feb  1 16:00:01 2011
@@ -755,7 +755,10 @@ static int balancer_post_config(apr_pool
             unsigned int index;
 
             balancer->max_workers = balancer->workers->nelts + balancer->growth;
-            ap_pstr2_alnum(pconf, balancer->name, &balancer->sname);
+            /* no need for the 'balancer://' prefix */
+            ap_pstr2_alnum(pconf, balancer->name + sizeof(BALANCER_PREFIX) - 1, 
+                           &balancer->sname);
+            balancer->sname = apr_pstrcat(pconf, conf->id, "_", balancer->sname,
NULL);
 
             /* Create global mutex */
             rv = ap_global_mutex_create(&(balancer->mutex), NULL, balancer_mutex_type,
@@ -839,6 +842,7 @@ static int balancer_handler(request_rec 
     apr_table_t *params;
     int access_status;
     int i, n;
+    int ok2change = 1;
     const char *name;
 
     /* is this for us? */
@@ -897,14 +901,11 @@ static int balancer_handler(request_rec 
         )
        ) {
         apr_table_clear(params);
+        ok2change = 0;
     }
 
     /* First set the params */
-    /*
-     * Note that it is not possible set the proxy_balancer because it is not
-     * in shared memory.
-     */
-    if (wsel) {
+    if (wsel && ok2change) {
         const char *val;
         if ((val = apr_table_get(params, "lf"))) {
             int ival = atoi(val);
@@ -940,6 +941,17 @@ static int balancer_handler(request_rec 
         }
 
     }
+
+    if (bsel && ok2change) {
+        const char *val;
+        if ((val = apr_table_get(params, "lbm"))) {
+            proxy_balancer_method *lbmethod;
+            lbmethod = ap_lookup_provider(PROXY_LBMETHOD, val, "0");
+            if (lbmethod)
+                bsel->s->lbmethod = lbmethod;
+        }
+    }
+
     if (apr_table_get(params, "xml")) {
         ap_set_content_type(r, "text/xml");
         ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n", r);
@@ -984,7 +996,11 @@ static int balancer_handler(request_rec 
         for (i = 0; i < conf->balancers->nelts; i++) {
 
             ap_rputs("<hr />\n<h3>LoadBalancer Status for ", r);
-            ap_rvputs(r, balancer->name, "</h3>\n\n", NULL);
+            ap_rvputs(r, "<a href=\"", r->uri, "?b=",
+                      balancer->name + sizeof(BALANCER_PREFIX) - 1,
+                      "&nonce=", balancer->s->nonce,
+                      "\">", NULL);
+            ap_rvputs(r, balancer->name, "</a></h3>\n\n", NULL);
             ap_rputs("\n\n<table border=\"0\" style=\"text-align: left;\"><tr>"
                 "<th>MaxMembers</th><th>StickySession</th><th>Timeout</th><th>FailoverAttempts</th><th>Method</th>"
                 "</tr>\n<tr>", r);
@@ -1089,10 +1105,40 @@ static int balancer_handler(request_rec 
                       bsel->s->nonce, "\">\n", NULL);
             ap_rvputs(r, "</form>\n", NULL);
             ap_rputs("<hr />\n", r);
+        } else if (bsel) {
+            const apr_array_header_t *provs;
+            const ap_list_provider_names_t *pname;
+            int i;
+            ap_rputs("<h3>Edit balancer settings for ", r);
+            ap_rvputs(r, bsel->name, "</h3>\n", NULL);
+            ap_rvputs(r, "<form method=\"GET\" action=\"", NULL);
+            ap_rvputs(r, r->uri, "\">\n<dl>\n<table>\n", NULL);
+            provs = ap_list_provider_names(r->pool, PROXY_LBMETHOD, "0");
+            if (provs) {
+                ap_rputs("<tr><td>LBmethod:</td>", r);
+                ap_rputs("<td>\n<select name=\"lbm\" id=\"lbm\">", r);
+                pname = (ap_list_provider_names_t *)provs->elts;
+                for (i = 0; i < provs->nelts; i++, pname++) {
+                    ap_rvputs(r,"<option value=\"", pname->provider_name, "\"", NULL);
+                    if (strcmp(pname->provider_name, bsel->s->lbmethod->name)
== 0)
+                        ap_rputs(" selected ", r);
+                    ap_rvputs(r, ">", pname->provider_name, "\n", NULL);
+                }
+                ap_rputs("</select>\n</td></tr>\n", r);
+            }
+            ap_rputs("</td></tr>\n", r);
+            ap_rputs("<tr><td colspan=2><input type=submit value=\"Submit\"></td></tr>\n",
r);
+            ap_rvputs(r, "</table>\n<input type=hidden name=\"b\" ", NULL);
+            ap_rvputs(r, "value=\"", bsel->name + sizeof(BALANCER_PREFIX) - 1,
+                      "\">\n", NULL);
+            ap_rvputs(r, "<input type=hidden name=\"nonce\" value=\"",
+                      bsel->s->nonce, "\">\n", NULL);
+            ap_rvputs(r, "</form>\n", NULL);
+            ap_rputs("<hr />\n", r);
         }
         ap_rputs(ap_psignature("",r), r);
         ap_rputs("</body></html>\n", r);
-    }
+}
     return OK;
 }
 



Mime
View raw message