ASF Bugzilla – Attachment 29551 Details for
Bug 54102
new feature: automatic route detection
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
autoroute patch
trunk_autoroute.patch (text/plain), 9.12 KB, created by
inu
on 2012-11-05 19:45:31 UTC
(
hide
)
Description:
autoroute patch
Filename:
MIME Type:
Creator:
inu
Created:
2012-11-05 19:45:31 UTC
Size:
9.12 KB
patch
obsolete
>Index: docs/manual/mod/mod_proxy.xml >=================================================================== >--- docs/manual/mod/mod_proxy.xml (revision 1405924) >+++ docs/manual/mod/mod_proxy.xml (working copy) >@@ -1143,6 +1143,11 @@ > without considering the retry parameter of each worker. In this case > set to <code>Off</code>. > </td></tr> >+ <tr><td>autoroute</td> >+ <td></td> >+ <td>Same application server send there route id within the response header. >+ The actual worker route id changed to the value of the here defined response field. >+ </td></tr> > > </table> > <p>A sample balancer setup</p> >Index: modules/proxy/mod_proxy_balancer.c >=================================================================== >--- modules/proxy/mod_proxy_balancer.c (revision 1405924) >+++ modules/proxy/mod_proxy_balancer.c (working copy) >@@ -614,6 +614,11 @@ > "%s: worker (%s) rewritten to %s", > (*balancer)->s->name, (*worker)->s->name, *url); > >+ /* store autoroute fieldname in notes for the output filter */ >+ if ((*balancer)->s->autoroute[0] != '\0') { >+ apr_table_set(r->notes, "proxy-balancer-ar-field", (*balancer)->s->autoroute); >+ } >+ > return access_status; > } > >@@ -632,6 +637,25 @@ > return HTTP_INTERNAL_SERVER_ERROR; > } > >+ /* set new route id */ >+ const char *new_route = apr_table_get(r->notes, "proxy-balancer-ar-newroute"); >+ if (new_route != NULL) { >+ /* update route id */ >+ if (strcmp(worker->s->route, new_route) != 0) { >+ if (strlen(new_route) >= PROXY_WORKER_MAX_ROUTE_SIZE) { >+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(99999) >+ "%s %s: route length must be < 64 characters", >+ balancer->s->name, worker->s->name); >+ } >+ else { >+ PROXY_STRNCPY(worker->s->route, new_route); >+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(99999) >+ "%s: new route id (%s) for worker (%s)", >+ balancer->s->name, worker->s->name, new_route); >+ } >+ } >+ } >+ > if (!apr_is_empty_array(balancer->errstatuses)) { > int i; > for (i = 0; i < balancer->errstatuses->nelts; i++) { >@@ -1136,6 +1160,14 @@ > } > } > } >+ if ((val = apr_table_get(params, "b_autoroute")) && *val) { >+ if (strlen(val) < (sizeof(bsel->s->autoroute)-1)) { >+ if (*val == '-' && *(val+1) == '\0') >+ *bsel->s->autoroute = '\0'; >+ else >+ PROXY_STRNCPY(bsel->s->autoroute, val); >+ } >+ } > if ((val = apr_table_get(params, "b_wyes")) && > (*val == '1' && *(val+1) == '\0') && > (val = apr_table_get(params, "b_nwrkr"))) { >@@ -1233,6 +1265,11 @@ > ap_rprintf(r, > " <httpd:timeout>%" APR_TIME_T_FMT "</httpd:timeout>", > apr_time_sec(balancer->s->timeout)); >+ if (balancer->s->autoroute) { >+ ap_rprintf(r, >+ " <httpd:autoroute>%s</httpd:autoroute>", >+ balancer->s->autoroute); >+ } > if (balancer->s->max_attempts_set) { > ap_rprintf(r, > " <httpd:maxattempts>%d</httpd:maxattempts>\n", >@@ -1443,7 +1480,7 @@ > "'>", NULL); > ap_rvputs(r, balancer->s->name, "</a> [",balancer->s->sname, "]</h3>\n", NULL); > ap_rputs("\n\n<table><tr>" >- "<th>MaxMembers</th><th>StickySession</th><th>DisableFailover</th><th>Timeout</th><th>FailoverAttempts</th><th>Method</th>" >+ "<th>MaxMembers</th><th>StickySession</th><th>DisableFailover</th><th>Timeout</th><th>AutoRoute</th><th>FailoverAttempts</th><th>Method</th>" > "<th>Path</th><th>Active</th></tr>\n<tr>", r); > /* the below is a safe cast, since the number of slots total will > * never be more than max_workers, which is restricted to int */ >@@ -1465,6 +1502,8 @@ > balancer->s->sticky_force ? "On" : "Off"); > ap_rprintf(r, "</td><td>%" APR_TIME_T_FMT "</td>", > apr_time_sec(balancer->s->timeout)); >+ ap_rprintf(r, "<td>%s</td>\n", >+ *balancer->s->autoroute == '\0' ? "(None)" : balancer->s->autoroute); > ap_rprintf(r, "<td>%d</td>\n", balancer->s->max_attempts); > ap_rprintf(r, "<td>%s</td>\n", > balancer->s->lbpname); >@@ -1586,6 +1625,9 @@ > ap_rvputs(r, "value ='", bsel->s->sticky, NULL); > } > ap_rputs("'> (Use '-' to delete)</td></tr>\n", r); >+ ap_rputs("<tr><td>AutoRoute</td>", r); >+ ap_rprintf(r, "<td><input name='b_autoroute' id='b_autoroute' size=64 type=text value='%s'> (Use '-' to delete)</td></tr>", >+ bsel->s->autoroute); > if (storage->num_free_slots(bsel->wslot) != 0) { > ap_rputs("<tr><td>Add New Worker:</td><td><input name='b_nwrkr' id='b_nwrkr' size=32 type=text>" > " Are you sure? <input name='b_wyes' id='b_wyes' type=checkbox value='1'>" >@@ -1643,6 +1685,30 @@ > > } > >+static apr_status_t proxy_balancer_fixup_headers_out(ap_filter_t *f, >+ apr_bucket_brigade *in) >+{ >+ /* copy new route id to notes, and remove it from response */ >+ const char *field; >+ if ((field = apr_table_get(f->r->notes, "proxy-balancer-ar-field")) != NULL) { >+ const char *value; >+ if ((value = apr_table_get(f->r->headers_out, field)) != NULL) { >+ apr_table_set( f->r->notes, "proxy-balancer-ar-newroute", value); >+ apr_table_unset( f->r->headers_out, field); >+ } >+ } >+ >+ /* remove ourselves from the filter chain */ >+ /* send the data up the stack */ >+ ap_remove_output_filter(f); >+ return ap_pass_brigade(f->next,in); >+} >+ >+static void proxy_balancer_insert_output_filter(request_rec *r) >+{ >+ ap_add_output_filter("FIXUP_PROXY_BALANCER_OUT", NULL, r, r->connection); >+} >+ > static void ap_proxy_balancer_register_hook(apr_pool_t *p) > { > /* Only the mpm_winnt has child init hook handler. >@@ -1655,9 +1721,12 @@ > ap_hook_pre_config(balancer_pre_config, NULL, NULL, APR_HOOK_MIDDLE); > ap_hook_handler(balancer_handler, NULL, NULL, APR_HOOK_FIRST); > ap_hook_child_init(balancer_child_init, aszPred, NULL, APR_HOOK_MIDDLE); >+ ap_hook_insert_filter(proxy_balancer_insert_output_filter, NULL, NULL, APR_HOOK_FIRST); > proxy_hook_pre_request(proxy_balancer_pre_request, NULL, NULL, APR_HOOK_FIRST); > proxy_hook_post_request(proxy_balancer_post_request, NULL, NULL, APR_HOOK_FIRST); > proxy_hook_canon_handler(proxy_balancer_canon, NULL, NULL, APR_HOOK_FIRST); >+ ap_register_output_filter("FIXUP_PROXY_BALANCER_OUT", proxy_balancer_fixup_headers_out, >+ NULL, AP_FTYPE_CONTENT_SET); > } > > AP_DECLARE_MODULE(proxy_balancer) = { >Index: modules/proxy/proxy_util.c >=================================================================== >--- modules/proxy/proxy_util.c (revision 1405924) >+++ modules/proxy/proxy_util.c (working copy) >@@ -1185,6 +1185,8 @@ > bshared->sticky_separator = '.'; > *bshared->nonce = PROXY_UNSET_NONCE; /* impossible valid input */ > >+ bshared->autoroute[0] = '\0'; >+ > (*balancer)->s = bshared; > (*balancer)->sconf = conf; > >Index: modules/proxy/mod_proxy.c >=================================================================== >--- modules/proxy/mod_proxy.c (revision 1405924) >+++ modules/proxy/mod_proxy.c (working copy) >@@ -407,6 +407,11 @@ > else > return "forcerecovery must be On|Off"; > } >+ else if (!strcasecmp(key, "autoroute")) { >+ if (strlen(val) > (PROXY_BALANCER_AUTOROUTE_FIELD_SIZE-1)) >+ return "autoroute length must be < 64 characters"; >+ PROXY_STRNCPY(balancer->s->autoroute, val); >+ } > else { > return "unknown Balancer parameter"; > } >Index: modules/proxy/mod_proxy.h >=================================================================== >--- modules/proxy/mod_proxy.h (revision 1405924) >+++ modules/proxy/mod_proxy.h (working copy) >@@ -310,6 +310,8 @@ > #define PROXY_BALANCER_MAX_HOSTNAME_SIZE PROXY_WORKER_MAX_HOSTNAME_SIZE > #define PROXY_BALANCER_MAX_STICKY_SIZE 64 > >+#define PROXY_BALANCER_AUTOROUTE_FIELD_SIZE 64 >+ > #define PROXY_MAX_PROVIDER_NAME_SIZE 16 > > #define PROXY_STRNCPY(dst, src) ap_proxy_strncpy((dst), (src), (sizeof(dst))) >@@ -414,6 +416,7 @@ > char sname[PROXY_BALANCER_MAX_NAME_SIZE]; > char vpath[PROXY_BALANCER_MAX_ROUTE_SIZE]; > char vhost[PROXY_BALANCER_MAX_HOSTNAME_SIZE]; >+ char autoroute[PROXY_BALANCER_AUTOROUTE_FIELD_SIZE]; > apr_interval_time_t timeout; /* Timeout for waiting on free connection */ > apr_time_t wupdated; /* timestamp of last change to workers list */ > int max_attempts; /* Number of attempts before failing */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 54102
:
29551
|
29719