You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2011/09/23 02:46:56 UTC

svn commit: r1174468 - /tomcat/jk/trunk/native/common/jk_lb_worker.c

Author: rjung
Date: Fri Sep 23 00:46:55 2011
New Revision: 1174468

URL: http://svn.apache.org/viewvc?rev=1174468&view=rev
Log:
When using the alternate decay for the "Next"
session lb method, calculate curmin only for
active workers. Otherwise curmin will quickly
stabilize at "0".

Decay non-active workers as well so that they
do not report fantasy values.

Modified:
    tomcat/jk/trunk/native/common/jk_lb_worker.c

Modified: tomcat/jk/trunk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_lb_worker.c?rev=1174468&r1=1174467&r2=1174468&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_lb_worker.c (original)
+++ tomcat/jk/trunk/native/common/jk_lb_worker.c Fri Sep 23 00:46:55 2011
@@ -624,7 +624,7 @@ static jk_uint64_t decay_load(lb_worker_
 {
     unsigned int i;
     jk_uint64_t curmax = 0;
-    jk_uint64_t curmin;
+    jk_uint64_t curmin = 0;
     lb_sub_worker_t *w;
     ajp_worker_t *aw;
 
@@ -636,9 +636,6 @@ static jk_uint64_t decay_load(lb_worker_
             if (p->lbmethod != JK_LB_METHOD_NEXT) {
                 w->s->lb_value >>= exponent;
             }
-            if (w->s->lb_value < curmin) {
-                curmin = w->s->lb_value;
-            }
             if (w->s->lb_value > curmax) {
                 curmax = w->s->lb_value;
             }
@@ -649,7 +646,23 @@ static jk_uint64_t decay_load(lb_worker_
     if (p->lbmethod == JK_LB_METHOD_NEXT) {
         for (i = 0; i < p->num_of_workers; i++) {
             w = &p->lb_workers[i];
-            w->s->lb_value -= curmin;
+            /* Take into account only the workers that are
+             * not in error state, stopped, disabled or busy.
+             * Unfortunately we can not respect activations
+             * defined by mapping rules here.
+             */
+            if (JK_WORKER_USABLE(w->s->state, w->activation)) {
+                if (curmin == 0 || w->s->lb_value < curmin) {
+                    curmin = w->s->lb_value;
+                }
+            }
+        }
+        for (i = 0; i < p->num_of_workers; i++) {
+            w = &p->lb_workers[i];
+            if (w->s->lb_value >= curmin)
+                w->s->lb_value -= curmin;
+            else
+                w->s->lb_value = 0;
         }
     }
     JK_TRACE_EXIT(l);
@@ -752,7 +765,7 @@ static int find_best_bydomain(jk_ws_serv
             strlen(wr.domain) != domain_len ||
             strncmp(wr.domain, route_or_domain, domain_len))
             continue;
-        /* Take into calculation only the workers that are
+        /* Take into account only the workers that are
          * not in error state, stopped, disabled or busy.
          */
         activation = s->extension.activation ?
@@ -802,7 +815,7 @@ static int find_best_byvalue(jk_ws_servi
         if (activation == JK_LB_ACTIVATION_UNSET)
             activation = wr.activation;
 
-        /* Take into calculation only the workers that are
+        /* Take into account only the workers that are
          * not in error state, stopped, disabled or busy.
          */
         if (JK_WORKER_USABLE(states[wr.i], activation)) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1174468 - /tomcat/jk/trunk/native/common/jk_lb_worker.c

Posted by Rainer Jung <ra...@kippdata.de>.
On 23.09.2011 16:47, Konstantin Kolinko wrote:
> 2011/9/23  <rj...@apache.org>:
>> Author: rjung
>> Date: Fri Sep 23 00:46:55 2011
>> New Revision: 1174468
>>
>> URL: http://svn.apache.org/viewvc?rev=1174468&view=rev
>> Log:
>> When using the alternate decay for the "Next"
>> session lb method, calculate curmin only for
>> active workers. Otherwise curmin will quickly
>> stabilize at "0".
>>
>> Decay non-active workers as well so that they
>> do not report fantasy values.
>>
>> Modified:
>>    tomcat/jk/trunk/native/common/jk_lb_worker.c
>>
>> Modified: tomcat/jk/trunk/native/common/jk_lb_worker.c
>> URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_lb_worker.c?rev=1174468&r1=1174467&r2=1174468&view=diff
>> ==============================================================================
>> --- tomcat/jk/trunk/native/common/jk_lb_worker.c (original)
>> +++ tomcat/jk/trunk/native/common/jk_lb_worker.c Fri Sep 23 00:46:55 2011
>> @@ -624,7 +624,7 @@ static jk_uint64_t decay_load(lb_worker_
>>  {
>>     unsigned int i;
>>     jk_uint64_t curmax = 0;
>> -    jk_uint64_t curmin;
>> +    jk_uint64_t curmin = 0;
>>     lb_sub_worker_t *w;
>>     ajp_worker_t *aw;
>>
>> @@ -636,9 +636,6 @@ static jk_uint64_t decay_load(lb_worker_
>>             if (p->lbmethod != JK_LB_METHOD_NEXT) {
>>                 w->s->lb_value >>= exponent;
>>             }
>> -            if (w->s->lb_value < curmin) {
>> -                curmin = w->s->lb_value;
>> -            }
> 
> The initial value of curmin is assigned above the loop:
> curmin = (&p->lb_workers[0])->s->lb_value;
> 
> I think you can remove that assignment. It happens without checking
> with "JK_WORKER_USABLE()" and thus contradicts with the new code
> below.

Correct, not removing the line was an oversight. It's gone with r1174830.

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1174468 - /tomcat/jk/trunk/native/common/jk_lb_worker.c

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/9/23  <rj...@apache.org>:
> Author: rjung
> Date: Fri Sep 23 00:46:55 2011
> New Revision: 1174468
>
> URL: http://svn.apache.org/viewvc?rev=1174468&view=rev
> Log:
> When using the alternate decay for the "Next"
> session lb method, calculate curmin only for
> active workers. Otherwise curmin will quickly
> stabilize at "0".
>
> Decay non-active workers as well so that they
> do not report fantasy values.
>
> Modified:
>    tomcat/jk/trunk/native/common/jk_lb_worker.c
>
> Modified: tomcat/jk/trunk/native/common/jk_lb_worker.c
> URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_lb_worker.c?rev=1174468&r1=1174467&r2=1174468&view=diff
> ==============================================================================
> --- tomcat/jk/trunk/native/common/jk_lb_worker.c (original)
> +++ tomcat/jk/trunk/native/common/jk_lb_worker.c Fri Sep 23 00:46:55 2011
> @@ -624,7 +624,7 @@ static jk_uint64_t decay_load(lb_worker_
>  {
>     unsigned int i;
>     jk_uint64_t curmax = 0;
> -    jk_uint64_t curmin;
> +    jk_uint64_t curmin = 0;
>     lb_sub_worker_t *w;
>     ajp_worker_t *aw;
>
> @@ -636,9 +636,6 @@ static jk_uint64_t decay_load(lb_worker_
>             if (p->lbmethod != JK_LB_METHOD_NEXT) {
>                 w->s->lb_value >>= exponent;
>             }
> -            if (w->s->lb_value < curmin) {
> -                curmin = w->s->lb_value;
> -            }

The initial value of curmin is assigned above the loop:
curmin = (&p->lb_workers[0])->s->lb_value;

I think you can remove that assignment. It happens without checking
with "JK_WORKER_USABLE()" and thus contradicts with the new code
below.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org