cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2004-03-17 Thread hgomez
hgomez  2004/03/17 09:13:32

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Remove unused vars
  
  Revision  ChangesPath
  1.39  +0 -4  jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- jk_worker_lb.c8 Mar 2004 23:01:06 -   1.38
  +++ jk_worker_lb.c17 Mar 2004 17:13:32 -  1.39
  @@ -440,7 +440,6 @@
   */
   static int JK_METHOD jk2_lb_refresh(jk_env_t *env, jk_worker_t *lb)
   {
  -int currentWorker=0;
   int i;
   int num_of_workers=lb->lbWorkerMap->size( env, lb->lbWorkerMap);
   
  @@ -503,7 +502,6 @@
   char *name)
   {
   jk_worker_t *lb=mbean->object;
  -unsigned i = 0;
   jk_worker_lb_private_t *lb_priv = lb->worker_private;
   
   if( strcmp( name, "workers") == 0 ) {
  @@ -533,7 +531,6 @@
   {
   jk_worker_t *lb=mbean->object;
   char *value=valueP;
  -unsigned i = 0;
   jk_worker_lb_private_t *lb_priv = lb->worker_private;
   
   if( strcmp( name, "worker") == 0 ) {
  @@ -593,7 +590,6 @@
   
   static int JK_METHOD jk2_lb_destroy(jk_env_t *env, jk_bean_t *bean)
   {
  -jk_worker_t *w=bean->object;
   /* Workers are destroyed by the workerEnv. It is possible
  that a worker is part of more than a lb.
  Nothing to clean up so far.
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2004-03-08 Thread Kurt Miller
Could one of the more senior jtc committers review this for me please?

The problem was that jk_lb_refresh was being called for each channel
parsed and adding all the workers to the workersTable each time. The
result was that the first channel was added to the table n+1 times
(where n = total number of workers), the second channel was added n
times and the third channel n-1, etc. Consequently the table was
getting overrun.

I believe this problem may also account for the first channel(s)
getting more load because of the extra copies in the table.

-Kurt

- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 08, 2004 6:01 PM
Subject: cvs commit: jakarta-tomcat-connectors/jk/native2/common
jk_worker_lb.c


> truk2004/03/08 15:01:07
>
>   Modified:jk/native2/common jk_worker_lb.c
>   Log:
>   Fix bug 23483
>
>   Only add worker to the workerTable if it is not already there.
>   Add check for maximum workers too.
>
>   Revision  ChangesPath
>   1.38  +21 -5
jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
>
>   Index: jk_worker_lb.c
>
===
>   RCS file:
/home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
>   retrieving revision 1.37
>   retrieving revision 1.38
>   diff -u -r1.37 -r1.38
>   --- jk_worker_lb.c 27 Feb 2004 08:34:18 - 1.37
>   +++ jk_worker_lb.c 8 Mar 2004 23:01:06 - 1.38
>   @@ -448,7 +448,8 @@
>char *name = lb->lbWorkerMap->nameAt( env,
lb->lbWorkerMap, i);
>jk_worker_t *w= env->getByName( env, name );
>int level=0;
>   -int pos=0;
>   +int pos;
>   +int workerCnt;
>
>if( w== NULL ) {
>env->l->jkLog(env, env->l, JK_LOG_ERROR,
>   @@ -463,12 +464,27 @@
>/* It's like disabled */
>if( level >= JK_LB_LEVELS ) continue;
>
>   -pos=lb->workerCnt[level]++;
>   +/* check if worker is already in the table */
>   +workerCnt = lb->workerCnt[level];
>   +for(pos = 0 ; pos < workerCnt ; pos++) {
>   +if( lb->workerTables[level][pos] == w ) {
>   +break;
>   +}
>   +}
>   +
>   +if( pos == workerCnt ) {
>   +if( pos == JK_LB_MAX_WORKERS ) {
>   +env->l->jkLog(env, env->l, JK_LOG_ERROR,
>   +  "lb_worker.init(): maximum lb
workers reached %s\n", name);
>   +continue;
>   +}
>   +pos=lb->workerCnt[level]++;
>
>   -lb->workerTables[level][pos]=w;
>   +lb->workerTables[level][pos]=w;
>
>   -w->lb_value = w->lb_factor;
>   -w->in_error_state = JK_FALSE;
>   +w->lb_value = w->lb_factor;
>   +w->in_error_state = JK_FALSE;
>   +}
>}
>
>return JK_OK;
>
>
>
>
> 
-
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2004-03-08 Thread ax
This account does not exist



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2004-03-08 Thread truk
truk2004/03/08 15:01:07

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Fix bug 23483
  
  Only add worker to the workerTable if it is not already there.
  Add check for maximum workers too.
  
  Revision  ChangesPath
  1.38  +21 -5 jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- jk_worker_lb.c27 Feb 2004 08:34:18 -  1.37
  +++ jk_worker_lb.c8 Mar 2004 23:01:06 -   1.38
  @@ -448,7 +448,8 @@
   char *name = lb->lbWorkerMap->nameAt( env, lb->lbWorkerMap, i);
   jk_worker_t *w= env->getByName( env, name );
   int level=0;
  -int pos=0;
  +int pos;
  +int workerCnt;
   
   if( w== NULL ) {
   env->l->jkLog(env, env->l, JK_LOG_ERROR,
  @@ -463,12 +464,27 @@
   /* It's like disabled */
   if( level >= JK_LB_LEVELS ) continue;
   
  -pos=lb->workerCnt[level]++;
  +/* check if worker is already in the table */
  +workerCnt = lb->workerCnt[level];
  +for(pos = 0 ; pos < workerCnt ; pos++) {
  +if( lb->workerTables[level][pos] == w ) {
  +break;
  +}
  +}
  +
  +if( pos == workerCnt ) {
  +if( pos == JK_LB_MAX_WORKERS ) {
  +env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +  "lb_worker.init(): maximum lb workers reached %s\n", 
name);
  +continue;
  +}
  +pos=lb->workerCnt[level]++;
   
  -lb->workerTables[level][pos]=w;
  +lb->workerTables[level][pos]=w;
   
  -w->lb_value = w->lb_factor;
  -w->in_error_state = JK_FALSE;
  +w->lb_value = w->lb_factor;
  +w->in_error_state = JK_FALSE;
  +}
   }
   
   return JK_OK;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2003-03-03 Thread costin
costin  2003/03/03 23:21:00

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Use the new field.
  
  Revision  ChangesPath
  1.32  +2 -0  jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- jk_worker_lb.c1 Mar 2003 05:49:58 -   1.31
  +++ jk_worker_lb.c4 Mar 2003 07:21:00 -   1.32
  @@ -146,6 +146,7 @@
   jk_worker_t *w=lb->workerTables[level][i];
   
   if( w->mbean->disabled ) continue;
  +if( w->graceful ) continue;
   if( w->in_error_state ) continue;
   if( w->lb_disabled ) continue;
   
  @@ -227,6 +228,7 @@
   jk_worker_t *w=lb->workerTables[level][i];
   
   if( w->mbean->disabled == JK_TRUE ) continue;
  +if( w->graceful ) continue;
   if( w->lb_disabled ) continue;
   
   error_workers++;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c jk_channel_jni.c jk_channel.c

2002-11-21 Thread mturk
mturk   2002/11/21 01:03:18

  Modified:jk/native2/common jk_worker_lb.c jk_channel_jni.c
jk_channel.c
  Log:
  Get rid of the one-shot worker initialization scheme.
  It doesn't work as it should, and it slows down the load balacer.
  Once when service channel will be introduced it will take care of that.
  
  Revision  ChangesPath
  1.28  +9 -62 jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- jk_worker_lb.c21 Nov 2002 07:46:41 -  1.27
  +++ jk_worker_lb.c21 Nov 2002 09:03:17 -  1.28
  @@ -85,7 +85,6 @@
   
   typedef struct {
   struct  jk_mutex *cs;
  -int initializing;
   int attempts;
   int recovery;
   int timeout;
  @@ -334,35 +333,12 @@
   /* Since there is potential worker state change
* make the find best worker call thread safe 
*/
  -if (!lb_priv->initializing) {
  -if (lb_priv->cs != NULL)
  -lb_priv->cs->lock(env, lb_priv->cs);
  -rec=jk2_get_most_suitable_worker(env, lb, s, attempt);
  -
  -if (lb_priv->cs != NULL)
  -lb_priv->cs->unLock(env, lb_priv->cs);
  -if (!rec && lb_priv->timeout) {
  -time_t now = time(NULL);
  -if ((int)(now - lb_priv->error_time) < lb_priv->timeout) {
  -#ifdef HAS_APR
  -apr_thread_yield();
  -#endif
  -continue;
  -}
  -}
  -else
  -lb_priv->error_time = time(NULL);
  -}
  -else if (!rec){
  -/* If we are initializing the service wait until
  - * the initialization finishes or times out 
  - */
  -if (lb->cs != NULL) {
  -lb->cs->lock(env, lb->cs);
  -lb->cs->unLock(env, lb->cs);
  -}
  -continue;
  -}
  +if (lb_priv->cs != NULL)
  +lb_priv->cs->lock(env, lb_priv->cs);
  +rec=jk2_get_most_suitable_worker(env, lb, s, attempt);
  +
  +if (lb_priv->cs != NULL)
  +lb_priv->cs->unLock(env, lb_priv->cs);
   attempt++;
   
   s->is_recoverable_error = JK_FALSE;
  @@ -405,50 +381,21 @@
   s->jvm_route = rec->route;
   
   s->realWorker = rec;
  -if (rec->mbean->initialize && !lb_priv->initializing && lb->cs != NULL) {
  -/* If the worker has not been called yet serialize the call */
  -lb->cs->lock(env, lb->cs);
  -lb_priv->initializing = JK_TRUE;
  -rec->error_time = time(NULL);
  -}
  +
   rc = rec->service(env, rec, s);
   
   if(rc==JK_OK) {
   rec->in_error_state = JK_FALSE;
   rec->error_time = 0;
  -/* Set the initialized flag to TRUE if that was the first call */
  -if (rec->mbean->initialize && lb->cs != NULL) {
  -rec->mbean->initialize = 0;
  -lb_priv->initializing = JK_FALSE;
  -lb->cs->unLock(env, lb->cs);
  -}
   return JK_OK;
   }
   
  -if (rec->mbean->initialize && lb->cs != NULL) {
  -time_t now = time(NULL);
  -/* In the case of initialization timeout disable the worker */
  -if ((int)(now - rec->error_time) > rec->mbean->initialize) {
  -rec->mbean->disabled = JK_TRUE;
  -lb_priv->initializing = JK_FALSE;
  -s->is_recoverable_error = JK_FALSE;
  -env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  -  "lb_worker.service() worker init timeout for %s\n",
  -  rec->channelName);
  -lb->cs->unLock(env, lb->cs);
  -}
  -else {
  -#ifdef HAS_APR
  -apr_thread_yield();
  -#endif
  -continue;
  -}
  -}
   /* If this is a browser connection error dont't check other
* workers. 
*/
   if (rc == JK_HANDLER_ERROR) {
  -
  +rec->in_error_state = JK_FALSE;
  +rec->error_time = 0;
   return JK_HANDLER_ERROR;
   }
   
  
  
  
  1.38  +1 -3  jakarta-tomcat-connectors/jk/native2/common/jk_channel_jni.c
  
  Index: jk_channel_jni.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_jni.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-13 Thread mturk

mturk   2002/10/13 23:30:42

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Check if the worker has lb_disabled flag set, and behave like it was
  disabled.
  
  Revision  ChangesPath
  1.26  +3 -0  jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- jk_worker_lb.c3 Oct 2002 01:33:15 -   1.25
  +++ jk_worker_lb.c14 Oct 2002 06:30:42 -  1.26
  @@ -143,6 +143,7 @@
   
   if( w->mbean->disabled ) continue;
   if( w->in_error_state ) continue;
  +if( w->lb_disabled ) continue;
   
   if( rc==NULL ) {
   rc=w;
  @@ -182,6 +183,7 @@
   jk_worker_t *w=lb->workerTables[level][i];
   
   if( w->mbean->disabled ) continue;
  +if( w->lb_disabled ) continue;
   
   if(w->in_error_state) {
   /* Check if it's ready for recovery */
  @@ -221,6 +223,7 @@
   jk_worker_t *w=lb->workerTables[level][i];
   
   if( w->mbean->disabled == JK_TRUE ) continue;
  +if( w->lb_disabled ) continue;
   
   error_workers++;
   
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-04 Thread Henri Gomez

> No, but extending one dtd would be better than reinventing everything.
> I will try to make a cleanup as soon as I have time. (docs need a lot of 
> time).

I confirm ;-)

BTW, any DTD will be fine but we should take a look at what others
jakarta and xml projects are using.





--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-03 Thread Costin Manolache

jean-frederic clere wrote:
 
>> :-) Sorry about 'horrible'.
>> 
>> What I meant is - the elements like  and almost everything
>> else have an identical meaning as the standard XHTML or docbook element.
>> It's a mix of elements - to do something that is already done and
>> standard and accepted.
>>  
>> What I find horrible is the fragmentation and missuse of XML
>> ( not only here, but all over ).
>> What's wrong with a subset of XHTML or Docbook ?
> 
> The first idea was to save us from writing XML tags and concentrate in the
> text. We have ended defining a dtd that fits our needs with typing the
> minimum...

I'm not sure I understand. How is this 'saving us' from writing XML tags?

We still have to write XML tags, and what's worse - to learn a set of 
tags that we'll never use outside jk. As oposed to write the same
thing using the tags we already know - subset of XHTML - or learn
a set of tags that we'll likely use - a subset of docbook.

And both XHTML and Docbook have editors and tools that would actually
'save us from writing XML' and concentrate on text. And plenty of 
stylesheets to generate pdf or whatever else.

> 
>> Do we
>> plan to beat W3C and Oasis in setting a standard for document
>> dtd ?
> 
> No, but extending one dtd would be better than reinventing everything.
> I will try to make a cleanup as soon as I have time. (docs need a lot of
> time).

??? 

We do reinvent everything aparently - yet another non-standard document DTD. 
W3C and Oasis define some reasonable and widely used DTDs for that. If 
someone feels docbook is too complex - we can restrict ourselfs to a subset 
( like linuxdoc did for a while ) , but we'll still benefit from some of 
the existing tools and what we already know. 

As I said, that's just me ranting - if the majority is happy with our
private DTD for docs - I'll have to use it ( but that doesn't mean I have
to like it ).

-- 
Costin



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-03 Thread jean-frederic clere

Costin Manolache wrote:
> jean-frederic clere wrote:
> 
> 
>>Costin Manolache wrote:
>>
>>>Mladen Turk wrote:
>>>
>>>
>>>
>-Original Message-
>On Behalf Of Costin Manolache
>
>Are we documenting all those settings - and the details on
>why/how :-) ?
>
>

Sure, like everyone else ;).
>>>
>>>
>>>Yes, I know :-)
>>>
>>>I'll try to get over the horrible and nonstandard DTD that we
>>>use
>>
>>I agree for not standard DTD but horrible...
>>Well it needs a lot of improvements but that means the xml files need to
>>be reviewed carefully I would suggest to output messages when using
>>"weird" elements to have time to rewrite the files.
> 
> 
> :-) Sorry about 'horrible'.
> 
> What I meant is - the elements like  and almost everything
> else have an identical meaning as the standard XHTML or docbook element. 
> It's a mix of elements - to do something that is already done and
> standard and accepted. 
>  
> What I find horrible is the fragmentation and missuse of XML
> ( not only here, but all over ). 
> What's wrong with a subset of XHTML or Docbook ?

