tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r439810 - in /tomcat/connectors/trunk/jk/native/common: jk_lb_worker.c jk_lb_worker.h jk_status.c
Date Sun, 03 Sep 2006 17:49:27 GMT
Author: rjung
Date: Sun Sep  3 10:49:26 2006
New Revision: 439810

URL: http://svn.apache.org/viewvc?view=rev&rev=439810
Log:
Refactor getting strings from integer constants in lb.
Avoid getting compilation warnings.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h
    tomcat/connectors/trunk/jk/native/common/jk_status.c

Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c?view=diff&rev=439810&r1=439809&r2=439810
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Sun Sep  3 10:49:26 2006
@@ -42,6 +42,39 @@
 #define JK_WORKER_USABLE(w)   ((w)->state != JK_LB_STATE_ERROR && (w)->state
!= JK_LB_STATE_BUSY && (w)->activation != JK_LB_ACTIVATION_STOPPED && (w)->activation
!= JK_LB_ACTIVATION_DISABLED)
 #define JK_WORKER_USABLE_STICKY(w)   ((w)->state != JK_LB_STATE_ERROR && (w)->activation
!= JK_LB_ACTIVATION_STOPPED)
 
+static const char *lb_locking_type[] = {
+    "unknown",
+    JK_LB_LOCK_TEXT_OPTIMISTIC,
+    JK_LB_LOCK_TEXT_PESSIMISTIC,
+    NULL
+};
+
+static const char *lb_method_type[] = {
+    "unknown",
+    JK_LB_METHOD_TEXT_REQUESTS,
+    JK_LB_METHOD_TEXT_TRAFFIC,
+    JK_LB_METHOD_TEXT_BUSYNESS,
+    NULL
+};
+
+static const char *lb_state_type[] = {
+    "unknown",
+    JK_LB_STATE_TEXT_NA,
+    JK_LB_STATE_TEXT_OK,
+    JK_LB_STATE_TEXT_RECOVER,
+    JK_LB_STATE_TEXT_BUSY,
+    JK_LB_STATE_TEXT_ERROR,
+    NULL
+};
+
+static const char *lb_activation_type[] = {
+    "unknown",
+    JK_LB_ACTIVATION_TEXT_ACTIVE,
+    JK_LB_ACTIVATION_TEXT_DISABLED,
+    JK_LB_ACTIVATION_TEXT_STOPPED,
+    NULL
+};
+
 struct lb_endpoint
 {
     jk_endpoint_t *e;
@@ -75,6 +108,30 @@
     return a * b / gcd(a, b);
 }
 
+/* Return the string representation of the lb lock type */
+const char *jk_lb_get_lock(lb_worker_t *p, jk_logger_t *l)
+{
+    return lb_locking_type[p->lblock];
+}
+
+/* Return the string representation of the lb method type */
+const char *jk_lb_get_method(lb_worker_t *p, jk_logger_t *l)
+{
+    return lb_method_type[p->lbmethod];
+}
+
+/* Return the string representation of the balance worker state */
+const char *jk_lb_get_state(worker_record_t *p, jk_logger_t *l)
+{
+    return lb_state_type[p->s->state];
+}
+
+/* Return the string representation of the balance worker activation */
+const char *jk_lb_get_activation(worker_record_t *p, jk_logger_t *l)
+{
+    return lb_activation_type[p->s->activation];
+}
+
 /* Update the load multipliers wrt. lb_factor */
 void update_mult(lb_worker_t *p, jk_logger_t *l)
 {
@@ -618,7 +675,7 @@
     if (rc && JK_IS_DEBUG_LEVEL(l)) {
         jk_log(l, JK_LOG_DEBUG,
                "found best worker %s (%s) using method '%s'",
-               rc->s->name, rc->s->jvm_route, lb_method_type[p->lbmethod]);
+               rc->s->name, rc->s->jvm_route, jk_lb_get_method(p, l));
     }
     JK_TRACE_EXIT(l);
     return rc;
@@ -881,9 +938,9 @@
                     log_names[6] = JK_NOTE_LB_FIRST_BUSY;
                     log_values[6] = buf;
                     log_names[7] = JK_NOTE_LB_FIRST_ACTIVATION;
-                    log_values[7] = lb_activation_type[rec->s->activation];
+                    log_values[7] = jk_lb_get_activation(rec, l);
                     log_names[8] = JK_NOTE_LB_FIRST_STATE;
-                    log_values[8] = lb_state_type[rec->s->state];
+                    log_values[8] = jk_lb_get_state(rec, l);
                     s->add_log_items(s, log_names, log_values, JK_LB_NOTES_COUNT);
                 }
             }
@@ -960,9 +1017,9 @@
             log_names[6] = JK_NOTE_LB_LAST_BUSY;
             log_values[6] = buf;
             log_names[7] = JK_NOTE_LB_LAST_ACTIVATION;
-            log_values[7] = lb_activation_type[prec->s->activation];
+            log_values[7] = jk_lb_get_activation(prec, l);
             log_names[8] = JK_NOTE_LB_LAST_STATE;
-            log_values[8] = lb_state_type[prec->s->state];
+            log_values[8] = jk_lb_get_state(prec, l);
             s->add_log_items(s, log_names, log_values, JK_LB_NOTES_COUNT);
         }
     }
