Hi Mladen,

the different notations confuse me: some parts use "retry_on_status", and some "http_status_fail". I think the implementation does "fail on configured status code", whereas the name of the config param suggests "retry=do not fail on configured status code".

I would suggest, to rename the config param (and the config function) from "retry_on_status" to "fail_on_status".

Regards,

Rainer

[EMAIL PROTECTED] wrote:
Author: mturk
Date: Wed Dec  6 02:54:08 2006
New Revision: 483021

URL: http://svn.apache.org/viewvc?view=rev&rev=483021
Log:
Added retry_on_status directive that can treat HTTP return codes as failures, 
allowing loadbalancing in case of 503, etc.

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_ajp_common.h
    tomcat/connectors/trunk/jk/native/common/jk_service.h
    tomcat/connectors/trunk/jk/native/common/jk_util.c
    tomcat/connectors/trunk/jk/native/common/jk_util.h
    tomcat/connectors/trunk/jk/xdocs/config/workers.xml
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.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=483021&r1=483020&r2=483021
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp13.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp13.h Wed Dec  6 02:54:08 2006
@@ -44,6 +44,7 @@
 #define JK_SERVER_ERROR             (-5)
 #define JK_CLIENT_RD_ERROR          (-6)
 #define JK_CLIENT_WR_ERROR          (-7)
+#define JK_STATUS_ERROR             (-8)
#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=483021&r1=483020&r2=483021
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Wed Dec  6 
02:54:08 2006
@@ -1398,6 +1398,7 @@
                               res.num_headers);
             if (r->flush && r->flush_header)
                 r->flush(r);
+            r->http_status = res.status;
         }
         return JK_AJP13_SEND_HEADERS;
@@ -1625,6 +1626,11 @@
             return JK_TRUE;
         }
         else if (JK_AJP13_SEND_HEADERS == rc) {
+            if (p->worker->http_status_fail &&
+                (p->worker->http_status_fail == s->http_status)) {
+                JK_TRACE_EXIT(l);
+                return JK_STATUS_ERROR;
+            }
             headeratclient = JK_TRUE;
         }
         else if (JK_AJP13_HAS_RESPONSE == rc) {
@@ -1841,6 +1847,18 @@
                 JK_TRACE_EXIT(l);
                 return JK_SERVER_ERROR;
             }
+            else if (err == JK_STATUS_ERROR) {
+                jk_log(l, JK_LOG_INFO,
+                       "(%s) request failed, "
+                       "because of response status %d, "
+                       "recoverable operation attempt=%d",
+                       p->worker->http_status_fail,
+                       p->worker->name, i);
+                JK_TRACE_EXIT(l);
+                if (i >= JK_RETRIES) {
+                    jk_sleep(JK_SLEEP_DEF);
+                }
+            }
             else {
                 /* if we can't get reply, check if no recover flag was set
                  * if is_recoverable_error is cleared, we have started
@@ -2062,6 +2080,8 @@
                                         AJP_DEF_RECOVERY_OPTS);
         p->max_packet_size =
             jk_get_max_packet_size(props, p->name);
+
+        p->http_status_fail = jk_get_worker_retry_on_status(props, p->name);
pThis->retries =
             jk_get_worker_retries(props, p->name,

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h?view=diff&rev=483021&r1=483020&r2=483021
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h Wed Dec  6 
02:54:08 2006
@@ -287,6 +287,11 @@
     unsigned int recovery_opts; /* Set the recovery option */
unsigned int max_packet_size; /* Maximum AJP Packet size */ + + /* + * HTTP status that will cause failover (0 means disabled)
+     */
+     int http_status_fail;
 };
Modified: tomcat/connectors/trunk/jk/native/common/jk_service.h
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_service.h?view=diff&rev=483021&r1=483020&r2=483021
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_service.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_service.h Wed Dec  6 02:54:08 
2006
@@ -222,6 +222,11 @@
      */
     int flush_header;
+ /*
+     * HTTP status sent from container.
+     */
+    int http_status;
+
     /* Uri worker map. Added for virtual host support
      */
     jk_uri_worker_map_t *uw_map;

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?view=diff&rev=483021&r1=483020&r2=483021
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Wed Dec  6 02:54:08 2006
@@ -91,6 +91,7 @@
 #define DEFAULT_WORKER_TYPE         JK_AJP13_WORKER_NAME
 #define SECRET_KEY_OF_WORKER        ("secretkey")
 #define RETRIES_OF_WORKER           ("retries")
+#define STATUS_FAIL_OF_WORKER       ("retry_on_status")
#define DEFAULT_WORKER JK_AJP13_WORKER_NAME
 #define WORKER_LIST_PROPERTY_NAME     ("worker.list")
@@ -180,6 +181,7 @@
     XML_NAMESPACE_OF_WORKER,
     XML_DOCTYPE_OF_WORKER,
     PROP_PREFIX_OF_WORKER,
+    STATUS_FAIL_OF_WORKER,
     NULL
 };
@@ -1001,6 +1003,20 @@ return sz;
 }
+
+int jk_get_worker_retry_on_status(jk_map_t *m, const char *wname)
+{
+    char buf[1024];
+
+    if (!m || !wname) {
+        return 0;
+    }
+
+    MAKE_WORKER_PARAM(STATUS_FAIL_OF_WORKER);
+    return jk_map_get_int(m, buf, 0);
+
+}
+
const char *jk_get_worker_style_sheet(jk_map_t *m, const char *wname, const char *def)
 {

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.h
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.h?view=diff&rev=483021&r1=483020&r2=483021
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.h Wed Dec  6 02:54:08 2006
@@ -193,6 +193,8 @@
const char *jk_get_worker_prop_prefix(jk_map_t *m, const char *wname, const char *def); +int jk_get_worker_retry_on_status(jk_map_t *m, const char *wname);
+
 #define TC32_BRIDGE_TYPE    32
 #define TC33_BRIDGE_TYPE    33
 #define TC40_BRIDGE_TYPE    40

Modified: tomcat/connectors/trunk/jk/xdocs/config/workers.xml
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/config/workers.xml?view=diff&rev=483021&r1=483020&r2=483021
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/config/workers.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/config/workers.xml Wed Dec  6 02:54:08 2006
@@ -711,6 +711,17 @@
 </p>
 </directive>
+<directive name="retry_on_status" default="0" required="false">
+Set this value to the HTTP status code that will cause a worker to fail
+if returned from Servlet contatiner. Use this directive to deal with
+cases when the servlet container can temporary return non-200 responses
+for a short amount of time, e.g during redeployment.
+<p>
+This feature has been added in <b>jk 1.2.20</b>.
+</p>
+</directive>
+
+
 </directives>
 </subsection>
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=483021&r1=483020&r2=483021
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Wed Dec  6 
02:54:08 2006
@@ -27,6 +27,9 @@
   <subsection name="Native">
     <changelog>
       <update>
+      Added retry_on_status for workers directive. (mturk)
+      </update>
+      <update>
       Status Worker: Add directive to make property prefix
       and good/bad rule configurable. (rjung)
       </update>



---------------------------------------------------------------------
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]

Reply via email to