tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r562194 - in /tomcat/connectors/trunk/jk: native/common/jk_ajp13.h native/common/jk_ajp_common.c native/common/jk_lb_worker.c xdocs/miscellaneous/changelog.xml xdocs/reference/workers.xml
Date Thu, 02 Aug 2007 17:42:24 GMT
Author: rjung
Date: Thu Aug  2 10:42:23 2007
New Revision: 562194

URL: http://svn.apache.org/viewvc?view=rev&rev=562194
Log:
Make fail_on_status more useful in combination with an LB.
We can now optionally only fail over, without putting the
failed worker in an error state.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_ajp13.h
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
    tomcat/connectors/trunk/jk/xdocs/reference/workers.xml

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp13.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp13.h?view=diff&rev=562194&r1=562193&r2=562194
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp13.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp13.h Thu Aug  2 10:42:23 2007
@@ -45,7 +45,8 @@
 #define JK_CLIENT_RD_ERROR          (-6)
 #define JK_CLIENT_WR_ERROR          (-7)
 #define JK_STATUS_ERROR             (-8)
-#define JK_REPLY_TIMEOUT            (-9)
+#define JK_STATUS_FATAL_ERROR       (-9)
+#define JK_REPLY_TIMEOUT            (-10)
 
 #define AJP13_MAX_SEND_BODY_SZ      (DEF_BUFFER_SZ - 6)
 #define AJP13_DEF_TIMEOUT           (0) /* Idle timout for pooled connections */

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?view=diff&rev=562194&r1=562193&r2=562194
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Thu Aug  2 10:42:23 2007
@@ -1427,9 +1427,12 @@
 static int is_http_status_fail(ajp_worker_t *w, int status)
 {
     unsigned int i;
+    int soft_status = -1 * status;
     for (i = 0; i < w->http_status_fail_num; i++) {
         if (w->http_status_fail[i] == status)
             return 1;
+        else if (w->http_status_fail[i] == soft_status)
+            return -1;
     }
     return 0;
 }
@@ -1450,6 +1453,7 @@
     switch (code) {
     case JK_AJP13_SEND_HEADERS:
         {
+            int rc;
             jk_res_data_t res;
             if (!ajp_unmarshal_response(msg, &res, ae, l)) {
                 jk_log(l, JK_LOG_ERROR,
@@ -1458,7 +1462,12 @@
                 return JK_AJP13_ERROR;
             }
             r->http_response_status = res.status;
-            if (is_http_status_fail(ae->worker, res.status)) {
+            rc  = is_http_status_fail(ae->worker, res.status);
+            if (rc > 0) {
+                JK_TRACE_EXIT(l);
+                return JK_STATUS_FATAL_ERROR;
+            }
+            else if (rc < 0) {
                 JK_TRACE_EXIT(l);
                 return JK_STATUS_ERROR;
             }
@@ -1740,9 +1749,9 @@
         else if (JK_AJP13_SEND_HEADERS == rc) {
             headeratclient = JK_TRUE;
         }
-        else if (JK_STATUS_ERROR == rc) {
+        else if (JK_STATUS_ERROR == rc || JK_STATUS_FATAL_ERROR == rc) {
             JK_TRACE_EXIT(l);
-            return JK_STATUS_ERROR;
+            return rc;
         }
         else if (JK_AJP13_HAS_RESPONSE == rc) {
             /*
@@ -2002,14 +2011,14 @@
                 JK_TRACE_EXIT(l);
                 return JK_SERVER_ERROR;
             }
-            else if (err == JK_STATUS_ERROR) {
+            else if (err == JK_STATUS_ERROR || err == JK_STATUS_FATAL_ERROR) {
                 jk_log(l, JK_LOG_INFO,
-                       "(%s) request failed, "
+                       "(%s) request failed%s, "
                        "because of response status %d, "
                        "recoverable operation attempt=%d",
                        p->worker->name,
+                       err == JK_STATUS_FATAL_ERROR ? "" : " (soft)",
                        s->http_response_status, i);
-                JK_TRACE_EXIT(l);
                 if (i >= JK_RETRIES) {
                     jk_sleep(JK_SLEEP_DEF);
                 }
@@ -2089,6 +2098,11 @@
            "(%s) Connecting to tomcat failed. Tomcat is probably not started "
            "or is listening on the wrong port",
            p->worker->name);
+
+    if (err == JK_STATUS_ERROR) {
+        JK_TRACE_EXIT(l);
+        return JK_STATUS_ERROR;
+    }
 
     if (err == JK_REPLY_TIMEOUT) {
         *is_error = JK_HTTP_GATEWAY_TIME_OUT;

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=562194&r1=562193&r2=562194
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Thu Aug  2 10:42:23 2007
@@ -1113,8 +1113,9 @@
                     if (service_stat == JK_REPLY_TIMEOUT) {
                         rec->s->reply_timeouts++;
                     }
-                    if (service_stat != JK_REPLY_TIMEOUT ||
-                        rec->s->reply_timeouts > (unsigned)p->worker->s->max_reply_timeouts)
{
+                    if (service_stat != JK_STATUS_ERROR &&
+                        (service_stat != JK_REPLY_TIMEOUT ||
+                        rec->s->reply_timeouts > (unsigned)p->worker->s->max_reply_timeouts))
{
 
                         /*
                         * Service failed !!!

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?view=diff&rev=562194&r1=562193&r2=562194
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Thu Aug  2 10:42:23 2007
@@ -28,6 +28,10 @@
   <subsection name="Native">
     <changelog>
       <update>
+        General: fail_on_status used in a load balancer can optionally
+        do fail over without putting the failed worker in error state. (rjung)
+      </update>
+      <update>
         NSAPI: Add initialization startup message containing JK version. (rjung)
       </update>
       <fix>

Modified: tomcat/connectors/trunk/jk/xdocs/reference/workers.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/reference/workers.xml?view=diff&rev=562194&r1=562193&r2=562194
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/reference/workers.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/reference/workers.xml Thu Aug  2 10:42:23 2007
@@ -704,6 +704,14 @@
 status codes separated by space or comma characters.
 For example: <code>worker.xxx.fail_on_status=500,503</code>
 </p>
+<p>
+Starting with <b>jk 1.2.25</b> you can also tell the load
+balancer to not put a member into an error state, if a
+response returned with one of the status codes in
+fail_on_status. This feature gets enabled, by putting a minus sign in
+front of those status codes.
+For example: <code>worker.xxx.fail_on_status=-404,-500,503</code>
+</p>
 </directive>
 
 <directive name="max_packet_size" workers="AJP,SUB" default="8192" required="false">



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


Mime
View raw message