@@ -1041,7 +1098,7 @@
                 unsigned int ms = jk_get_max_packet_size(props, worker_names[i]);
                 if (ms > p->max_packet_size)
                     p->max_packet_size = ms;
-           }
+            }
             for (i = 0; i < num_of_workers; i++) {
                 const char *s;
                 strncpy(p->lb_workers[i].s->name, worker_names[i],

Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h?view=diff&rev=439810&r1=439809&r2=439810
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h Sun Sep  3 10:49:26 2006
@@ -103,39 +103,6 @@
 /* The exponent x is JK_LB_DECAY_MULT*#MAINT_INTV_SINCE_LAST_MAINT */
 #define JK_LB_DECAY_MULT         (1)
 
-static const char *lb_locking_type[] = {
-    "unknown",
-    JK_LB_LOCK_TEXT_OPTIMISTIC,
-    JK_LB_LOCK_TEXT_PESSIMISTIC,
-    NULL
-};
-
-static const char *lb_method_type[] = {
-    "unknown",
-    JK_LB_METHOD_TEXT_REQUESTS,
-    JK_LB_METHOD_TEXT_TRAFFIC,
-    JK_LB_METHOD_TEXT_BUSYNESS,
-    NULL
-};
-
-static const char *lb_state_type[] = {
-    "unknown",
-    JK_LB_STATE_TEXT_NA,
-    JK_LB_STATE_TEXT_OK,
-    JK_LB_STATE_TEXT_RECOVER,
-    JK_LB_STATE_TEXT_BUSY,
-    JK_LB_STATE_TEXT_ERROR,
-    NULL
-};
-
-static const char *lb_activation_type[] = {
-    "unknown",
-    JK_LB_ACTIVATION_TEXT_ACTIVE,
-    JK_LB_ACTIVATION_TEXT_DISABLED,
-    JK_LB_ACTIVATION_TEXT_STOPPED,
-    NULL
-};
-
 struct worker_record
 {
     jk_worker_t      *w;
@@ -169,6 +136,10 @@
 int JK_METHOD lb_worker_factory(jk_worker_t **w,
                                 const char *name, jk_logger_t *l);
 
+const char *jk_lb_get_lock(lb_worker_t *p, jk_logger_t *l);
+const char *jk_lb_get_method(lb_worker_t *p, jk_logger_t *l);
+const char *jk_lb_get_state(worker_record_t *p, jk_logger_t *l);
+const char *jk_lb_get_activation(worker_record_t *p, jk_logger_t *l);
 void reset_lb_values(lb_worker_t *p, jk_logger_t *l);
 void update_mult(lb_worker_t * p, jk_logger_t *l);
 

Modified: tomcat/connectors/trunk/jk/native/common/jk_status.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_status.c?view=diff&rev=439810&r1=439809&r2=439810
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_status.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_status.c Sun Sep  3 10:49:26 2006
@@ -437,8 +437,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_method_type[lb->lbmethod]);
-            jk_printf(s, "<td>%s</td>", lb_locking_type[lb->lblock]);
+            jk_printf(s, "<td>%s</td>", jk_lb_get_method(lb, l));
+            jk_printf(s, "<td>%s</td>", jk_lb_get_lock(lb, l));
             jk_printf(s, "<td>%d</td>", lb->s->recover_wait_time);
             jk_puts(s, "</tr>\n</table>\n<br/>\n");
             jk_puts(s, "<table><tr>"
@@ -460,8 +460,8 @@
                 jk_putv(s, "<td>", jk_dump_hinfo(&a->worker_inet_addr, buf),
                         "</td>", NULL);
                 /* TODO: descriptive status */
-                jk_putv(s, "<td>", lb_activation_type[wr->s->activation], "</td>",
NULL);
-                jk_putv(s, "<td>", lb_state_type[wr->s->state], "</td>",
NULL);
+                jk_putv(s, "<td>", jk_lb_get_activation(wr, l), "</td>", NULL);
+                jk_putv(s, "<td>", jk_lb_get_state(wr, l), "</td>", NULL);
                 jk_printf(s, "<td>%d</td>", wr->s->distance);
                 jk_printf(s, "<td>%d</td>", wr->s->lb_factor);
                 jk_printf(s, "<td>%" JK_UINT64_T_FMT "</td>", wr->s->lb_mult);
@@ -664,8 +664,8 @@
                 a->host,
                 a->port,
                 jk_dump_hinfo(&a->worker_inet_addr, buf),
-                lb_activation_type[wr->s->activation],
-                lb_state_type[wr->s->state]);
+                jk_lb_get_activation(wr, l),
+                jk_lb_get_state(wr, l));
 
             jk_printf(s, " distance=\"%d\"", wr->s->distance);
             jk_printf(s, " lbfactor=\"%d\"", wr->s->lb_factor);
@@ -763,7 +763,7 @@
             jk_log(l, JK_LOG_INFO,
                    "worker '%s' activation changed to '%s' via status worker",
                    wr->s->name,
-                   lb_activation_type[wr->s->activation]);
+                   jk_lb_get_activation(wr, l));
         }
         i = status_int("wx", s->query_string, wr->s->distance);
         if (wr->s->distance != i) {



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


Mime
View raw message