mturk       2005/05/15 08:22:06

  Modified:    jk/native/common jk_lb_worker.c jk_lb_worker.h jk_status.c
                        jk_util.c jk_util.h
  Log:
  Added lock directive for load balancer that allows more acurate
  load balancing in case of burst load. Also display both method and
  lock type in load balancer.
  
  Revision  Changes    Path
  1.88      +20 -2     jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c
  
  Index: jk_lb_worker.c
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- jk_lb_worker.c    15 May 2005 13:02:38 -0000      1.87
  +++ jk_lb_worker.c    15 May 2005 15:22:05 -0000      1.88
  @@ -229,7 +229,8 @@
       size_t curmin = 0;
   
       worker_record_t *candidate = NULL;
  -
  +    if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
  +        jk_shm_lock();
       /* First try to see if we have available candidate */
       for (i = 0; i < p->num_of_workers; i++) {
           /* Skip all workers that are not member of domain */
  @@ -262,6 +263,8 @@
               candidate->s->lb_value -= total_factor;
           candidate->r = &(candidate->s->domain[0]);
       }
  +    if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
  +        jk_shm_unlock();
   
       return candidate;
   }
  @@ -274,6 +277,8 @@
       int total_factor = 0;
       worker_record_t *candidate = NULL;
   
  +    if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
  +        jk_shm_lock();
       /* First try to see if we have available candidate */
       for (i = 0; i < p->num_of_workers; i++) {
           /* If the worker is in error state run
  @@ -298,6 +303,9 @@
   
       if (candidate)
           candidate->s->lb_value -= total_factor;
  +    if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
  +        jk_shm_unlock();
  +
       return candidate;
   }
   
  @@ -309,6 +317,8 @@
       size_t curmin = 0;
       worker_record_t *candidate = NULL;
   
  +    if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
  +        jk_shm_lock();
       /* First try to see if we have available candidate */
       for (i = 0; i < p->num_of_workers; i++) {
           /* If the worker is in error state run
  @@ -332,6 +342,8 @@
               }
           }
       }
  +    if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
  +        jk_shm_unlock();
       return candidate;
   }
   
  @@ -374,6 +386,9 @@
       }
       if (candidate && !uses_domain &&
           p->lbmethod == JK_LB_BYREQUESTS) {
  +        if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
  +            jk_shm_lock();
  +
           for (i = 0; i < p->num_of_workers; i++) {
               if (JK_WORKER_USABLE(p->lb_workers[i].s)) {
                   /* Skip all workers that are not member of candidate domain 
*/
  @@ -385,6 +400,8 @@
               }
           }
           candidate->s->lb_value -= total_factor;
  +        if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
  +            jk_shm_unlock();
       }
       return candidate;
   }
  @@ -848,6 +865,7 @@
           p->s->recover_wait_time = WAIT_BEFORE_RECOVER;
   
       p->lbmethod = jk_get_lb_method(props, p->s->name);
  +    p->lblock   = jk_get_lb_lock(props, p->s->name);
   
       JK_INIT_CS(&(p->cs), i);
       if (i == JK_FALSE) {
  
  
  
  1.15      +9 -3      jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.h
  
  Index: jk_lb_worker.h
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.h,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- jk_lb_worker.h    22 Feb 2005 08:42:45 -0000      1.14
  +++ jk_lb_worker.h    15 May 2005 15:22:05 -0000      1.15
  @@ -39,8 +39,13 @@
   
   #define JK_LB_BYREQUESTS      (0)
   #define JK_LB_BYTRAFFIC       (1)
  -#define JK_LB_METHOD_REQUESTS ("request")
  -#define JK_LB_METHODTRAFFIC   ("traffic")
  +#define JK_LB_METHOD_REQUESTS ("Request")
  +#define JK_LB_METHOD_TRAFFIC  ("Traffic")
  +#define JK_LB_LOCK_DEFAULT     (0)
  +#define JK_LB_LOCK_PESSIMISTIC (1)
  +#define JK_LB_LM_DEFAULT       ("Optimistic")
  +#define JK_LB_LM_PESSIMISTIC   ("Pessimistic")
  +
   #define WAIT_BEFORE_RECOVER   (60)
   
   struct worker_record
  @@ -58,6 +63,7 @@
       worker_record_t *lb_workers;
       unsigned int num_of_workers;
       int          lbmethod;
  +    int          lblock;
   
       jk_pool_t p;
       jk_pool_atom_t buf[TINY_POOL_SIZE];
  
  
  
  1.41      +5 -1      jakarta-tomcat-connectors/jk/native/common/jk_status.c
  
  Index: jk_status.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_status.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- jk_status.c       15 May 2005 11:27:06 -0000      1.40
  +++ jk_status.c       15 May 2005 15:22:05 -0000      1.41
  @@ -436,6 +436,8 @@
                       "<th>Type</th><th>Sticky session</th>"
                       "<th>Force Sticky session</th>"
                       "<th>Retries</th>"
  +                    "<th>Method</th>"
  +                    "<th>Lock</th>"
                       "</tr>\n<tr>");
               jk_putv(s, "<td>", status_worker_type(w->type), "</td>", NULL);
               jk_putv(s, "<td>", status_val_bool(lb->s->sticky_session),
  @@ -443,6 +445,8 @@
               jk_putv(s, "<td>", status_val_bool(lb->s->sticky_session_force),
                       "</td>", NULL);
               jk_printf(s, "<td>%d</td>", lb->s->retries);
  +            jk_printf(s, "<td>%s</td>", lb->lbmethod == JK_LB_BYREQUESTS ? 
JK_LB_METHOD_REQUESTS : JK_LB_METHOD_TRAFFIC);
  +            jk_printf(s, "<td>%s</td>", lb->lblock == JK_LB_LOCK_DEFAULT ? 
JK_LB_LM_DEFAULT : JK_LB_LM_PESSIMISTIC);
               jk_puts(s, "</tr>\n</table>\n<br/>\n");
               jk_puts(s, "<table><tr>"
                       "<th>Name</th><th>Type</th><th>Host</th><th>Addr</th>"
  
  
  
  1.69      +22 -1     jakarta-tomcat-connectors/jk/native/common/jk_util.c
  
  Index: jk_util.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_util.c,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- jk_util.c 15 May 2005 11:10:11 -0000      1.68
  +++ jk_util.c 15 May 2005 15:22:05 -0000      1.69
  @@ -66,6 +66,7 @@
   #define REDIRECT_OF_WORKER          ("redirect")
   #define MOUNT_OF_WORKER             ("mount")
   #define METHOD_OF_WORKER            ("method")
  +#define LOCK_OF_WORKER              ("lock")
   #define IS_WORKER_DISABLED          ("disabled")
   #define IS_WORKER_STOPPED           ("stopped")
   #define WORKER_RECOVER_TIME         ("recover_time")
  @@ -773,6 +774,26 @@
           return JK_LB_BYREQUESTS;
   }
   
  +int jk_get_lb_lock(jk_map_t *m, const char *wname)
  +{
  +    char buf[1024];
  +    const char *v;
  +    if (!m || !wname) {
  +        return JK_LB_LOCK_DEFAULT;
  +    }
  +
  +    MAKE_WORKER_PARAM(LOCK_OF_WORKER);
  +    v = jk_map_get_string(m, buf, NULL);
  +    if (!v)
  +        return JK_LB_LOCK_DEFAULT;
  +    else if  (*v == 'o' || *v == 'O' || *v == '1')
  +        return JK_LB_LOCK_DEFAULT;
  +    else if  (*v == 'p' || *v == 'P' || *v == '0')
  +        return JK_LB_LOCK_PESSIMISTIC;
  +    else
  +        return JK_LB_BYREQUESTS;
  +}
  +
   int jk_get_lb_worker_list(jk_map_t *m,
                             const char *wname,
                             char ***list, unsigned int *num_of_wokers)
  
  
  
  1.34      +3 -1      jakarta-tomcat-connectors/jk/native/common/jk_util.h
  
  Index: jk_util.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_util.h,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- jk_util.h 15 May 2005 11:10:11 -0000      1.33
  +++ jk_util.h 15 May 2005 15:22:06 -0000      1.34
  @@ -98,6 +98,8 @@
   
   int jk_get_lb_method(jk_map_t *m, const char *wname);
   
  +int jk_get_lb_lock(jk_map_t *m, const char *wname);
  +
   int jk_get_lb_worker_list(jk_map_t *m,
                             const char *lb_wname,
                             char ***list, unsigned int *num_of_wokers);
  
  
  

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

Reply via email to