summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2016-02-02 18:23:43 +0100
committerJim Jagielski <jim@apache.org>2016-02-02 18:23:43 +0100
commitee6d08cab15361f841d1c6c48490a7f06f0a5e24 (patch)
tree0e896945186039cf8f7e774e180fb314537f597e
parentBetter naming (diff)
downloadapache2-ee6d08cab15361f841d1c6c48490a7f06f0a5e24.tar.xz
apache2-ee6d08cab15361f841d1c6c48490a7f06f0a5e24.zip
Tie bal-man to hcheck for dynamic adjustments... right now,
actually editing not implemented yet. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728161 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--modules/proxy/mod_proxy.h3
-rw-r--r--modules/proxy/mod_proxy_balancer.c32
-rw-r--r--modules/proxy/mod_proxy_hcheck.c25
3 files changed, 54 insertions, 6 deletions
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h
index ea8eeea6b7..f1d617e461 100644
--- a/modules/proxy/mod_proxy.h
+++ b/modules/proxy/mod_proxy.h
@@ -562,8 +562,9 @@ struct proxy_balancer_method {
#define PROXY_DECLARE_DATA __declspec(dllimport)
#endif
+/* Following 3 from health check */
APR_DECLARE_OPTIONAL_FN(void, hc_show_exprs, (request_rec *));
-
+APR_DECLARE_OPTIONAL_FN(void, hc_select_exprs, (request_rec *, const char *));
APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param,
(apr_pool_t *, server_rec *, proxy_worker *,
const char *, const char *, void *));
diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c
index 143ba19173..c7f16b62b6 100644
--- a/modules/proxy/mod_proxy_balancer.c
+++ b/modules/proxy/mod_proxy_balancer.c
@@ -34,6 +34,7 @@ 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;
+static APR_OPTIONAL_FN_TYPE(hc_select_exprs) *hc_select_exprs_f = NULL;
/*
@@ -53,6 +54,7 @@ static int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
}
set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param);
hc_show_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_show_exprs);
+ hc_select_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_select_exprs);
return OK;
}
@@ -1601,7 +1603,7 @@ static int balancer_handler(request_rec *r)
"<th>Draining Mode</th>"
"<th>Disabled</th>"
"<th>Hot Standby</th>", r);
- if (set_worker_hc_param_f) {
+ if (hc_show_exprs_f) {
ap_rputs("<th>HC Fail</th>", r);
}
ap_rputs("<th>Stopped</th></tr>\n<tr>", r);
@@ -1609,12 +1611,34 @@ static int balancer_handler(request_rec *r)
create_radio("w_status_N", (PROXY_WORKER_IS(wsel, PROXY_WORKER_DRAIN)), r);
create_radio("w_status_D", (PROXY_WORKER_IS(wsel, PROXY_WORKER_DISABLED)), r);
create_radio("w_status_H", (PROXY_WORKER_IS(wsel, PROXY_WORKER_HOT_STANDBY)), r);
- if (set_worker_hc_param_f) {
+ if (hc_show_exprs_f) {
create_radio("w_status_C", (PROXY_WORKER_IS(wsel, PROXY_WORKER_HC_FAIL)), r);
}
create_radio("w_status_S", (PROXY_WORKER_IS(wsel, PROXY_WORKER_STOPPED)), r);
- ap_rputs("</tr></table>\n", r);
- ap_rputs("<tr><td colspan=2><input type=submit value='Submit'></td></tr>\n", r);
+ ap_rputs("</tr></table></td></tr>\n", r);
+ if (hc_select_exprs_f) {
+ proxy_hcmethods_t *method = proxy_hcmethods;
+ ap_rputs("<tr><td colspan='2'>\n<table align='center'><tr><th>Health Check param</th><th>Value</th></tr>\n", r);
+ ap_rputs("<tr><td>Method</td><td><select name='hcmethod'>\n", r);
+ for (; method->name; method++) {
+ if (method->implemented) {
+ ap_rprintf(r, "<option value='%s' %s >%s</option>\n",
+ method->name,
+ (wsel->s->method == method->method) ? "selected" : "",
+ method->name);
+ }
+ }
+ ap_rputs("</select>\n</td></tr>\n", r);
+ ap_rputs("<tr><td>Expr</td><td><select name='hcexpr'>\n", r);
+ hc_select_exprs_f(r, wsel->s->hcexpr);
+ ap_rputs("</select>\n</td></tr>\n", r);
+ ap_rprintf(r, "<tr><td>Interval (secs)</td><td>%d</td></tr>\n", (int)apr_time_sec(wsel->s->interval));
+ ap_rprintf(r, "<tr><td>Fails trigger</td><td>%d</td></tr>\n", wsel->s->fails);
+ ap_rprintf(r, "<tr><td>Passes trigger</td><td>%d</td></tr>\n", wsel->s->passes);
+ ap_rprintf(r, "<tr><td>HC uri</td><td>%s</td></tr>\n", wsel->s->hcuri);
+ ap_rputs("</table>\n</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='w' id='w' ", NULL);
ap_rvputs(r, "value='", ap_escape_uri(r->pool, wsel->s->name), "'>\n", NULL);
ap_rvputs(r, "<input type=hidden name='b' id='b' ", NULL);
diff --git a/modules/proxy/mod_proxy_hcheck.c b/modules/proxy/mod_proxy_hcheck.c
index 90105e3ed8..b97dd6414e 100644
--- a/modules/proxy/mod_proxy_hcheck.c
+++ b/modules/proxy/mod_proxy_hcheck.c
@@ -1011,7 +1011,7 @@ static void hc_show_exprs(request_rec *r)
return;
ap_rputs("\n\n<table>"
- "<tr><th colspan=\"2\">Health check cond. expressions:</th></tr>\n"
+ "<tr><th colspan='2'>Health check cond. expressions:</th></tr>\n"
"<tr><th>Expr name</th><th>Expression</th></tr>\n", r);
hdr = apr_table_elts(ctx->conditions);
@@ -1028,6 +1028,28 @@ static void hc_show_exprs(request_rec *r)
ap_rputs("</table><hr/>\n", r);
}
+static void hc_select_exprs(request_rec *r, const char *expr)
+{
+ 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;
+
+ hdr = apr_table_elts(ctx->conditions);
+ elts = (const apr_table_entry_t *) hdr->elts;
+ for (i = 0; i < hdr->nelts; ++i) {
+ if (!elts[i].key) {
+ continue;
+ }
+ ap_rprintf(r, "<option value='%s' %s >%s</option>\n", elts[i].key,
+ (!ap_casecmpstr(elts[i].key, expr)) ? "selected" : "",
+ elts[i].key);
+ }
+}
+
static const char *hc_get_body(request_rec *r)
{
apr_off_t length;
@@ -1115,6 +1137,7 @@ static void hc_register_hooks(apr_pool_t *p)
static const char *const aszSucc[] = { "mod_watchdog.c", NULL};
APR_REGISTER_OPTIONAL_FN(set_worker_hc_param);
APR_REGISTER_OPTIONAL_FN(hc_show_exprs);
+ APR_REGISTER_OPTIONAL_FN(hc_select_exprs);
ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST);
ap_hook_expr_lookup(hc_expr_lookup, NULL, NULL, APR_HOOK_MIDDLE);
}