From a107563a23ace17d960982c1b3227deb9bf87f5c Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 19 Jan 2016 20:48:33 +0000 Subject: [PATCH] And make the list of health check conditions viewable via the balancer manager :) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725609 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy.h | 3 +++ modules/proxy/mod_proxy_balancer.c | 7 +++++++ modules/proxy/mod_proxy_hcheck.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 125a8fa3f0..f6312fd459 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -552,10 +552,13 @@ struct proxy_balancer_method { #define PROXY_DECLARE_DATA __declspec(dllimport) #endif +APR_DECLARE_OPTIONAL_FN(void, hc_show_exprs, (request_rec *)); + APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param, (apr_pool_t *, server_rec *, proxy_worker *, const char *, const char *, void *)); + APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r, proxy_worker *worker, proxy_server_conf *conf, char *url, const char *proxyhost, apr_port_t proxyport)) diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index f1c0a6f146..e1d518f96b 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -33,6 +33,9 @@ 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; +static APR_OPTIONAL_FN_TYPE(hc_show_exprs) *hc_show_exprs_f = NULL; + + /* * Register our mutex type before the config is read so we * can adjust the mutex settings using the Mutex directive. @@ -49,6 +52,7 @@ static int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog, return rv; } set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param); + hc_show_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_show_exprs); return OK; } @@ -1572,6 +1576,9 @@ static int balancer_handler(request_rec *r) ++balancer; } ap_rputs("
\n", r); + if (hc_show_exprs_f) { + hc_show_exprs_f(r); + } if (wsel && bsel) { ap_rputs("

Edit worker settings for ", r); ap_rvputs(r, (*wsel->s->uds_path?"":""), ap_proxy_worker_name(r->pool, wsel), (*wsel->s->uds_path?"":""), "

\n", NULL); diff --git a/modules/proxy/mod_proxy_hcheck.c b/modules/proxy/mod_proxy_hcheck.c index 67d018f526..b40c3b5eb9 100644 --- a/modules/proxy/mod_proxy_hcheck.c +++ b/modules/proxy/mod_proxy_hcheck.c @@ -824,6 +824,34 @@ static int hc_post_config(apr_pool_t *p, apr_pool_t *plog, return OK; } +static void hc_show_exprs(request_rec *r) +{ + const apr_table_entry_t *elts; + const apr_array_header_t *hdr; + int i; + sctx_t *ctx = (sctx_t *) ap_get_module_config(r->server->module_config, + &proxy_hcheck_module); + if (apr_is_empty_table(ctx->conditions)) + return; + + ap_rputs("\n\n" + "\n" + "\n", r); + + hdr = apr_table_elts(ctx->conditions); + elts = (const apr_table_entry_t *) hdr->elts; + for (i = 0; i < hdr->nelts; ++i) { + hc_condition_t *cond; + if (!elts[i].key) { + continue; + } + cond = (hc_condition_t *)elts[i].val; + ap_rprintf(r, "\n", elts[i].key, + cond->expr); + } + ap_rputs("
Health check cond. expressions:
Expr nameExpression
%s%s

\n", r); +} + static const command_rec command_table[] = { AP_INIT_RAW_ARGS("ProxyHCTemplate", set_hc_template, NULL, OR_FILEINFO, "Health check template"), @@ -837,6 +865,7 @@ static void hc_register_hooks(apr_pool_t *p) 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); + APR_REGISTER_OPTIONAL_FN(hc_show_exprs); ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST); } -- 2.40.0