The first idea was to save us from writing XML tags and concentrate in the text.
We have ended defining a dtd that fits our needs with typing the minimum...

> Do we
> plan to beat W3C and Oasis in setting a standard for document 
> dtd ?

No, but extending one dtd would be better than reinventing everything.
I will try to make a cleanup as soon as I have time. (docs need a lot of time).

> 
> ( well, that's just me ranting - this has little to do 
> with our xdocs, as I said I'll try to get over it and 
> add to them )
> 




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-03 Thread Costin Manolache

jean-frederic clere wrote:

> Costin Manolache wrote:
>> Mladen Turk wrote:
>> 
>> 
>>>
-Original Message-
On Behalf Of Costin Manolache

Are we documenting all those settings - and the details on
why/how :-) ?


>>>
>>>Sure, like everyone else ;).
>> 
>> 
>> Yes, I know :-)
>> 
>> I'll try to get over the horrible and nonstandard DTD that we
>> use
> 
> I agree for not standard DTD but horrible...
> Well it needs a lot of improvements but that means the xml files need to
> be reviewed carefully I would suggest to output messages when using
> "weird" elements to have time to rewrite the files.

:-) Sorry about 'horrible'.

What I meant is - the elements like  and almost everything
else have an identical meaning as the standard XHTML or docbook element. 
It's a mix of elements - to do something that is already done and
standard and accepted. 
 
What I find horrible is the fragmentation and missuse of XML
( not only here, but all over ). 
What's wrong with a subset of XHTML or Docbook ? Do we
plan to beat W3C and Oasis in setting a standard for document 
dtd ?

( well, that's just me ranting - this has little to do 
with our xdocs, as I said I'll try to get over it and 
add to them )

-- 
Costin



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-03 Thread jean-frederic clere

Costin Manolache wrote:
> Mladen Turk wrote:
> 
> 
>>
>>>-Original Message-
>>>On Behalf Of Costin Manolache
>>>
>>>Are we documenting all those settings - and the details on
>>>why/how :-) ?
>>>
>>>
>>
>>Sure, like everyone else ;).
> 
> 
> Yes, I know :-)
> 
> I'll try to get over the horrible and nonstandard DTD that we 
> use

I agree for not standard DTD but horrible...
Well it needs a lot of improvements but that means the xml files need to be 
reviewed carefully I would suggest to output messages when using "weird" 
elements to have time to rewrite the files.

> and start documenting what I can still remember, and anything new
> that I add. And I won't write any new jk code until I finish at least
> reviewing all the bugs ( 80 ? )
>  




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-02 Thread Mladen Turk



> -Original Message-
> > 
> > Sure, like everyone else ;).
> 
> Yes, I know :-)
> 
> I'll try to get over the horrible and nonstandard DTD that we 
> use and start documenting what I can still remember, and 
> anything new that I add. And I won't write any new jk code 
> until I finish at least reviewing all the bugs ( 80 ? )
>  

Roger to that.

MT.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-02 Thread Costin Manolache

Mladen Turk wrote:

> 
> 
>> -Original Message-
>> On Behalf Of Costin Manolache
>> 
>> Are we documenting all those settings - and the details on
>> why/how :-) ?
>> 
>> 
> 
> Sure, like everyone else ;).

Yes, I know :-)

I'll try to get over the horrible and nonstandard DTD that we 
use and start documenting what I can still remember, and anything new
that I add. And I won't write any new jk code until I finish at least
reviewing all the bugs ( 80 ? )
 
-- 
Costin



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-02 Thread Mladen Turk



> -Original Message-
> On Behalf Of Costin Manolache
> 
> Are we documenting all those settings - and the details on 
> why/how :-) ?
> 
> 

Sure, like everyone else ;).

MT.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-02 Thread Costin Manolache

Are we documenting all those settings - and the details on why/how :-) ?


Mladen Turk wrote:

> 
> It is disabled by default and never checked (if you don't set the
> timeout=x inside the [lb]).
> 
>  
>> I there any way to disable completely that timeout?
>> 
>> Perhaps setting it to -1 or something like that?
>> 
>> This timeout disabled should be the default config..
>>

-- 
Costin



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-02 Thread Mladen Turk


It is disabled by default and never checked (if you don't set the
timeout=x inside the [lb]).

 
> I there any way to disable completely that timeout?
> 
> Perhaps setting it to -1 or something like that?
> 
> This timeout disabled should be the default config.. 
> 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-02 Thread Ignacio J. Ortega

> De: Mladen Turk [mailto:[EMAIL PROTECTED]]
> Enviado el: 2 de octubre de 2002 17:50

I there any way to disable completely that timeout?

Perhaps setting it to -1 or something like that?

This timeout disabled should be the default config.. 

Saludos ,
Ignacio J. Ortega

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-02 Thread Mladen Turk



> -Original Message-
> From: [EMAIL PROTECTED]
 
>   Modified:jk/native2/common jk_worker_lb.c
>   Log:
>   Introduced 3 new configuration parameters to the lb.
>   1. attempts -- replaces harcoded MAX_ATTEMPTS
>   2. recovery -- replaces hardcoded WAIT_BEFORE_RECOVER
>   3. timeout -- this one is new.
>   The timeout if set will force the lb to cycle through 
> workers if all are in the
>   error_state for the specified amount of seconds. This is usefull for
>   situations when the TC is overloaded and refuses new connections.
>   The lb will wait and after timeout will report 500 to the client.
>   

Some more clarification:

The reason for introducing timeout inside lb is from my point of view
and the applications I'm using jk2 for, fact that even using most
powerful system, there will be situations that returns 500 to the client
simply because the TC is to busy and refuses new connections. One way to
solve that is to force the TC to allow more connections eating system
resources, and the other is using lb timeout.

One drawback of using timeout is the fact that the client will get
delayed response even for the non-existent configured TC instance.
I've made such behavior at first inside the socket connector, but Nacho
(he was right) made a strong objection to that. So instead trying to
connect to the instance from connector point of view, all that is put
inside the load balancer.


MT. 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-10-02 Thread mturk

mturk   2002/10/02 08:36:22

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Introduced 3 new configuration parameters to the lb.
  1. attempts -- replaces harcoded MAX_ATTEMPTS
  2. recovery -- replaces hardcoded WAIT_BEFORE_RECOVER
  3. timeout -- this one is new.
  The timeout if set will force the lb to cycle through workers if all are in the
  error_state for the specified amount of seconds. This is usefull for
  situations when the TC is overloaded and refuses new connections.
  The lb will wait and after timeout will report 500 to the client.
  
  Revision  ChangesPath
  1.24  +36 -9 jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- jk_worker_lb.c8 Jul 2002 13:33:38 -   1.23
  +++ jk_worker_lb.c2 Oct 2002 15:36:22 -   1.24
  @@ -77,15 +77,20 @@
   #define DEFAULT_LB_FACTOR   (1.0)
   
   /* Time to wait before retry... XXX make it configurable*/
  -#define WAIT_BEFORE_RECOVER (60) 
  +#define WAIT_BEFORE_RECOVER 60 
   
   #define MAX_ATTEMPTS 3
   
   #define NO_WORKER_MSG "The servlet container is temporary unavailable or being 
