From b32eb3a6afe98616ed14fd35a2c7040d2e276acf Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Fri, 4 Feb 2011 13:50:39 +0000 Subject: [PATCH] And yet more balancer params that can be changed at runtime via the b-m application... next up, of course, is adding new workers ;) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1067178 13f79535-47bb-0310-9956-ffa450edef68 --- modules/proxy/mod_proxy_balancer.c | 85 +++++++++++++++++++----------- 1 file changed, 54 insertions(+), 31 deletions(-) diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 91c51f7fcd..09df282647 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -835,14 +835,13 @@ 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) +static void create_radio(const char *name, unsigned int flag, request_rec *r) { - ap_rvputs(r, "Set s->status & flag) + ap_rvputs(r, "On
Clear s->status & flag)) + ap_rvputs(r, ">
Off \n", r); } @@ -924,7 +923,7 @@ static int balancer_handler(request_rec *r) /* First set the params */ if (wsel && ok2change) { const char *val; - if ((val = apr_table_get(params, "lf"))) { + if ((val = apr_table_get(params, "w_lf"))) { int ival = atoi(val); if (ival >= 1 && ival <= 100) { wsel->s->lbfactor = ival; @@ -932,31 +931,31 @@ static int balancer_handler(request_rec *r) recalc_factors(bsel); } } - if ((val = apr_table_get(params, "wr"))) { + if ((val = apr_table_get(params, "w_wr"))) { if (strlen(val) && strlen(val) < sizeof(wsel->s->route)) strcpy(wsel->s->route, val); else *wsel->s->route = '\0'; } - if ((val = apr_table_get(params, "rr"))) { + if ((val = apr_table_get(params, "w_rr"))) { if (strlen(val) && strlen(val) < sizeof(wsel->s->redirect)) strcpy(wsel->s->redirect, val); else *wsel->s->redirect = '\0'; } - if ((val = apr_table_get(params, "status_I"))) { + if ((val = apr_table_get(params, "w_status_I"))) { ap_proxy_set_wstatus('I', atoi(val), wsel); } - if ((val = apr_table_get(params, "status_N"))) { + if ((val = apr_table_get(params, "w_status_N"))) { ap_proxy_set_wstatus('N', atoi(val), wsel); } - if ((val = apr_table_get(params, "status_D"))) { + if ((val = apr_table_get(params, "w_status_D"))) { ap_proxy_set_wstatus('D', atoi(val), wsel); } - if ((val = apr_table_get(params, "status_H"))) { + if ((val = apr_table_get(params, "w_status_H"))) { ap_proxy_set_wstatus('H', atoi(val), wsel); } - if ((val = apr_table_get(params, "ls"))) { + if ((val = apr_table_get(params, "w_ls"))) { int ival = atoi(val); if (ival >= 0 && ival <= 99) { wsel->s->lbset = ival; @@ -967,12 +966,29 @@ static int balancer_handler(request_rec *r) if (bsel && ok2change) { const char *val; - if ((val = apr_table_get(params, "lbm"))) { + int ival; + if ((val = apr_table_get(params, "b_lbm"))) { proxy_balancer_method *lbmethod; lbmethod = ap_lookup_provider(PROXY_LBMETHOD, val, "0"); if (lbmethod) bsel->s->lbmethod = lbmethod; } + if ((val = apr_table_get(params, "b_tmo"))) { + ival = atoi(val); + if (ival >= 0 && ival <= 7200) { /* 2 hrs enuff? */ + bsel->s->timeout = apr_time_from_sec(ival); + } + } + if ((val = apr_table_get(params, "b_max"))) { + ival = atoi(val); + if (ival >= 0 && ival <= 99) { + bsel->s->max_attempts = ival; + } + } + if ((val = apr_table_get(params, "b_sforce"))) { + ival = atoi(val); + bsel->s->sticky_force = (ival != 0); + } } if (apr_table_get(params, "xml")) { @@ -1025,7 +1041,7 @@ static int balancer_handler(request_rec *r) "'>", NULL); ap_rvputs(r, balancer->name, "\n\n", NULL); ap_rputs("\n\n" - "" + "" "\n", r); ap_rprintf(r, "\n", balancer->max_workers); if (*balancer->s->sticky) { @@ -1040,6 +1056,8 @@ static int balancer_handler(request_rec *r) else { ap_rputs("\n", + balancer->s->sticky_force ? "On" : "Off"); ap_rprintf(r, "", apr_time_sec(balancer->s->timeout)); ap_rprintf(r, "\n", balancer->s->max_attempts); @@ -1088,32 +1106,32 @@ static int balancer_handler(request_rec *r) ap_rvputs(r, wsel->s->name, "\n", NULL); ap_rvputs(r, "\n
", NULL); - ap_rputs("
MaxMembersStickySessionTimeoutFailoverAttemptsMethodMaxMembersStickySessionDisableFailoverTimeoutFailoverAttemptsMethod
%d - ", r); } + ap_rprintf(r, "%s%" APR_TIME_T_FMT "%d
\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:
Load factor:
LB Set:LB Set:
Route:Route:
Route Redirect: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); + create_radio("w_status_I", (PROXY_WORKER_IGNORE_ERRORS & wsel->s->status), r); + create_radio("w_status_N", (PROXY_WORKER_DRAIN & wsel->s->status), r); + create_radio("w_status_D", (PROXY_WORKER_DISABLED & wsel->s->status), r); + create_radio("w_status_H", (PROXY_WORKER_HOT_STANDBY & wsel->s->status), r); ap_rputs("
IgnDrnDisStby
\n", r); ap_rputs("
\n\n\n", NULL); - ap_rvputs(r, "\n", NULL); - ap_rvputs(r, "\n", NULL); ap_rvputs(r, "\n", NULL); ap_rputs("
\n", r); @@ -1128,7 +1146,7 @@ static int balancer_handler(request_rec *r) provs = ap_list_provider_names(r->pool, PROXY_LBMETHOD, "0"); if (provs) { ap_rputs("LBmethod:", r); - ap_rputs("\n", r); pname = (ap_list_provider_names_t *)provs->elts; for (i = 0; i < provs->nelts; i++, pname++) { ap_rvputs(r,"