From 57a654ffe71ee60f75c1ae9fc0455f98168cc39f Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Wed, 2 Feb 2011 14:39:48 +0000 Subject: [PATCH] Instead of just enabling/disabling, we can now adjust more useful worker status bits, such as whether hot stby, etc... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1066482 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy.c | 9 +- modules/proxy/mod_proxy_balancer.c | 144 ++++++++++++++++------------- 2 files changed, 82 insertions(+), 71 deletions(-) diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 32b97cebe5..969da8da42 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -2332,14 +2332,7 @@ static int proxy_status_hook(request_rec *r, int flags) char fbuf[50]; ap_rvputs(r, "\n", (*worker)->s->scheme, "", NULL); ap_rvputs(r, "", (*worker)->s->hostname, "", NULL); - 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) - ap_rputs("Ok", r); - else - ap_rputs("-", r); + ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, *worker), NULL); ap_rvputs(r, "", (*worker)->s->route, NULL); ap_rvputs(r, "", (*worker)->s->redirect, NULL); ap_rprintf(r, "%d", (*worker)->s->lbfactor); diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 8ea81c9378..6f29133ee1 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -830,6 +830,18 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog, return OK; } +static void create_radio(const char *name, unsigned int flag, proxy_worker *w, + request_rec *r) +{ + ap_rvputs(r, "Set s->status & flag) + ap_rputs(" checked", r); + ap_rvputs(r, ">
Clear s->status & flag)) + ap_rputs(" checked", r); + ap_rputs(">\n", r); +} + /* Manages the loadfactors and member status */ static int balancer_handler(request_rec *r) @@ -927,11 +939,17 @@ static int balancer_handler(request_rec *r) else *wsel->s->redirect = '\0'; } - if ((val = apr_table_get(params, "dw"))) { - if (!strcasecmp(val, "Disable")) - wsel->s->status |= PROXY_WORKER_DISABLED; - else if (!strcasecmp(val, "Enable")) - wsel->s->status &= ~PROXY_WORKER_DISABLED; + if ((val = apr_table_get(params, "status_I"))) { + ap_proxy_set_wstatus('I', atoi(val), wsel); + } + if ((val = apr_table_get(params, "status_N"))) { + ap_proxy_set_wstatus('N', atoi(val), wsel); + } + if ((val = apr_table_get(params, "status_D"))) { + ap_proxy_set_wstatus('D', atoi(val), wsel); + } + if ((val = apr_table_get(params, "status_H"))) { + ap_proxy_set_wstatus('H', atoi(val), wsel); } if ((val = apr_table_get(params, "ls"))) { int ival = atoi(val); @@ -954,8 +972,8 @@ static int balancer_handler(request_rec *r) if (apr_table_get(params, "xml")) { ap_set_content_type(r, "text/xml"); - ap_rputs("\n", r); - ap_rputs("\n", r); + ap_rputs("\n", r); + ap_rputs("\n", r); ap_rputs(" \n", r); balancer = (proxy_balancer *)conf->balancers->elts; for (i = 0; i < conf->balancers->nelts; i++) { @@ -996,34 +1014,34 @@ static int balancer_handler(request_rec *r) for (i = 0; i < conf->balancers->nelts; i++) { ap_rputs("
\n

LoadBalancer Status for ", r); - ap_rvputs(r, "uri, "?b=", + ap_rvputs(r, "", NULL); ap_rvputs(r, balancer->name, "

\n\n", NULL); - ap_rputs("\n\n" + ap_rputs("\n\n
" "" "\n", r); - ap_rprintf(r, "\n", balancer->max_workers); + ap_rprintf(r, "\n", balancer->max_workers); if (*balancer->s->sticky) { if (strcmp(balancer->s->sticky, balancer->s->sticky_path)) { - ap_rvputs(r, "", + ap_rprintf(r, "", apr_time_sec(balancer->s->timeout)); - ap_rprintf(r, "\n", balancer->s->max_attempts); - ap_rprintf(r, "\n", + ap_rprintf(r, "\n", balancer->s->max_attempts); + ap_rprintf(r, "\n", balancer->s->lbmethod->name); ap_rputs("
MaxMembersStickySessionTimeoutFailoverAttemptsMethod
%d%d", balancer->s->sticky, " | ", + ap_rvputs(r, "", balancer->s->sticky, " | ", balancer->s->sticky_path, NULL); } else { - ap_rvputs(r, "", balancer->s->sticky, NULL); + ap_rvputs(r, "", balancer->s->sticky, NULL); } } else { - ap_rputs(" - ", r); + ap_rputs(" - ", r); } - ap_rprintf(r, "%" APR_TIME_T_FMT "%" APR_TIME_T_FMT "%d%s%d%s
\n
", r); - ap_rputs("\n\n" + ap_rputs("\n\n
" "" "" "" @@ -1034,23 +1052,23 @@ static int balancer_handler(request_rec *r) for (n = 0; n < balancer->workers->nelts; n++) { char fbuf[50]; worker = *workers; - ap_rvputs(r, "\n\n", NULL); - ap_rvputs(r, "", worker->s->lbfactor); - ap_rprintf(r, "", worker->s->lbfactor); + ap_rprintf(r, "", r); - ap_rprintf(r, "\n", r); @@ -1063,35 +1081,35 @@ static int balancer_handler(request_rec *r) if (wsel && bsel) { ap_rputs("

Edit worker settings for ", r); ap_rvputs(r, wsel->s->name, "

\n", NULL); - ap_rvputs(r, "uri, "\">\n
", NULL); - ap_rputs("
Worker URLRouteRouteRedirFactorSetStatus
uri, "?b=", + ap_rvputs(r, "
", NULL); ap_rvputs(r, worker->s->name, "", ap_escape_html(r->pool, worker->s->route), + ap_rvputs(r, "", ap_escape_html(r->pool, worker->s->route), NULL); - ap_rvputs(r, "", + ap_rvputs(r, "", ap_escape_html(r->pool, worker->s->redirect), NULL); - ap_rprintf(r, "%d%d", worker->s->lbset); + ap_rprintf(r, "%d%d", worker->s->lbset); ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, worker), NULL); ap_rputs("%" APR_SIZE_T_FMT "", worker->s->elected); + ap_rprintf(r, "%" APR_SIZE_T_FMT "", worker->s->elected); ap_rputs(apr_strfsize(worker->s->transferred, fbuf), r); - ap_rputs("", r); + ap_rputs("", r); ap_rputs(apr_strfsize(worker->s->read, fbuf), r); ap_rputs("
\n", wsel->s->lbfactor); - ap_rputs("\n", wsel->s->lbset); - ap_rputs("\n", r); + ap_rvputs(r, "
Load factor:
LB Set:
Route:pool, wsel->s->route), + ap_rvputs(r, "\n
", NULL); + ap_rputs("\n", wsel->s->lbfactor); + ap_rputs("\n", wsel->s->lbset); + ap_rputs("\n", r); + ap_rputs("\n", r); + ap_rputs("", r); + ap_rputs("\n", r); + ap_rvputs(r, "
Load factor:
LB Set:
Route:
Route Redirect:
Status:\n", r); + create_radio("status_I", PROXY_WORKER_IGNORE_ERRORS, wsel, r); + create_radio("status_N", PROXY_WORKER_DRAIN, wsel, r); + create_radio("status_D", PROXY_WORKER_DISABLED, wsel, r); + create_radio("status_H", PROXY_WORKER_HOT_STANDBY, wsel, r); + ap_rputs("
IgnDrnDisStby
\n", r); + ap_rputs("
\n\n", NULL); + ap_rvputs(r, "\n", NULL); + ap_rvputs(r, "\n", NULL); ap_rvputs(r, "\n", NULL); ap_rputs("
\n", r); } else if (bsel) { @@ -1100,15 +1118,15 @@ static int balancer_handler(request_rec *r) int i; ap_rputs("

Edit balancer settings for ", r); ap_rvputs(r, bsel->name, "

\n", NULL); - ap_rvputs(r, "
uri, "\">\n
\n\n", NULL); + ap_rvputs(r, "\n
\n
\n", NULL); provs = ap_list_provider_names(r->pool, PROXY_LBMETHOD, "0"); if (provs) { ap_rputs("", r); - ap_rputs("\n", r); } ap_rputs("\n", r); - ap_rputs("\n", r); - ap_rvputs(r, "
LBmethod:\n\n\n
\nname + sizeof(BALANCER_PREFIX) - 1, - "\">\n", NULL); - ap_rvputs(r, "s->nonce, "\">\n", NULL); + ap_rputs("
\n\n", NULL); + ap_rvputs(r, "\n", NULL); ap_rvputs(r, "\n", NULL); ap_rputs("
\n", r); } -- 2.40.0