1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

Add updatelbstatus to allow to have all the LB logic in the balancers.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@936828 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Frederic Clere
2010-04-22 13:13:40 +00:00
parent 66e7158c3d
commit 4c4b534813
2 changed files with 25 additions and 21 deletions

View File

@@ -383,6 +383,7 @@ struct proxy_balancer_method {
void *context; /* general purpose storage */ void *context; /* general purpose storage */
apr_status_t (*reset)(proxy_balancer *balancer, server_rec *s); apr_status_t (*reset)(proxy_balancer *balancer, server_rec *s);
apr_status_t (*age)(proxy_balancer *balancer, server_rec *s); apr_status_t (*age)(proxy_balancer *balancer, server_rec *s);
apr_status_t (*updatelbstatus)(proxy_balancer *balancer, proxy_worker *elected, server_rec *s);
}; };
#if APR_HAS_THREADS #if APR_HAS_THREADS

View File

@@ -471,28 +471,31 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
/* Step 4: find the session route */ /* Step 4: find the session route */
runtime = find_session_route(*balancer, r, &route, &sticky, url); runtime = find_session_route(*balancer, r, &route, &sticky, url);
if (runtime) { if (runtime) {
int i, total_factor = 0; if ((*balancer)->lbmethod && (*balancer)->lbmethod->updatelbstatus) {
proxy_worker **workers; /* Call the LB implementation */
/* We have a sticky load balancer (*balancer)->lbmethod->updatelbstatus(*balancer, runtime, r->server);
* Update the workers status }
* so that even session routes get else { /* Use the default one */
* into account. int i, total_factor = 0;
*/ proxy_worker **workers;
workers = (proxy_worker **)(*balancer)->workers->elts; /* We have a sticky load balancer
for (i = 0; i < (*balancer)->workers->nelts; i++) { * Update the workers status
/* Take into calculation only the workers that are * so that even session routes get
* not in error state or not disabled. * into account.
* */
* TODO: Abstract the below, since this is dependent workers = (proxy_worker **)(*balancer)->workers->elts;
* on the LB implementation for (i = 0; i < (*balancer)->workers->nelts; i++) {
*/ /* Take into calculation only the workers that are
if (PROXY_WORKER_IS_USABLE(*workers)) { * not in error state or not disabled.
(*workers)->s->lbstatus += (*workers)->s->lbfactor; */
total_factor += (*workers)->s->lbfactor; if (PROXY_WORKER_IS_USABLE(*workers)) {
} (*workers)->s->lbstatus += (*workers)->s->lbfactor;
workers++; total_factor += (*workers)->s->lbfactor;
}
workers++;
}
runtime->s->lbstatus -= total_factor;
} }
runtime->s->lbstatus -= total_factor;
runtime->s->elected++; runtime->s->elected++;
*worker = runtime; *worker = runtime;