upgraded\n";
   
   typedef struct {
  -struct jk_mutex *cs;
  -intinitializing;
  +struct  jk_mutex *cs;
  +int initializing;
  +int attempts;
  +int recovery;
  +int timeout;
  +time_t  error_time;
  +
   } jk_worker_lb_private_t;
   
   /** Find the best worker. In process, check if timeout expired
  @@ -108,6 +113,7 @@
   int currentLevel=JK_LB_LEVELS - 1;
   char *session_route;
   time_t now = 0;
  +jk_worker_lb_private_t *lb_priv = lb->worker_private;
   
   session_route = jk2_requtil_getSessionRoute(env, s);
  
  @@ -119,7 +125,7 @@
   if(w->route != NULL &&
  0 == strcmp(session_route, w->route)) {
   if(attempt > 0 && w->in_error_state) {
  -/* We already tried to revive this worker. */
  +/* We already tried to revive this worker. */
   break;
   } else {
   return w;
  @@ -181,7 +187,7 @@
   /* Check if it's ready for recovery */
   if( now==0 ) now = time(NULL);
   
  -if((now - w->error_time) > WAIT_BEFORE_RECOVER) {
  +if((now - w->error_time) > lb_priv->recovery) {
   env->l->jkLog(env, env->l, JK_LOG_ERROR,
 "lb.getWorker() reenable %s\n", w->mbean->name);
   w->in_error_state = JK_FALSE;
  @@ -331,7 +337,18 @@
   rec=jk2_get_most_suitable_worker(env, lb, s, attempt);
   
   if (lb_priv->cs != NULL)
  -lb_priv->cs->unLock(env, lb_priv->cs);
  +lb_priv->cs->unLock(env, lb_priv->cs);
  +if (!rec && lb_priv->timeout) {
  +time_t now = time(NULL);
  +if ((int)(now - lb_priv->error_time) < lb_priv->timeout) {
  +#ifdef HAS_APR
  +apr_thread_yield();
  +#endif
  +continue;
  +}
  +}
  +else
  +lb_priv->error_time = time(NULL);
   }
   else if (!rec){
   /* If we are initializing the service wait until
  @@ -340,7 +357,7 @@
   if (lb->cs != NULL) {
   lb->cs->lock(env, lb->cs);
   lb->cs->unLock(env, lb->cs);
  -}
  +}
   continue;
   }
   attempt++;
  @@ -370,6 +387,7 @@
   }
   
   s->afterRequest( env, s);
  +lb_priv->error_time = time(NULL);
   return JK_ERR;
   }
   
  @@ -502,6 +520,7 @@
   jk_worker_t *lb=mbean->object;
   char *value=valueP;
   unsigned i = 0;
  +jk_worker_lb_private_t *lb_priv = lb->worker_private;
   
   if( strcmp( name, "worker") == 0 ) {
   if( lb->lbWorkerMap->get( env, lb->lbWorkerMap, name) != NULL ) {
  @@ -523,7 +542,13 @@
   lb->noWorkerCode=atoi( value );
   } else if( strcmp( name, "hwBalanceErr") == 0 ) {
   lb->hwBalanceErr=atoi( value );
  -}
  +} else if( strcmp( name, "timeout") == 0 ) {
  +lb_priv->timeout=atoi( value );
  +} else if( strcmp( name, "recovery") == 0 ) {
  +lb_priv->recovery=atoi( value );
  +} else if( strcmp( name, "attempts") == 0 ) {
  +lb_priv->attempts=atoi( value );
  +}
   return JK_ERR;
   }
   
  @@ -594,7 +619,9 @@
   if( jkb != NULL ) {
   worker_pri

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-07-08 Thread mturk

mturk   2002/07/08 06:33:38

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  no message
  
  Revision  ChangesPath
  1.23  +4 -4  jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- jk_worker_lb.c29 Jun 2002 18:28:10 -  1.22
  +++ jk_worker_lb.c8 Jul 2002 13:33:38 -   1.23
  @@ -374,7 +374,7 @@
   }
   
   if( lb->mbean->debug > 0 ) 
  -env->l->jkLog(env, env->l, JK_LOG_INFO,
  +env->l->jkLog(env, env->l, JK_LOG_DEBUG,
 "lb.service() try %s\n", rec->mbean->name );
   
   if( rec->route==NULL ) {
  @@ -446,7 +446,7 @@
* another worker... Lets try to do that.
*/
   if( lb->mbean->debug > 0 ) {
  -env->l->jkLog(env, env->l, JK_LOG_INFO, 
  +env->l->jkLog(env, env->l, JK_LOG_DEBUG, 
 "lb_worker.service() try other hosts\n");
   }
   }
  @@ -512,7 +512,7 @@
   lb->lbWorkerMap->add(env, lb->lbWorkerMap, value, "");
   
   if( lb->mbean->debug > 0 )
  -env->l->jkLog(env, env->l, JK_LOG_INFO,
  +env->l->jkLog(env, env->l, JK_LOG_DEBUG,
 "lb_worker.setAttribute(): Adding to %s: %s\n", 
lb->mbean->localName, value);
   
   jk2_lb_refresh( env, lb );
  @@ -542,7 +542,7 @@
   /* if( lb->workerEnv->shm != NULL && lb->workerEnv->shm->head != NULL)  */
   /* jk2_lb_updateWorkers(env, lb, lb->workerEnv->shm); */
   if( lb->mbean->debug > 0 )
  -env->l->jkLog(env, env->l, JK_LOG_INFO, "lb.init() %s %d workers\n",
  +env->l->jkLog(env, env->l, JK_LOG_DEBUG, "lb.init() %s %d workers\n",
 lb->mbean->name, num_of_workers );
   
   return JK_OK;
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-06-29 Thread mturk

mturk   2002/06/29 11:28:10

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Move the worker initalization to channel, so we can skip the channels
  that not need that option.
  
  Revision  ChangesPath
  1.22  +6 -13 jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- jk_worker_lb.c29 Jun 2002 07:48:20 -  1.21
  +++ jk_worker_lb.c29 Jun 2002 18:28:10 -  1.22
  @@ -85,7 +85,6 @@
   
   typedef struct {
   struct jk_mutex *cs;
  -intinit_timeout;
   intinitializing;
   } jk_worker_lb_private_t;
   
  @@ -385,7 +384,7 @@
   s->jvm_route = rec->route;
   
   s->realWorker = rec;
  -if (!rec->initialized && !lb_priv->initializing && lb->cs != NULL) {
  +if (rec->mbean->initialize && !lb_priv->initializing && lb->cs != NULL) {
   /* If the worker has not been called yet serialize the call */
   lb->cs->lock(env, lb->cs);
   lb_priv->initializing = JK_TRUE;
  @@ -397,18 +396,18 @@
   rec->in_error_state = JK_FALSE;
   rec->error_time = 0;
   /* Set the initialized flag to TRUE if that was the first call */
  -if (!rec->initialized && lb->cs != NULL) {
  -rec->initialized = JK_TRUE;
  +if (rec->mbean->initialize && lb->cs != NULL) {
  +rec->mbean->initialize = 0;
   lb_priv->initializing = JK_FALSE;
   lb->cs->unLock(env, lb->cs);
   }
   return JK_OK;
   }
   
  -if (!rec->initialized && lb->cs != NULL) {
  +if (rec->mbean->initialize && lb->cs != NULL) {
   time_t now = time(NULL);
   /* In the case of initialization timeout disable the worker */
  -if ((int)(now - rec->error_time) > lb_priv->init_timeout) {
  +if ((int)(now - rec->error_time) > rec->mbean->initialize) {
   rec->mbean->disabled = JK_TRUE;
   lb_priv->initializing = JK_FALSE;
   s->is_recoverable_error = JK_FALSE;
  @@ -524,11 +523,7 @@
   lb->noWorkerCode=atoi( value );
   } else if( strcmp( name, "hwBalanceErr") == 0 ) {
   lb->hwBalanceErr=atoi( value );
  -} else if( strcmp( name, "initTimeout") == 0 ) {
  -jk_worker_lb_private_t *priv = lb->worker_private;
  -priv->init_timeout=atoi( value );
   }
  -
   return JK_ERR;
   }
   
  @@ -595,8 +590,6 @@
   worker_private = (jk_worker_lb_private_t *)pool->calloc(env,
 pool, sizeof(jk_worker_lb_private_t));
   
  -/* one minute service startup */
  -worker_private->init_timeout = 60;
   jkb=env->createBean2(env, pool,"threadMutex", NULL);
   if( jkb != NULL ) {
   worker_private->cs=jkb->object;
  @@ -625,7 +618,7 @@
   
   w->workerEnv=env->getByName( env, "workerEnv" );
   w->workerEnv->addWorker( env, w->workerEnv, w );
  -
  +
   return JK_OK;
   }
   
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-06-29 Thread mturk

mturk   2002/06/29 00:48:20

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Serialize the calls to the workers until the first call finishes or times out.
  Added new config param 'timeout' setting the initialization worker
  timeout.
  
  Revision  ChangesPath
  1.21  +88 -7 jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- jk_worker_lb.c22 Jun 2002 16:57:54 -  1.20
  +++ jk_worker_lb.c29 Jun 2002 07:48:20 -  1.21
  @@ -70,6 +70,10 @@
   #include "jk_env.h"
   #include "jk_requtil.h"
   
  +#ifdef HAS_APR
  +#include "apr_thread_proc.h"
  +#endif
  +
   #define DEFAULT_LB_FACTOR   (1.0)
   
   /* Time to wait before retry... XXX make it configurable*/
  @@ -79,6 +83,12 @@
   
   #define NO_WORKER_MSG "The servlet container is temporary unavailable or being 
upgraded\n";
   
  +typedef struct {
  +struct jk_mutex *cs;
  +intinit_timeout;
  +intinitializing;
  +} jk_worker_lb_private_t;
  +
   /** Find the best worker. In process, check if timeout expired
   for workers that failed in the past and give them another chance.
   
  @@ -281,6 +291,8 @@
   {
   int attempt=0;
   jk_workerEnv_t *wEnv=lb->workerEnv;
  +jk_worker_lb_private_t *lb_priv = lb->worker_private;
  +jk_worker_t *rec = NULL;
   
   if( s==NULL ) {
   env->l->jkLog(env, env->l, JK_LOG_ERROR,
  @@ -309,10 +321,29 @@
   }
   
   while(1) {
  -jk_worker_t *rec;
   int rc;
   
  -rec=jk2_get_most_suitable_worker(env, lb, s, attempt);
  +/* Since there is potential worker state change
  + * make the find best worker call thread safe 
  + */
  +if (!lb_priv->initializing) {
  +if (lb_priv->cs != NULL)
  +lb_priv->cs->lock(env, lb_priv->cs);
  +rec=jk2_get_most_suitable_worker(env, lb, s, attempt);
  +
  +if (lb_priv->cs != NULL)
  +lb_priv->cs->unLock(env, lb_priv->cs);
  +}
  +else if (!rec){
  +/* If we are initializing the service wait until
  + * the initialization finishes or times out 
  + */
  +if (lb->cs != NULL) {
  +lb->cs->lock(env, lb->cs);
  +lb->cs->unLock(env, lb->cs);
  +}
  +continue;
  +}
   attempt++;
   
   s->is_recoverable_error = JK_FALSE;
  @@ -354,16 +385,45 @@
   s->jvm_route = rec->route;
   
   s->realWorker = rec;
  -
  +if (!rec->initialized && !lb_priv->initializing && lb->cs != NULL) {
  +/* If the worker has not been called yet serialize the call */
  +lb->cs->lock(env, lb->cs);
  +lb_priv->initializing = JK_TRUE;
  +rec->error_time = time(NULL);
  +}
   rc = rec->service(env, rec, s);
   
   if(rc==JK_OK) {
   rec->in_error_state = JK_FALSE;
   rec->error_time = 0;
  -/* the endpoint that succeeded is saved for done() */
  +/* Set the initialized flag to TRUE if that was the first call */
  +if (!rec->initialized && lb->cs != NULL) {
  +rec->initialized = JK_TRUE;
  +lb_priv->initializing = JK_FALSE;
  +lb->cs->unLock(env, lb->cs);
  +}
   return JK_OK;
   }
   
  +if (!rec->initialized && lb->cs != NULL) {
  +time_t now = time(NULL);
  +/* In the case of initialization timeout disable the worker */
  +if ((int)(now - rec->error_time) > lb_priv->init_timeout) {
  +rec->mbean->disabled = JK_TRUE;
  +lb_priv->initializing = JK_FALSE;
  +s->is_recoverable_error = JK_FALSE;
  +env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  +  "lb_worker.service() worker init timeout for %s\n",
  +  rec->channelName);
  +lb->cs->unLock(env, lb->cs);
  +}
  +else {
  +#ifdef HAS_APR
  +apr_thread_yield();
  +#endif
  +continue;
  +}
  +}
   env->l->jkLog(env, env->l, JK_LOG_ERROR, 
 "lb.service() worker failed %s\n", rec->mbean->name );
   
  @@ -373,7 +433,7 @@
* Time for fault tolerance (if possible)...
*/
   rec->in_error_state = JK_TRUE;
  -rec->error_time = time(0);
  +rec->error_time = time(NULL);
   
   if(!s->is_recoverable_error) {

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-06-22 Thread jfclere

jfclere 2002/06/22 09:57:54

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Typo
  Submitted by: Ian Darwin ian at darwinsys.com
  
  Revision  ChangesPath
  1.20  +1 -1  jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- jk_worker_lb.c10 Jun 2002 21:55:06 -  1.19
  +++ jk_worker_lb.c22 Jun 2002 16:57:54 -  1.20
  @@ -77,7 +77,7 @@
   
   #define MAX_ATTEMPTS 3
   
  -#define NO_WORKER_MSG "The servlet container is temporary unavailable or beeing 
upgraded\n";
  +#define NO_WORKER_MSG "The servlet container is temporary unavailable or being 
upgraded\n";
   
   /** Find the best worker. In process, check if timeout expired
   for workers that failed in the past and give them another chance.
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-15 Thread Bernd Koecke

[EMAIL PROTECTED] wrote:
> On Tue, 14 May 2002, Bernd Koecke wrote:
> 
> 
>>Hi Costin,
>>
>>the new patch seems to work, but I'll test it more exactly tomorrow. Then I'll 
>>create the patches and the functional description.
>>
>>In short, the patched lb_worker uses an additinal flag on the other workers (e.g 
>>worker.ajp13.local_worker=1) to determine if it should be moved to the beginning 
>>of the balanced_workers. So we don't need to deal with two lists in lb_worker 
>>and the lb_value '0' has no special meaning. The flag for sending requests only 
>>to local workers is 'local_worker_only' on the lb_worker. More when the patch is 
>>tested and ready.
> 
> 
> Ok. I already commited part of the changes for jk2 - but my version is 
> called 'hwBalanceErr', on worker_lb.
> 
> If 0 normal selection of non-local workers takes place if all locals are 
> in error state. If non 0, we'll return the value as the error code - for 
> a front-end balancer to detect and stop forwarding requests for this 
> instance. 
> 
> I think that's the behavior you need - and it also allows customization
> for the returned error code.
> 

That sounds great, many thanks!

The patch for jk1 is on the way and I added some explanation how it works and 
about the two config flags.

Bernd


> Costin
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 



-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-14 Thread costin

costin  02/05/14 13:41:35

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Support for customizable error message ( or redirect ) in case all
  workers are down
  
  Revision  ChangesPath
  1.15  +28 -3 jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- jk_worker_lb.c14 May 2002 17:23:31 -  1.14
  +++ jk_worker_lb.c14 May 2002 20:41:35 -  1.15
  @@ -78,6 +78,8 @@
   
   #define MAX_ATTEMPTS 3
   
  +#define NO_WORKER_MSG "The servlet container is temporary unavailable or beeing 
upgraded\n";
  +
   /** Find the best worker. In process, check if timeout expired
   for workers that failed in the past and give them another chance.
   
  @@ -321,8 +323,25 @@
   /* NULL record, no more workers left ... */
   env->l->jkLog(env, env->l, JK_LOG_ERROR, 
 "lb_worker.service() all workers in error or disabled 
state\n");
  -/* XXX set hwBalanceErr status */
  -/* XXX nice message or redirect */
  +/* set hwBalanceErr status */
  +if( lb->hwBalanceErr != 0 ) {
  +s->status=lb->hwBalanceErr;
  +} else {
  +s->status=lb->noWorkerCode; /* SERVICE_UNAVAILABLE is the default */
  +}
  +
  +if( s->status == 302 ) {
  +s->headers_out->put(env, s->headers_out,
  +"Location", lb->noWorkerMsg, NULL);
  +s->head(env, s );
  +} else {
  +s->headers_out->put(env, s->headers_out,
  +"Content-Type", "text/html", NULL);
  +s->head(env, s );
  +s->jkprintf(env, s, lb->noWorkerMsg );
  +}
  +
  +s->afterRequest( env, s);
   return JK_ERR;
   }
   
  @@ -419,7 +438,7 @@
   
   
   static char *jk2_worker_lb_multiValueInfo[]={"worker", NULL };
  -static char *jk2_worker_lb_setAttributeInfo[]={"hwBalanceErr", NULL };
  +static char *jk2_worker_lb_setAttributeInfo[]={"hwBalanceErr", "noWorkerMsg", 
"noWorkerCode", NULL };
   
   static int JK_METHOD jk2_lb_setAttribute(jk_env_t *env, jk_bean_t *mbean, 
char *name, void *valueP)
  @@ -445,6 +464,10 @@
   
   jk2_lb_refresh( env, lb );
   return JK_OK;
  +} else if( strcmp( name, "noWorkerMsg") == 0 ) {
  +lb->noWorkerMsg=value;
  +} else if( strcmp( name, "noWorkerCode") == 0 ) {
  +lb->noWorkerCode=atoi( value );
   } else if( strcmp( name, "hwBalanceErr") == 0 ) {
   lb->hwBalanceErr=atoi( value );
   }
  @@ -525,6 +548,8 @@
   w->mbean=result;
   
   w->hwBalanceErr=0;
  +w->noWorkerCode=503;
  +w->noWorkerMsg=NO_WORKER_MSG;
   
   w->workerEnv=env->getByName( env, "workerEnv" );
   w->workerEnv->addWorker( env, w->workerEnv, w );
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-14 Thread costinm

On Tue, 14 May 2002, Bernd Koecke wrote:

> Hi Costin,
> 
> the new patch seems to work, but I'll test it more exactly tomorrow. Then I'll 
> create the patches and the functional description.
> 
> In short, the patched lb_worker uses an additinal flag on the other workers (e.g 
> worker.ajp13.local_worker=1) to determine if it should be moved to the beginning 
> of the balanced_workers. So we don't need to deal with two lists in lb_worker 
> and the lb_value '0' has no special meaning. The flag for sending requests only 
> to local workers is 'local_worker_only' on the lb_worker. More when the patch is 
> tested and ready.

Ok. I already commited part of the changes for jk2 - but my version is 
called 'hwBalanceErr', on worker_lb.

If 0 normal selection of non-local workers takes place if all locals are 
in error state. If non 0, we'll return the value as the error code - for 
a front-end balancer to detect and stop forwarding requests for this 
instance. 

I think that's the behavior you need - and it also allows customization
for the returned error code.

Costin



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-14 Thread Bernd Koecke

[EMAIL PROTECTED] wrote:
[...]

> 
> I'll implement the same thing in jk2, but I wait your patch for jk1.
> 

Hi Costin,

the new patch seems to work, but I'll test it more exactly tomorrow. Then I'll 
create the patches and the functional description.

In short, the patched lb_worker uses an additinal flag on the other workers (e.g 
worker.ajp13.local_worker=1) to determine if it should be moved to the beginning 
of the balanced_workers. So we don't need to deal with two lists in lb_worker 
and the lb_value '0' has no special meaning. The flag for sending requests only 
to local workers is 'local_worker_only' on the lb_worker. More when the patch is 
tested and ready.

Bernd

> Costin
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 



-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-14 Thread costin

costin  02/05/14 10:23:31

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  - Started to add the 'hwBalanceErr' support.
  
  - removed the config stuff - it's now in jk_config
  
  - we still check the shm head and call the config->update method. This
  is needed since /jkstatus will be called in one process, and we need
  all processes to update. In addition this is another mechanism to triger
  config reloading.
  
  - various cosmetic changes.
  
  Revision  ChangesPath
  1.14  +43 -221   jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- jk_worker_lb.c9 May 2002 23:47:31 -   1.13
  +++ jk_worker_lb.c14 May 2002 17:23:31 -  1.14
  @@ -148,6 +148,13 @@
   */
   break;
   }
  +
  +if( lb->hwBalanceErr > 0 ) {
  +/* don't go to higher levels - we'll return an error
  + */
  +currentLevel=0;
  +break;
  +}
   }
   
   /** Reenable workers in error state if the timeout has passed.
  @@ -212,6 +219,11 @@
   rc = w;
   }
   }
  +
  +if( lb->hwBalanceErr > 0 ) {
  +/* Don't try higher levels, only level=0 */
  +break;
  +}
   }
   
   if( attempt >= error_workers ) {
  @@ -257,202 +269,6 @@
   return rc;
   }
   
  -/* Remove all channels used by this tomcat instance */
  -static int jk2_worker_lb_disableInstance( jk_env_t *env,
  -  jk_worker_t *lb,
  -  char *instanceId )
  -{
  -int i;
  -int level;
  -
  -for( level=0; levelworkerCnt[level] ; i++) {
  -jk_worker_t *w=lb->workerTables[level][i];
  -
  -if( w->route != NULL &&
  -strcmp( w->route, instanceId ) == 0 ) {
  -env->l->jkLog(env, env->l, JK_LOG_INFO,
  -  "lb.updateWorkers() Gracefull shutdown %s %s\n",
  -  w->channel->mbean->name, instanceId );
  -w->in_error_state= JK_TRUE;
  -w->mbean->disabled = JK_TRUE;
  -}
  -}
  -}
  -return JK_OK;
  -}
  -
  -static int jk2_worker_lb_registerChannel( jk_env_t *env,
  -  jk_worker_t *lb,
  -  char *instanceId,
  -  jk_msg_t *msg, jk_map_t *groups)
  -{
  -char *chName;
  -jk_map_t *chProp;
  -int i;
  -int found=JK_FALSE;
  -jk_config_t *config;
  -char *tmpBuf;
  -jk_bean_t *chBean;
  -int rc=JK_OK;
  -int level;
  -
  -jk2_map_default_create(env, &chProp, env->tmpPool);
  -
  -chName=msg->getString( env, msg );
  -if( chName==NULL ) 
  -rc=JK_ERR;
  -
  -if( rc==JK_OK )
  -rc=msg->getMap( env, msg, chProp );
  -
  -if( rc!=JK_OK ) {
  -env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -  "lb.updateWorkers() can't read channel data %s %s\n",
  -  chName, instanceId);
  -return JK_ERR;
  -}
  -
  -for( level=0; levelworkerCnt[level] ; i++) {
  -jk_worker_t *w=lb->workerTables[level][i];
  -
  -if( w->route &&
  -strcmp( w->route, instanceId ) == 0 &&
  -strcmp( w->channel->mbean->name, chName ) == 0 ) {
  -/* XXX Create a new channel with the update properties,
  -   Then replace it.
  -   
  -   At this moment we just re-enable the worker.
  -*/
  -if( w->mbean->disabled || w->in_error_state ) {
  -env->l->jkLog(env, env->l, JK_LOG_INFO,
  -  "lb.updateWorkers() re-enabling %s %s\n",
  -  w->channel->mbean->name, instanceId );
  -w->mbean->disabled=JK_FALSE;
  -w->in_error_state=JK_FALSE;
  -}
  -
  -found=JK_TRUE;
  -break;
  -}
  -}
  -}
  -
  -if( found==JK_TRUE ) {
  -env->l->jkLog(env, env->l, JK_LOG_INFO,
  -  "lb.updateWorkers() already found %s %s\n",
  -  chName, instanceId);
  -return JK_OK;
  -}
  -
  -config=lb->workerEnv->config;
  -
  -tmpBuf=(char *)env->tmpPool->calloc( env, env->tmpPool, strlen( chName ) + 10 );
  -strcpy( tmpBuf, chName );
  -strcat( tmpBuf, ".name" );
  -
  -config->setPropertyStr

Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-14 Thread Bernd Koecke

[EMAIL PROTECTED] wrote:
> On Tue, 14 May 2002, Bernd Koecke wrote:
> 
> 
>>The '0' as lb_value is needed to determine which are the main/local-workers. If 
>>we don't have this special value we need an additional config-flag with a list 
>>of the local/main-workers like in Mathias patch.
>>
>>Should I add an additional config-flag (I will take it from Mathias patch) or do 
>>we stay with the special '0' value?
> 
> 
> I think it would be a good idea, it'll make things cleaner.
> 
> 'local_worker' would be allways selected, and if 'main_worker_mode' ( or 
> maybe 'hw_lb_mode' ) no fallback will happen.
> 
> 
> 
>>The 'main_worker_mode' is not the same like the 'in_main_worker_mode' var in 
>>lb_worker struct. If 'main_worker_mode' flag is set to 'reject' in the 
>>workers.properties the reject var of lb_worker struct is set to JK_TRUE. The 
>>'in_main_worker_mode' var of lb_worker struct is set to JK_TRUE if there is in 
>>minimum one worker with '0' as lb_value.
> 
> 
> That's a bit confusing. Maybe some better variable names are needed.
> 
> 2 flags should be enough - 'local_worker' and 'local_worker_only' ( or 
> something that makes it clear that if the flag is set, no fallback will
> occur but an error is returned for the hw balancer ).

Ok, how should we handle the local_worker list? The current code depends on one 
worker list. And for requests with a session its easier to look into one list. 
Is it ok to have the balanced_workers and one ore more of these workers could be 
  in the local_worker list? Then we could leave must of the code in validate 
function untouched and after getting all the workers we go through the 
local_worker list, if any, and move the worker from this list at the beginning 
of the balanced_workers and mark them as local. Would this be ok? Oterwise we 
have to handle two lists and it would be possible to have only local workers and 
no balanced_workers. Then the lb_module makes no sense, but it is configurable 
and we have to deal with this. Another solution is to have two lists in config 
but only one in lb_worker. But then we have to rewrite most of the code in 
validate and handle memory etc. You know I'm not so experienced in C, so I would 
prefere the first suggestion :).

Bernd

> 
> I'll implement the same thing in jk2, but I wait your patch for jk1.
> 
> Costin
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 



-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-13 Thread costinm

On Tue, 14 May 2002, Bernd Koecke wrote:

> The '0' as lb_value is needed to determine which are the main/local-workers. If 
> we don't have this special value we need an additional config-flag with a list 
> of the local/main-workers like in Mathias patch.
> 
> Should I add an additional config-flag (I will take it from Mathias patch) or do 
> we stay with the special '0' value?

I think it would be a good idea, it'll make things cleaner.

'local_worker' would be allways selected, and if 'main_worker_mode' ( or 
maybe 'hw_lb_mode' ) no fallback will happen.


> The 'main_worker_mode' is not the same like the 'in_main_worker_mode' var in 
> lb_worker struct. If 'main_worker_mode' flag is set to 'reject' in the 
> workers.properties the reject var of lb_worker struct is set to JK_TRUE. The 
> 'in_main_worker_mode' var of lb_worker struct is set to JK_TRUE if there is in 
> minimum one worker with '0' as lb_value.

That's a bit confusing. Maybe some better variable names are needed.

2 flags should be enough - 'local_worker' and 'local_worker_only' ( or 
something that makes it clear that if the flag is set, no fallback will
occur but an error is returned for the hw balancer ).

I'll implement the same thing in jk2, but I wait your patch for jk1.

Costin




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-13 Thread Bernd Koecke

GOMEZ Henri wrote:
>>The '0' as lb_value is needed to determine which are the 
>>main/local-workers. If 
>>we don't have this special value we need an additional 
>>config-flag with a list 
>>of the local/main-workers like in Mathias patch.
>>
>>Should I add an additional config-flag (I will take it from 
>>Mathias patch) or do 
>>we stay with the special '0' value?
> 
> 
> It will be very usefull to make a short documentation
> on latest lb work mode and configuration.
> 
> Like a descriptive mail to this list, I'll commit mod_jk
> document accordingly...
> 

A short description of my latest patch is in my mail from 6.May 18:23 CEST.

If we add a new conf-flag I will test it localy and send a detailed description 
with the patch. If we don't add a flag I'll send a more detailed description 
about the latest patch.

Bernd
-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-13 Thread GOMEZ Henri

>The '0' as lb_value is needed to determine which are the 
>main/local-workers. If 
>we don't have this special value we need an additional 
>config-flag with a list 
>of the local/main-workers like in Mathias patch.
>
>Should I add an additional config-flag (I will take it from 
>Mathias patch) or do 
>we stay with the special '0' value?

It will be very usefull to make a short documentation
on latest lb work mode and configuration.

Like a descriptive mail to this list, I'll commit mod_jk
document accordingly...

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-13 Thread Bernd Koecke

[EMAIL PROTECTED] wrote:
> On Mon, 13 May 2002, Bernd Koecke wrote:
> 
> 
>>Sorry, I must say it again, for my environment it is an error, if a _switched
>>off_ tomcat got a request without a sessionid or with a session from another 
>>node. Its not necessary that this tomact-apache tandem is
> 
> 
> In the current code ( in jk2 ), if a worker is in 'disabled' state it'll 
> only get requests with sessionid, as you need.
> 
> If it is not disabled, but has a higher level ( == distance ), it'll
> still not get any new requests unless all closer workers are in error
> state.
> 
> 
>>update and start them up again. If there are no local/main worker I need an 
>>error response and no routing to a switched off tomcat. Its possible that this 
>>happens once per day.
> 
> 
> Setting the non-local workers in disabled state should do that. 
> 
> 
> 
>>I know this might be a special environment. I spent some time in jk1 to
>>build a working patch. Than I started looking in jk2. I'm not a good C
> 
> 
> Your patch looks ok. Would it be possible to remove the use of '0' as 
> a special value, and keep only the main_worker_mode flag for that ?
> Also, what's the meaning of 'reject' flag ? 
> 

The '0' as lb_value is needed to determine which are the main/local-workers. If 
we don't have this special value we need an additional config-flag with a list 
of the local/main-workers like in Mathias patch.

Should I add an additional config-flag (I will take it from Mathias patch) or do 
we stay with the special '0' value?

The reject value of the 'main_worker_mode' flag is for the special behavior not 
to balance even if no main-worker is up. Without this flag you would send a 
request to a non main-worker if all main-workers are in error state. When the 
main-workers are only a preference it might be ok to send a request to a non 
main-worker and lose only the session but don't send an error response. I think 
this was what Mathias said. But I need an error response if the main-worker is down.

The 'main_worker_mode' is not the same like the 'in_main_worker_mode' var in 
lb_worker struct. If 'main_worker_mode' flag is set to 'reject' in the 
workers.properties the reject var of lb_worker struct is set to JK_TRUE. The 
'in_main_worker_mode' var of lb_worker struct is set to JK_TRUE if there is in 
minimum one worker with '0' as lb_value.

> Also it would be nice to get some documentation for the new settings.
> 

Thats no problem, I could write a patch for the HTML-page.

> Regarding jk2 - I just want to know if the current solution is ok or 
> what are still problems. For now the priority is getting the patch in jk1
> so it can be released in 4.0.4 final ( so today or early tommorow I would 
> like to close this issue ). 

This sounds pretty good, many thanks!

Bernd


> 
> Costin 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 



-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-13 Thread costinm

On Mon, 13 May 2002, Bernd Koecke wrote:

> Sorry, I must say it again, for my environment it is an error, if a _switched
> off_ tomcat got a request without a sessionid or with a session from another 
> node. Its not necessary that this tomact-apache tandem is

In the current code ( in jk2 ), if a worker is in 'disabled' state it'll 
only get requests with sessionid, as you need.

If it is not disabled, but has a higher level ( == distance ), it'll
still not get any new requests unless all closer workers are in error
state.

> update and start them up again. If there are no local/main worker I need an 
> error response and no routing to a switched off tomcat. Its possible that this 
> happens once per day.

Setting the non-local workers in disabled state should do that. 


> I know this might be a special environment. I spent some time in jk1 to
> build a working patch. Than I started looking in jk2. I'm not a good C

Your patch looks ok. Would it be possible to remove the use of '0' as 
a special value, and keep only the main_worker_mode flag for that ?
Also, what's the meaning of 'reject' flag ? 

Also it would be nice to get some documentation for the new settings.

Regarding jk2 - I just want to know if the current solution is ok or 
what are still problems. For now the priority is getting the patch in jk1
so it can be released in 4.0.4 final ( so today or early tommorow I would 
like to close this issue ). 

Costin 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-13 Thread Bernd Koecke

Mathias Herberts wrote:
 > [EMAIL PROTECTED] wrote:
 >
 >> costin  02/05/09 14:06:48
 >>
 >> Modified:jk/native2/common jk_worker_lb.c Log: That's the big one.
 >>
 >> Please review !
 >>
 >> It changes the handling of lb_value to int. I also cleaned up the logic so
 >> it's easier ( I hope ) to understand what's happening. "Levels" replace the
 >> 'local worker', I thing I got the logic straight for those.
 >>
 >> I started to add a 'introspection' data, to validate and better report the
 >> config.
 >>
 >> We use one table per level. At the moment the maximum number of workers is
 >> hardcoded ( to 255 ), we could make it dynamic but that would make things
 >> pretty complex when we add workers dynamically ( it won't work without a CS
 >> or atomic operations )
 >
 >
 > Hi Costin,
 >
 > I read your code throughly and found no problem in get_most_suitable_worker,
 > I think your approach to prioritizing workers is the best. What bernd and I
 > had done was mainly driven by the need to have a frontal load balancer detect
 > the failure of the local worker(s). Since my last patch and having read yours
 > I think I found a better way to make the load balancer detect failures.
 >
 > Configure all Apache instances so they see all Tomcat instances, assign a
 > higher priority to local workers on each Apache, therefore local workers will
 > be chosen first. On each Apache, the load balancing worker is called lb.
 > Another load balancing worker, balancing only the local workers, is called
 > hwlb. The hardware load balancer checks the health of the Apache servers
 > using a URI which is served by hwlb instead of lb, therefore if there are no
 > more local workers left alive, the requests the hardware load balancer
 > dispatches to the associated Apache before it can detect the local workers
 > failure will be rerouted to the other non local workers and the client will
 > only loose its session information, she will not get any errors. When the
 > hardware load balancer ends up detecting the local workers failure (because
 > the hwlb worker rejected the request due to the lack of available worker), it
 > will declare the Apache inactive and will only use the other ones.
 >
 > This setup solves my use cases at least, I don't know for Bernd's.

Sorry, I must say it again, for my environment it is an error, if a _switched
off_ tomcat got a request without a sessionid or with a session from another 
node. Its not necessary that this tomact-apache tandem is
shut down. We switch off a port on this node and than the balancer wouldn't send
a request to it. And than no mod_jk is allowed to send a request to it without a
session for this node. It is normal that some nodes are _switched off_. We need
this for a a graceful update. We switch off some nodes, wait till there are no 
active sessions (all timed out) and then we shutdown apache + tomcat, make an 
update and start them up again. If there are no local/main worker I need an 
error response and no routing to a switched off tomcat. Its possible that this 
happens once per day.

I know this might be a special environment. I spent some time in jk1 to
build a working patch. Than I started looking in jk2. I'm not a good C
developer, so I needed some time for looking into jk2. Now I think I understand
the internal structure. I don't want to send untested patches or patches which
build more problems than it solves. The last patch I sent for jk1 solved my
problem, I tested it here on a testcluster and I hope it broke no prior
functionality. But it will take some time till I could send a patch for jk2. My 
boss give me some deadlines for other projects, one is next Wednesday. I would 
be happy if jk2 make it possible to use local/main-worker with sticky sessions 
(need only one per node/mod_jk). And if all local/main-worker are down the 
request gets an error-response. I will do my best to install a jk2 on my test 
cluster and try to play around with it.

May be I misunderstood Mathias suggestion for jk2, than delete the whole mail 
:). I hope I could send a patch for jk2 or look into the new code shortly.

