httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r420986 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy_balancer.c proxy_util.c
Date Tue, 11 Jul 2006 20:39:38 GMT
Author: jim
Date: Tue Jul 11 13:39:38 2006
New Revision: 420986

URL: http://svn.apache.org/viewvc?rev=420986&view=rev
Log:

Add in hot-standby balancer member. If all other members
are disabled or not-usable, ONLY THEN will the hot
standby's be used.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
    httpd/httpd/trunk/modules/proxy/proxy_util.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=420986&r1=420985&r2=420986&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Jul 11 13:39:38 2006
@@ -213,8 +213,14 @@
                 else
                     worker->status &= ~PROXY_WORKER_IN_ERROR;
             }
+            else if (*v == 'H' || *v == 'h') {
+                if (mode)
+                    worker->status |= PROXY_WORKER_HOT_STANDBY;
+                else
+                    worker->status &= ~PROXY_WORKER_HOT_STANDBY;
+            }
             else {
-                return "Unknow status parameter option";
+                return "Unknown status parameter option";
             }
         }
     }

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=420986&r1=420985&r2=420986&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Tue Jul 11 13:39:38 2006
@@ -226,6 +226,34 @@
         }
         worker++;
     }
+    /*
+     * Check for any hot-standbys, since we have no usable workers
+     */
+    worker = (proxy_worker *)balancer->workers->elts;
+    for (i = 0; i < balancer->workers->nelts; i++) {
+        if (*(worker->s->route) && (strcmp(worker->s->route, route) ==
0) &&
+            PROXY_WORKER_IS_STANDBY(worker)) {
+            if (worker && PROXY_WORKER_IS_USABLE_STANDBY(worker)) {
+                return worker;
+            } else {
+                ap_proxy_retry_worker("BALANCER", worker, r->server);
+                if (PROXY_WORKER_IS_USABLE_STANDBY(worker)) {
+                        return worker;
+                } else {
+                    if (*worker->s->redirect) {
+                        proxy_worker *rworker = NULL;
+                        rworker = find_route_worker(balancer, worker->s->redirect,
r);
+                        if (rworker && !PROXY_WORKER_IS_USABLE_STANDBY(rworker))
{
+                            ap_proxy_retry_worker("BALANCER", rworker, r->server);
+                        }
+                        if (rworker && PROXY_WORKER_IS_USABLE_STANDBY(rworker))
+                            return rworker;
+                    }
+                }
+            }
+        }
+        worker++;
+    }
     return NULL;
 }
 
@@ -690,14 +718,20 @@
                 ap_rvputs(r, "<td>", worker->s->route, NULL);
                 ap_rvputs(r, "</td><td>", worker->s->redirect, NULL);
                 ap_rprintf(r, "</td><td>%d</td><td>", worker->s->lbfactor);
-                if (worker->s->status & PROXY_WORKER_DISABLED)
-                    ap_rputs("Dis", r);
-                else if (worker->s->status & PROXY_WORKER_IN_ERROR)
-                    ap_rputs("Err", r);
-                else if (worker->s->status & PROXY_WORKER_INITIALIZED)
+                if (PROXY_WORKER_IS_USABLE(worker))
                     ap_rputs("Ok", r);
-                else
-                    ap_rputs("-", r);
+                else {
+                    if (worker->s->status & PROXY_WORKER_DISABLED)
+                       ap_rputs("Dis ", r);
+                    if (worker->s->status & PROXY_WORKER_IN_ERROR)
+                       ap_rputs("Err ", r);
+                    if (worker->s->status & PROXY_WORKER_STOPPED)
+                       ap_rputs("Stop ", r);
+                    if (worker->s->status & PROXY_WORKER_HOT_STANDBY)
+                       ap_rputs("Stby ", r);
+                    if (!PROXY_WORKER_IS_INITIALIZED(worker))
+                        ap_rputs("-", r);
+                }
                 ap_rputs("</td></tr>\n", r);
 
                 ++worker;
@@ -876,6 +910,23 @@
         worker++;
     }
 
+    if (!mycandidate) {
+        worker = (proxy_worker *)balancer->workers->elts;
+        for (i = 0; i < balancer->workers->nelts; i++) {
+            if (PROXY_WORKER_IS_STANDBY(worker)) {
+                if (!PROXY_WORKER_IS_USABLE_STANDBY(worker))
+                    ap_proxy_retry_worker("BALANCER", worker, r->server);
+                if (PROXY_WORKER_IS_USABLE_STANDBY(worker)) {
+                    worker->s->lbstatus += worker->s->lbfactor;
+                    total_factor += worker->s->lbfactor;
+                    if (!mycandidate || worker->s->lbstatus > mycandidate->s->lbstatus)
+                        mycandidate = worker;
+                }
+            }
+            worker++;
+        }
+    }
+
     if (mycandidate) {
         mycandidate->s->lbstatus -= total_factor;
         mycandidate->s->elected++;
@@ -936,6 +987,25 @@
             }
         }
         worker++;
+    }
+
+    if (!mycandidate) {
+        worker = (proxy_worker *)balancer->workers->elts;
+        for (i = 0; i < balancer->workers->nelts; i++) {
+            if (PROXY_WORKER_IS_STANDBY(worker)) {
+                if (!PROXY_WORKER_IS_USABLE_STANDBY(worker))
+                    ap_proxy_retry_worker("BALANCER", worker, r->server);
+                if (PROXY_WORKER_IS_USABLE_STANDBY(worker)) {
+                    mytraffic = (worker->s->transferred/worker->s->lbfactor)
+
+                        (worker->s->read/worker->s->lbfactor);
+                    if (!mycandidate || mytraffic < curmin) {
+                        mycandidate = worker;
+                        curmin = mytraffic;
+                    }
+                }
+            }
+            worker++;
+        }
     }
 
     if (mycandidate) {

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=420986&r1=420985&r2=420986&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Tue Jul 11 13:39:38 2006
@@ -1764,11 +1764,11 @@
 {
     apr_status_t rv;
 
-    if (!PROXY_WORKER_IS_USABLE(worker)) {
+    if (!PROXY_WORKER_IS_USABLE_DC(worker)) {
         /* Retry the worker */
         ap_proxy_retry_worker(proxy_function, worker, s);
 
-        if (!PROXY_WORKER_IS_USABLE(worker)) {
+        if (!PROXY_WORKER_IS_USABLE_DC(worker)) {
             ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
                          "proxy: %s: disabled connection for (%s)",
                          proxy_function, worker->hostname);
@@ -2074,7 +2074,7 @@
      * Altrough some connections may be alive
      * no further connections to the worker could be made
      */
-    if (!connected && PROXY_WORKER_IS_USABLE(worker) &&
+    if (!connected && PROXY_WORKER_IS_USABLE_DC(worker) &&
         !(worker->s->status & PROXY_WORKER_IGNORE_ERRORS)) {
         worker->s->status |= PROXY_WORKER_IN_ERROR;
         worker->s->error_time = apr_time_now();



Mime
View raw message