You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2006/03/20 11:12:56 UTC
svn commit: r387178 -
/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
Author: mturk
Date: Mon Mar 20 02:12:54 2006
New Revision: 387178
URL: http://svn.apache.org/viewcvs?rev=387178&view=rev
Log:
Add missing bussines logic for innner domain
lb election. Also remove useless check for negative
busy values. They are handled correctly now.
Modified:
tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewcvs/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c?rev=387178&r1=387177&r2=387178&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Mon Mar 20 02:12:54 2006
@@ -38,7 +38,6 @@
* The load balancing code in this
*/
-
/*
* Time to wait before retry...
*/
@@ -227,6 +226,9 @@
int total_factor = 0;
jk_u64_t mytraffic = 0;
jk_u64_t curmin = 0;
+ int bfn = 1;
+ int bfd = 1;
+
worker_record_t *candidate = NULL;
if (p->lbmethod == JK_LB_BYTRAFFIC) {
@@ -242,7 +244,6 @@
}
}
}
-
/* First try to see if we have available candidate */
for (i = 0; i < p->num_of_workers; i++) {
/* Skip all workers that are not member of domain */
@@ -259,7 +260,7 @@
if (!candidate || p->lb_workers[i].s->lb_value > candidate->s->lb_value)
candidate = &p->lb_workers[i];
}
- else {
+ else if (p->lbmethod == JK_LB_BYTRAFFIC) {
mytraffic = (p->lb_workers[i].s->transferred +
p->lb_workers[i].s->readed ) / p->lb_workers[i].s->lb_factor;
if (!candidate || mytraffic < curmin) {
@@ -267,6 +268,18 @@
curmin = mytraffic;
}
}
+ else {
+ /* compare rational numbers: (a/b) < (c/d) iff a*d < c*b
+ */
+ int left = p->lb_workers[i].s->busy * bfd;
+ int right = bfn * p->lb_workers[i].s->lb_factor;
+
+ if (!candidate || (left < right)) {
+ candidate = &p->lb_workers[i];
+ bfn = p->lb_workers[i].s->busy;
+ bfd = p->lb_workers[i].s->lb_factor;
+ }
+ }
}
}
@@ -368,8 +381,6 @@
unsigned int offset;
int bfn = 1; /* Numerator of best busy factor */
int bfd = 1; /* Denominator of best busy factor */
- int curn; /* Numerator of current busy factor */
- int curd; /* Denominator of current busy factor */
int left; /* left and right are used to compare rational numbers */
int right;
@@ -397,32 +408,15 @@
* not in error state, stopped or not disabled.
*/
if (JK_WORKER_USABLE(p->lb_workers[i].s)) {
- curn = p->lb_workers[i].s->busy;
- curd = p->lb_workers[i].s->lb_factor;
-
- /* If the server is restarted under load there is a bug that causes
- * busy to be reset to zero before all the outstanding connections
- * finish, they then finally finish. As a result, the busy value
- * becomes negative, messing up the busyness load balancing.
- * When this bug is fixed, this section can be removed
- */
- if (curn < 0) {
- jk_log(l, JK_LOG_WARNING,
- "busy value is %d for worker %s, resetting it to zero",
- curn, p->lb_workers[i].s->name);
- p->lb_workers[i].s->busy = 0;
- curn = 0;
- }
-
/* compare rational numbers: (a/b) < (c/d) iff a*d < c*b
*/
- left = curn * bfd;
- right = bfn * curd;
+ left = p->lb_workers[i].s->busy * bfd;
+ right = bfn * p->lb_workers[i].s->lb_factor;
if (!candidate || (left < right)) {
candidate = &p->lb_workers[i];
- bfn = curn;
- bfd = curd;
+ bfn = p->lb_workers[i].s->busy;
+ bfd = p->lb_workers[i].s->lb_factor;
next_offset = i + 1;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org