Again, I think its a very good idea to use ints for lb_value, set a maximum and 
correct the value if one reaches this upper bound. And its a good idea to make 
the local/main-worker a more general thing. For a cluster environment it is a 
nice feature :).

Thanks

Bernd

 >
 > There remains a related problem in jk_requtil in jk2_requtil_getCookieByName,
 > as I mentioned several months ago on the list, the cookie extraction does not
 > work for cookies whose format conforms to RFC 2169, that is the cookie value
 > is enclosed in double quotes. Such cookie format is used by lynx for example.
 > I had submitted a patch into the bug database but cannot find it anymore,
 > I'll have to look up my archives.
 >
 > Good job on the lb worker Costin,
 >
 > Mathias.



-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: [EMAIL PRO

Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-10 Thread costinm

Hi Mathias,

Thanks for the review.

Few comments:

> Configure all Apache instances so they see all Tomcat instances, assign
> a higher priority to local workers on each Apache, therefore local

What you set is the 'level' ( or proximity, distance, etc ) - lower 
numbers mean closer ( and higher priority, local worker ). 

I still need to add and verify the setters and check the various cases.

> workers, is called hwlb. The hardware load balancer checks the health of
> the Apache servers using a URI which is served by hwlb instead of lb,

You may have noticed the 'jk_status' worker - it displays runtime 
informations ( still in progress - we need to agregate the statistics 
from all workers using shm, but the status of the workers should be fine ).

It can be easily extended ( or a similar handler added ) so it 
can generate info that can be 'consumed' by a front load balancer
or other tools. Like number of active workers and average response times.


I am also investigating how we can use the number of active connections
on each worker and the response times in the main lb, any idea would
be wellcome :-)


