You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2016/01/17 21:12:09 UTC
svn commit: r1725120 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.h
mod_proxy_balancer.c mod_proxy_hcheck.c proxy_util.c
Author: jim
Date: Sun Jan 17 20:12:09 2016
New Revision: 1725120
URL: http://svn.apache.org/viewvc?rev=1725120&view=rev
Log:
Make balancer manager health-check aware
Modified:
httpd/httpd/trunk/modules/proxy/mod_proxy.h
httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c
httpd/httpd/trunk/modules/proxy/proxy_util.c
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1725120&r1=1725119&r2=1725120&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Sun Jan 17 20:12:09 2016
@@ -446,6 +446,11 @@ struct proxy_worker {
void *context; /* general purpose storage */
};
+/* default to health check every 30 seconds */
+#define HCHECK_WATHCHDOG_DEFAULT_INTERVAL (30)
+/* The watchdog runs every 5 seconds, which is also the minimal check */
+#define HCHECK_WATHCHDOG_INTERVAL (5)
+
/*
* Time to wait (in microseconds) to find out if more data is currently
* available at the backend.
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=1725120&r1=1725119&r2=1725120&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Sun Jan 17 20:12:09 2016
@@ -28,6 +28,8 @@ ap_slotmem_provider_t *storage = NULL;
module AP_MODULE_DECLARE_DATA proxy_balancer_module;
+static APR_OPTIONAL_FN_TYPE(set_worker_hc_param) *set_worker_hc_param_f = NULL;
+
static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
proxy_worker *worker, server_rec *s) = NULL;
@@ -46,7 +48,7 @@ static int balancer_pre_config(apr_pool_
if (rv != APR_SUCCESS) {
return rv;
}
-
+ set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param);
return OK;
}
@@ -971,6 +973,17 @@ static void push2table(const char *input
}
}
+static const char *show_hcmethod(hcmethod_t method)
+{
+ hcmethods_t *m = hcmethods;
+ for (; m->name; m++) {
+ if (m->method == method) {
+ return m->name;
+ }
+ }
+ return "???";
+}
+
/* Manages the loadfactors and member status
* The balancer, worker and nonce are obtained from
* the request args (?b=...&w=...&nonce=....).
@@ -1449,7 +1462,7 @@ static int balancer_handler(request_rec
" padding: 2px;\n"
" border-style: dotted;\n"
" border-color: gray;\n"
- " background-color: white;\n"
+ " background-color: lightgray;\n"
" text-align: center;\n"
"}\n"
"td {\n"
@@ -1522,8 +1535,11 @@ static int balancer_handler(request_rec
"<th>Worker URL</th>"
"<th>Route</th><th>RouteRedir</th>"
"<th>Factor</th><th>Set</th><th>Status</th>"
- "<th>Elected</th><th>Busy</th><th>Load</th><th>To</th><th>From</th>"
- "</tr>\n", r);
+ "<th>Elected</th><th>Busy</th><th>Load</th><th>To</th><th>From</th>", r);
+ if (set_worker_hc_param_f) {
+ ap_rputs("<th>Method</th><th>Interval</th><th>Passes</th><th>Fails</th><th>URI</th>", r);
+ }
+ ap_rputs("</tr>\n", r);
workers = (proxy_worker **)balancer->workers->elts;
for (n = 0; n < balancer->workers->nelts; n++) {
@@ -1551,6 +1567,13 @@ static int balancer_handler(request_rec
ap_rputs(apr_strfsize(worker->s->transferred, fbuf), r);
ap_rputs("</td><td>", r);
ap_rputs(apr_strfsize(worker->s->read, fbuf), r);
+ if (set_worker_hc_param_f) {
+ ap_rprintf(r, "</td><td>%s</td>", show_hcmethod(worker->s->method));
+ ap_rprintf(r, "<td>%d</td>", (int)apr_time_sec(worker->s->interval));
+ ap_rprintf(r, "<td>%d</td>", worker->s->passes);
+ ap_rprintf(r, "<td>%d</td>", worker->s->fails);
+ ap_rprintf(r, "<td>%s", worker->s->hcuri);
+ }
ap_rputs("</td></tr>\n", r);
++workers;
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c?rev=1725120&r1=1725119&r2=1725120&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c Sun Jan 17 20:12:09 2016
@@ -22,10 +22,6 @@
module AP_MODULE_DECLARE_DATA proxy_hcheck_module;
#define HCHECK_WATHCHDOG_NAME ("_proxy_hcheck_")
-/* default to health check every 30 seconds */
-#define HCHECK_WATHCHDOG_DEFAULT_INTERVAL (30)
-/* The watchdog runs every 5 seconds, which is also the minimal check */
-#define HCHECK_WATHCHDOG_INTERVAL (5)
typedef struct {
char *name;
@@ -126,7 +122,6 @@ static apr_status_t hc_init_worker(sctx_
worker->s->hostname, (int)worker->s->port);
return err;
}
- worker->s->interval = apr_time_from_sec(HCHECK_WATHCHDOG_DEFAULT_INTERVAL);
}
return APR_SUCCESS;
}
@@ -517,10 +512,10 @@ static const command_rec command_table[]
static void hc_register_hooks(apr_pool_t *p)
{
- static const char *const runAfter[] = { "mod_proxy_balancer.c", "mod_proxy.c", NULL};
- static const char *const runBefore[] = { "mod_watchdog.c", NULL};
+ static const char *const aszPre[] = { "mod_proxy_balancer.c", "mod_proxy.c", NULL};
+ static const char *const aszSucc[] = { "mod_watchdog.c", NULL};
APR_REGISTER_OPTIONAL_FN(set_worker_hc_param);
- ap_hook_post_config(hc_post_config, runAfter, runBefore, APR_HOOK_LAST);
+ ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST);
}
/* the main config structure */
Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1725120&r1=1725119&r2=1725120&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Sun Jan 17 20:12:09 2016
@@ -1761,6 +1761,9 @@ PROXY_DECLARE(char *) ap_proxy_define_wo
wshared->flush_wait = PROXY_FLUSH_WAIT;
wshared->is_address_reusable = 1;
wshared->lbfactor = 1;
+ wshared->passes = 1;
+ wshared->fails = 1;
+ wshared->interval = apr_time_from_sec(HCHECK_WATHCHDOG_DEFAULT_INTERVAL);
wshared->smax = -1;
wshared->hash.def = ap_proxy_hashfunc(wshared->name, PROXY_HASHFUNC_DEFAULT);
wshared->hash.fnv = ap_proxy_hashfunc(wshared->name, PROXY_HASHFUNC_FNV);