> This setup solves my use cases at least, I don't know for Bernd's.

Ok, but let me know if you find jk2 acceptable for your case and 
what is the minimal change to jk1 that we can do. I still have 
to merge your patches, I was waiting for more comments.

I don't think we can/should backport the new code, it's far too
much. 


> There remains a related problem in jk_requtil in
> jk2_requtil_getCookieByName, as I mentioned several months ago on the
> list, the cookie extraction does not work for cookies whose format
> conforms to RFC 2169, that is the cookie value is enclosed in double
> quotes. Such cookie format is used by lynx for example. I had submitted
> a patch into the bug database but cannot find it anymore, I'll have to
> look up my archives.

Please do, and send it to the list ( with PATCH ).

I would apreciate 2 patches, one for jk1 and one for jk2 ( if the problem 
is in both ).

Costin


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-10 Thread Mathias Herberts

[EMAIL PROTECTED] wrote:
> 
> costin  02/05/09 14:06:48
> 
>   Modified:jk/native2/common jk_worker_lb.c
>   Log:
>   That's the big one.
> 
>   Please review !
> 
>   It changes the handling of lb_value to int. I also cleaned up the logic so
>   it's easier ( I hope ) to understand what's happening. "Levels" replace
>   the 'local worker', I thing I got the logic straight for those.
> 
>   I started to add a 'introspection' data, to validate and better report
>   the config.
> 
>   We use one table per level. At the moment the maximum number of workers
>   is hardcoded ( to 255 ), we could make it dynamic but that would make things
>   pretty complex when we add workers dynamically ( it won't work without
>   a CS or atomic operations )

Hi Costin,

I read your code throughly and found no problem in
get_most_suitable_worker, I think your approach to prioritizing workers
is the best. What bernd and I had done was mainly driven by the need to
have a frontal load balancer detect the failure of the local worker(s).
Since my last patch and having read yours I think I found a better way
to make the load balancer detect failures.

Configure all Apache instances so they see all Tomcat instances, assign
a higher priority to local workers on each Apache, therefore local
workers will be chosen first. On each Apache, the load balancing worker
is called lb. Another load balancing worker, balancing only the local
workers, is called hwlb. The hardware load balancer checks the health of
the Apache servers using a URI which is served by hwlb instead of lb,
therefore if there are no more local workers left alive, the requests
the hardware load balancer dispatches to the associated Apache before it
can detect the local workers failure will be rerouted to the other non
local workers and the client will only loose its session information,
she will not get any errors. When the hardware load balancer ends up
detecting the local workers failure (because the hwlb worker rejected
the request due to the lack of available worker), it will declare the
Apache inactive and will only use the other ones.

This setup solves my use cases at least, I don't know for Bernd's.

There remains a related problem in jk_requtil in
jk2_requtil_getCookieByName, as I mentioned several months ago on the
list, the cookie extraction does not work for cookies whose format
conforms to RFC 2169, that is the cookie value is enclosed in double
quotes. Such cookie format is used by lynx for example. I had submitted
a patch into the bug database but cannot find it anymore, I'll have to
look up my archives.

Good job on the lb worker Costin,

Mathias.

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-09 Thread costin

costin  02/05/09 14:06:48

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  That's the big one.
  
  Please review !
  
  It changes the handling of lb_value to int. I also cleaned up the logic so
  it's easier ( I hope ) to understand what's happening. "Levels" replace
  the 'local worker', I thing I got the logic straight for those.
  
  I started to add a 'introspection' data, to validate and better report
  the config.
  
  We use one table per level. At the moment the maximum number of workers
  is hardcoded ( to 255 ), we could make it dynamic but that would make things
  pretty complex when we add workers dynamically ( it won't work without
  a CS or atomic operations )
  
  Revision  ChangesPath
  1.12  +195 -181  jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- jk_worker_lb.c9 May 2002 00:01:43 -   1.11
  +++ jk_worker_lb.c9 May 2002 21:06:48 -   1.12
  @@ -77,6 +77,7 @@
   /* XXX make it longer - debugging only */
   #define WAIT_BEFORE_RECOVER (5) 
   
  +#define MAX_ATTEMPTS 3
   
   /** Find the best worker. In process, check if timeout expired
   for workers that failed in the past and give them another chance.
  @@ -90,115 +91,157 @@
jk_ws_service_t *s, int attempt)
   {
   jk_worker_t *rc = NULL;
  -double lb_min = 0.0;
  +int lb_min = 0;
  +int lb_max = 0;
   int i;
  +int j;
  +int level;
  +int currentLevel=JK_LB_LEVELS - 1;
   char *session_route;
   time_t now = 0;
   
   session_route = jk2_requtil_getSessionRoute(env, s);
  
   if(session_route) {
  -for(i = 0 ; i < lb->num_of_workers ; i++) {
  -jk_worker_t *w=lb->lb_workers[i];
  -
  -if(w->route != NULL &&
  -   0 == strcmp(session_route, w->route)) {
  -if(attempt > 0 && w->in_error_state) {
  -   break;
  -} else {
  -return w;
  - }
  +for( level=0; levelworkerCnt[level]; i++) {
  +jk_worker_t *w=lb->workerTables[level][i];
  +
  +if(w->route != NULL &&
  +   0 == strcmp(session_route, w->route)) {
  +if(attempt > 0 && w->in_error_state) {
  +/* We already tried to revive this worker. */
  +break;
  +} else {
  +return w;
  +}
  +}
   }
   }
   }
   
  -/** Get one worker that is ready */
  -for(i = 0 ; i < lb->num_of_workers ; i++) {
  -jk_worker_t *w=lb->lb_workers[i];
  -
  -if(w->in_error_state) {
  +/** Get one worker that is ready
  + */
  +for( level=0; levelworkerCnt[level] ; i++) {
  +jk_worker_t *w=lb->workerTables[level][i];
  +
   if( w->mbean->disabled ) continue;
  -
  -/* Check if it's ready for recovery */
  -/* if(!lb->lb_workers[i]->in_recovering) { */
  -if( now==0 )
  -now = time(NULL);
  -
  -if((now - w->error_time) > WAIT_BEFORE_RECOVER) {
  -env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -  "lb.getWorker() timeout expired, reenable again %s\n",
  -  w->mbean->name);
  -
  -w->in_recovering  = JK_TRUE;
  -w->in_error_state = JK_FALSE;
  +if( w->in_error_state ) continue;
   
  -/* No need to do that - if it'll be used again, then error time
  -   will be set automatically on error */
  -/*  w->error_time = now;   */
  -/* Not sure we need that either */
  -/*  w->retry_count++; */
  -
  -/* The worker's error state is reset, but that doesn't
  -   mean it'll be used - normal priority selection happens
  -   Don't give bigger priority to recovered workers
  -*/
  -/* rc = lb->lb_workers[i]; 
  -   break;
  -*/
  +if( rc==NULL ) {
  +rc=w;
  +currentLevel=level;
  +lb_min=w->lb_value;
  +continue;
   }
  -}
  -if( ! lb->lb_workers[i]->in_error_state ) {
  -if(lb->lb_workers[i]->lb_value == 0 ) {
  -/* That's the 'default' worker, it'll take all requests.
  - * All other worker

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-04 Thread nacho

nacho   02/05/04 12:07:53

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  * Bug: the worker was lost if only there was 1 worker configured
  
  Revision  ChangesPath
  1.9   +4 -1  jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- jk_worker_lb.c3 May 2002 22:12:17 -   1.8
  +++ jk_worker_lb.c4 May 2002 19:07:53 -   1.9
  @@ -450,7 +450,10 @@
*/
   jk_worker_t *first=lb->lb_workers[0];
   lb->lb_workers[0]=w;
  -lb->lb_workers[currentWorker]=first;
  +/* Only do the exchange if the worker is not the first */
  +if( currentWorker > 0 ) {
  +lb->lb_workers[currentWorker]=first;
  +}
   }
   
   
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-05-03 Thread costin

costin  02/05/03 10:49:05

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Try to fix the 'default worker' case.
  
  An lbfactor of 0 means the worker is used exclusively ( as long as it's alive).
  
  Revision  ChangesPath
  1.5   +65 -27jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jk_worker_lb.c25 Apr 2002 19:21:58 -  1.4
  +++ jk_worker_lb.c3 May 2002 17:49:04 -   1.5
  @@ -60,7 +60,7 @@
*  several workers.   *
* Author:  Gal Shachor <[EMAIL PROTECTED]>   *
* Based on:   *
  - * Version: $Revision: 1.4 $   *
  + * Version: $Revision: 1.5 $   *
***/
   
   #include "jk_pool.h"
  @@ -114,17 +114,18 @@
   double lb_min = 0.0;
   int i;
   char *session_route;
  +time_t now = 0;
   
   session_route = jk2_requtil_getSessionRoute(env, s);
  
   if(session_route) {
   for(i = 0 ; i < lb->num_of_workers ; i++) {
  -if(0 == strcmp(session_route, lb->lb_workers[i]->mbean->name)) {
  +if(0 == strcmp(session_route, lb->lb_workers[i]->route)) {
   if(attempt > 0 && lb->lb_workers[i]->in_error_state) {
  break;
   } else {
   return lb->lb_workers[i];
  -}
  + }
   }
   }
   }
  @@ -133,7 +134,8 @@
   for(i = 0 ; i < lb->num_of_workers ; i++) {
   if(lb->lb_workers[i]->in_error_state) {
   if(!lb->lb_workers[i]->in_recovering) {
  -time_t now = time(0);
  +if( now==0 )
  +now = time(NULL);
   
   if((now - lb->lb_workers[i]->error_time) > WAIT_BEFORE_RECOVER) {
   
  @@ -146,14 +148,25 @@
   }
   }
   } else {
  -if(lb->lb_workers[i]->lb_value < lb_min || !rc) {
  +if(lb->lb_workers[i]->lb_value == 0 ) {
  +/* That's the 'default' worker, it'll take all requests.
  + * All other workers are not used unless this is in error state.
  + *
  + * The 'break' will disable checking for recovery on other
  + * workers - but that doesn't matter as long as the default is 
alive.
  + */
  +rc=lb->lb_workers[i];
  +break;
  +}
  +if(lb->lb_workers[i]->lb_value < lb_min ||
  +   ( rc==NULL ) ) {
   lb_min = lb->lb_workers[i]->lb_value;
   rc = lb->lb_workers[i];
   }
   }
   }
   
  -if ( !rc ) {
  +if ( rc==NULL ) {
   /* no workers found (rc is null), now try as hard as possible to get a
  worker anyway, pick one with largest error time.. */
   for(i = 0 ; i < lb->num_of_workers ; i++) {
  @@ -164,7 +177,7 @@
  not continue to be retried over and over again.
   */
   if ( lb->lb_workers[i]->retry_count == 0 ) {
  -if ( rc ) {
  +if ( rc != NULL ) {
   /* pick the oldest failed worker */
   if ( lb->lb_workers[i]->error_time < rc->error_time ) {
   rc = lb->lb_workers[i];
  @@ -185,7 +198,8 @@
   }
   
   if ( rc  && rc->in_error_state ) {
  -time_t now = time(0);
  +if(now==0)
  +now = time(0);
   rc->in_recovering  = JK_TRUE;
   rc->error_time = now;
   rc->retry_count++;
  @@ -193,7 +207,12 @@
   }
   
   if(rc) {
  -rc->lb_value += rc->lb_factor;
  +if( rc->lb_value != 0 ) {
  +/* It it's the default, it'll remain the default - we don't
  +   increase the factor
  +*/
  +rc->lb_value += rc->lb_factor;
  +}
   }
   
   return rc;
  @@ -232,7 +251,22 @@
   /* */
   char *instanceId=slot->name+7;
   char *data=slot->data;
  +jk_msg_t *msg;
  +int chCnt;
  +
  +msg=jk2_msg_ajp_create2( env, env->tmpPool, slot->data, slot->size);
  +chCnt=msg->getInt(env, msg );
   
  + 

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-04-25 Thread costin

costin  02/04/25 12:21:58

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Added some code to check the shm 'version' and update the config.
  
  Not completed.
  
  Revision  ChangesPath
  1.4   +173 -97   jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_worker_lb.c15 Apr 2002 23:47:57 -  1.3
  +++ jk_worker_lb.c25 Apr 2002 19:21:58 -  1.4
  @@ -60,7 +60,7 @@
*  several workers.   *
* Author:  Gal Shachor <[EMAIL PROTECTED]>   *
* Based on:   *
  - * Version: $Revision: 1.3 $   *
  + * Version: $Revision: 1.4 $   *
***/
   
   #include "jk_pool.h"
  @@ -70,6 +70,7 @@
   #include "jk_config.h"
   #include "jk_env.h"
   #include "jk_requtil.h"
  +#include "jk_mt.h"
   
   #define DEFAULT_LB_FACTOR   (1.0)
   
  @@ -83,15 +84,15 @@
* This + ADDITIONAL_WAIT_LOAD will be set on all the workers
* that recover after an error.
*/
  -static double jk2_get_max_lb(jk_worker_t *p) 
  +static double jk2_get_max_lb(jk_worker_t *lb) 
   {
   int i;
   double rc = 0.0;
   
  -for(i = 0 ; i < p->num_of_workers ; i++) {
  -if(!p->lb_workers[i]->in_error_state) {
  -if(p->lb_workers[i]->lb_value > rc) {
  -rc = p->lb_workers[i]->lb_value;
  +for(i = 0 ; i < lb->num_of_workers ; i++) {
  +if(!lb->lb_workers[i]->in_error_state) {
  +if(lb->lb_workers[i]->lb_value > rc) {
  +rc = lb->lb_workers[i]->lb_value;
   }
   }
   }
  @@ -106,7 +107,7 @@
   
   It'll also adjust the load balancing factors.
   */
  -static jk_worker_t *jk2_get_most_suitable_worker(jk_env_t *env, jk_worker_t *p, 
  +static jk_worker_t *jk2_get_most_suitable_worker(jk_env_t *env, jk_worker_t *lb, 
jk_ws_service_t *s, int attempt)
   {
   jk_worker_t *rc = NULL;
  @@ -117,37 +118,37 @@
   session_route = jk2_requtil_getSessionRoute(env, s);
  
   if(session_route) {
  -for(i = 0 ; i < p->num_of_workers ; i++) {
  -if(0 == strcmp(session_route, p->lb_workers[i]->mbean->name)) {
  -if(attempt > 0 && p->lb_workers[i]->in_error_state) {
  +for(i = 0 ; i < lb->num_of_workers ; i++) {
  +if(0 == strcmp(session_route, lb->lb_workers[i]->mbean->name)) {
  +if(attempt > 0 && lb->lb_workers[i]->in_error_state) {
  break;
   } else {
  -return p->lb_workers[i];
  +return lb->lb_workers[i];
   }
   }
   }
   }
   
   /** Get one worker that is ready */
  -for(i = 0 ; i < p->num_of_workers ; i++) {
  -if(p->lb_workers[i]->in_error_state) {
  -if(!p->lb_workers[i]->in_recovering) {
  +for(i = 0 ; i < lb->num_of_workers ; i++) {
  +if(lb->lb_workers[i]->in_error_state) {
  +if(!lb->lb_workers[i]->in_recovering) {
   time_t now = time(0);
   
  -if((now - p->lb_workers[i]->error_time) > WAIT_BEFORE_RECOVER) {
  +if((now - lb->lb_workers[i]->error_time) > WAIT_BEFORE_RECOVER) {
   
  -p->lb_workers[i]->in_recovering  = JK_TRUE;
  -p->lb_workers[i]->error_time = now;
  -p->lb_workers[i]->retry_count++;
  -rc = p->lb_workers[i];
  +lb->lb_workers[i]->in_recovering  = JK_TRUE;
  +lb->lb_workers[i]->error_time = now;
  +lb->lb_workers[i]->retry_count++;
  +rc = lb->lb_workers[i];
   
   break;
   }
   }
   } else {
  -if(p->lb_workers[i]->lb_value < lb_min || !rc) {
  -lb_min = p->lb_workers[i]->lb_value;
  -rc = p->lb_workers[i];
  +if(lb->lb_workers[i]->lb_value < lb_min || !rc) {
  +lb_min = lb->lb_workers[i]->lb_value;
  +rc = lb->lb_workers[i];
   }
   }
   }
  @@ -155,29 +156,29 @@
   if ( !rc ) {
   /* no workers found (rc is null), now try as hard as possible to get a
  worker anyway, pick one with largest error time.. */
  -for(i = 0 ; 

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-04-15 Thread costin

costin  02/04/15 16:47:57

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Patch from Eugene Gluzberg <[EMAIL PROTECTED]>
  
  > If a tomcat goes down, it gets taken out of the "worker list" for 60
  > seconds, before its retried. If all the tomcats that are being load balanced
  > are being restarted (one at a time to upgrade the system for instance), you
  > need to wait until the tomcat that you just brought up to get back in the
  > list before you shut down the next one, or you may have website downtime.
  > Same problem if any intermittent network problem would occur between
  > Netscape and tomcat. The downtime would be at least 60 seconds.
  
  > To avoid that I made a fix to the load balancer worker that would be
  > activated only when all the tomcat workers were taken out of the list due to
  > failure.
  
  > If all the load balanced tomcat workers are out of the list, the patched
  > load balancer would go through all of the workers again once in reverse
  > order of their "last error time" until one is found. They would be retried
  > even though 60 seconds did not pass yet. If and only if all the workers have
  > been tried once in this particular request and all failed an error would be
  > returned to the user. The retries would continue for every request until at
  > least one tomcat worker recovers. After the first tomcat worker recovers,
  > the rest would be retried once every 60 seconds as before.
  
  Revision  ChangesPath
  1.3   +52 -1 jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_worker_lb.c12 Apr 2002 00:23:07 -  1.2
  +++ jk_worker_lb.c15 Apr 2002 23:47:57 -  1.3
  @@ -60,7 +60,7 @@
*  several workers.   *
* Author:  Gal Shachor <[EMAIL PROTECTED]>   *
* Based on:   *
  - * Version: $Revision: 1.2 $   *
  + * Version: $Revision: 1.3 $   *
***/
   
   #include "jk_pool.h"
  @@ -128,6 +128,7 @@
   }
   }
   
  +/** Get one worker that is ready */
   for(i = 0 ; i < p->num_of_workers ; i++) {
   if(p->lb_workers[i]->in_error_state) {
   if(!p->lb_workers[i]->in_recovering) {
  @@ -137,6 +138,7 @@
   
   p->lb_workers[i]->in_recovering  = JK_TRUE;
   p->lb_workers[i]->error_time = now;
  +p->lb_workers[i]->retry_count++;
   rc = p->lb_workers[i];
   
   break;
  @@ -150,6 +152,45 @@
   }
   }
   
  +if ( !rc ) {
  +/* no workers found (rc is null), now try as hard as possible to get a
  +   worker anyway, pick one with largest error time.. */
  +for(i = 0 ; i < p->num_of_workers ; i++) {
  +if(p->lb_workers[i]->in_error_state) {
  +if(!p->lb_workers[i]->in_recovering) {
  +/* if the retry count is zero, that means the worker only
  +   failed once, this is to e that the failed worker will
  +   not continue to be retried over and over again.
  +*/
  +if ( p->lb_workers[i]->retry_count == 0 ) {
  +if ( rc ) {
  +/* pick the oldest failed worker */
  +if ( p->lb_workers[i]->error_time < rc->error_time ) {
  +rc = p->lb_workers[i];
  +}
  +} else {
  +rc = p->lb_workers[i];
  +}
  +}
  +}
  +} else {
  +/* This is a good worker - it may have come to life */
  +if(p->lb_workers[i]->lb_value < lb_min || rc != NULL) {
  +lb_min = p->lb_workers[i]->lb_value;
  +rc = p->lb_workers[i];
  +break;
  +}
  +}
  +}
  +
  +if ( rc  && rc->in_error_state ) {
  +time_t now = time(0);
  +rc->in_recovering  = JK_TRUE;
  +rc->error_time = now;
  +rc->retry_count++;
  +}
  +}
  +
   if(rc) {
   rc->lb_value += rc->lb_factor;
   }
  @@ -167,6 +208,7 @@
   jk_ws_service_t *s)
   {
   int attempt=0;
  

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c

2002-04-11 Thread costin

costin  02/04/11 17:23:07

  Modified:jk/native2/common jk_worker_lb.c
  Log:
  Fix and test the lb worker.
  
  We'll refresh the internal fields every time a new lb worker is added
  ( it could happen at runtime - until now it was fixed )
  
  Revision  ChangesPath
  1.2   +97 -57jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_worker_lb.c20 Mar 2002 23:39:36 -  1.1
  +++ jk_worker_lb.c12 Apr 2002 00:23:07 -  1.2
  @@ -60,7 +60,7 @@
*  several workers.   *
* Author:  Gal Shachor <[EMAIL PROTECTED]>   *
* Based on:   *
  - * Version: $Revision: 1.1 $   *
  + * Version: $Revision: 1.2 $   *
***/
   
   #include "jk_pool.h"
  @@ -112,7 +112,9 @@
   jk_worker_t *rc = NULL;
   double lb_min = 0.0;
   int i;
  -char *session_route = jk2_requtil_getSessionRoute(env, s);
  +char *session_route;
  +
  +session_route = jk2_requtil_getSessionRoute(env, s);
  
   if(session_route) {
   for(i = 0 ; i < p->num_of_workers ; i++) {
  @@ -176,9 +178,16 @@
   s->realWorker=NULL;
   
   while(1) {
  -jk_worker_t *rec = jk2_get_most_suitable_worker(env, w, s, attempt++);
  +jk_worker_t *rec;
   int rc;
   
  +if( w->num_of_workers==1 ) {
  +/* A single worker - no need to search */
  +rec=w->lb_workers[0];
  +} else {
  +rec=jk2_get_most_suitable_worker(env, w, s, attempt++);
  +}
  +
   s->is_recoverable_error = JK_FALSE;
   
   if(rec == NULL) {
  @@ -233,6 +242,65 @@
   return JK_FALSE;
   }
   
  +/** Init internal structures.
  +Called any time the config changes
  +*/
  +static int JK_METHOD jk2_lb_initLbArray(jk_env_t *env, jk_worker_t *_this)
  +{
  +int currentWorker=0;
  +int i;
  +_this->num_of_workers=_this->lbWorkerMap->size( env, _this->lbWorkerMap);
  +
  +if( _this->lb_workers_size < _this->num_of_workers ) {
  +if( _this->lb_workers_size==0 ) {
  +_this->lb_workers_size=10;
  +} else {
  +_this->lb_workers_size = 2 * _this->lb_workers_size;
  +}
  +_this->lb_workers =
  +_this->pool->alloc(env, _this->pool, 
  +   _this->lb_workers_size * sizeof(jk_worker_t *));
  +if(!_this->lb_workers) {
  +env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +  "lb_worker.validate(): OutOfMemoryException\n");
  +return JK_FALSE;
  +}
  +}
  +
  +for(i = 0 ; i < _this->num_of_workers ; i++) {
  +char *name = _this->lbWorkerMap->nameAt( env, _this->lbWorkerMap, i);
  +jk_worker_t *w= env->getByName( env, name );
  +if( w== NULL ) {
  +env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +  "lb_worker.init(): no worker found %s\n", name);
  +   _this->num_of_workers--;
  +continue;
  +}
  +
  +_this->lb_workers[currentWorker]=w;
  +
  +if( _this->lb_workers[currentWorker]->lb_factor == 0 )
  +_this->lb_workers[currentWorker]->lb_factor = DEFAULT_LB_FACTOR;
  +
  +_this->lb_workers[currentWorker]->lb_factor =
  +1/ _this->lb_workers[currentWorker]->lb_factor;
  +
  +/* 
  + * Allow using lb in fault-tolerant mode.
  + * Just set lbfactor in worker.properties to 0 to have 
  + * a worker used only when principal is down or session route
  + * point to it. Provided by Paul Frieden <[EMAIL PROTECTED]>
  + */
  +_this->lb_workers[currentWorker]->lb_value =
  +_this->lb_workers[currentWorker]->lb_factor;
  +_this->lb_workers[currentWorker]->in_error_state = JK_FALSE;
  +_this->lb_workers[currentWorker]->in_recovering  = JK_FALSE;
  +
  +currentWorker++;
  +}
  +return JK_TRUE;
  +}
  +
   static int JK_METHOD jk2_lb_setProperty(jk_env_t *env, jk_bean_t *mbean, 
   char *name, void *valueP)
   {
  @@ -257,62 +325,31 @@
   for(i = 0 ; i < num_of_workers ; i++) {
   char *name = _this->pool->pstrdup(env, _this->pool, worker_names[i]);
   _this->lbWorkerMap->add(env, _this->lbWorkerMap, name, "");
  +env->l->jkLog(env, env->l, JK_LOG_INFO,
  +  

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_lb.c jk_lb_worker.c

2002-03-20 Thread costin

costin  02/03/20 15:39:36

  Added:   jk/native2/common jk_worker_lb.c
  Removed: jk/native2/common jk_lb_worker.c
  Log:
  Renamed to follow the same naming scheme with the rest of the code.
  
  Revision  ChangesPath
  1.1  jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===
  /* = *
   *   *
   * The Apache Software License,  Version 1.1 *
   *   *
   *  Copyright (c) 1999-2001 The Apache Software Foundation.  *
   *   All rights reserved.*
   *   *
   * = *
   *   *
   * Redistribution and use in source and binary forms,  with or without modi- *
   * fication, are permitted provided that the following conditions are met:   *
   *   *
   * 1. Redistributions of source code  must retain the above copyright notice *
   *notice, this list of conditions and the following disclaimer.  *
   *   *
   * 2. Redistributions  in binary  form  must  reproduce the  above copyright *
   *notice,  this list of conditions  and the following  disclaimer in the *
   *documentation and/or other materials provided with the distribution.   *
   *   *
   * 3. The end-user documentation  included with the redistribution,  if any, *
   *must include the following acknowlegement: *
   *   *
   *   "This product includes  software developed  by the Apache  Software *
   *Foundation ."  *
   *   *
   *Alternately, this acknowlegement may appear in the software itself, if *
   *and wherever such third-party acknowlegements normally appear. *
   *   *
   * 4. The names  "The  Jakarta  Project",  "Jk",  and  "Apache  Software *
   *Foundation"  must not be used  to endorse or promote  products derived *
   *from this  software without  prior  written  permission.  For  written *
   *permission, please contact <[EMAIL PROTECTED]>.*
   *   *
   * 5. Products derived from this software may not be called "Apache" nor may *
   *"Apache" appear in their names without prior written permission of the *
   *Apache Software Foundation.*
   *   *
   * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
   * INCLUDING, BUT NOT LIMITED TO,  THE IMPLIED WARRANTIES OF MERCHANTABILITY *
   * AND FITNESS FOR  A PARTICULAR PURPOSE  ARE DISCLAIMED.  IN NO EVENT SHALL *
   * THE APACHE  SOFTWARE  FOUNDATION OR  ITS CONTRIBUTORS  BE LIABLE  FOR ANY *
   * DIRECT,  INDIRECT,   INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL *
   * DAMAGES (INCLUDING,  BUT NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE GOODS *
   * OR SERVICES;  LOSS OF USE,  DATA,  OR PROFITS;  OR BUSINESS INTERRUPTION) *
   * HOWEVER CAUSED AND  ON ANY  THEORY  OF  LIABILITY,  WHETHER IN  CONTRACT, *
   * STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
   * ANY  WAY  OUT OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF  ADVISED  OF THE *
   * POSSIBILITY OF SUCH DAMAGE.   *
   *   *
   * = *
   *   *
   * This software  consists of voluntary  contributions made  by many indivi- *
   * duals on behalf of the  Apache Software Foundation.  For more information *
   * on the Apache Software Foundation, please see .   *
   *   *
   * = */
  
  /*