]> granicus.if.org Git - apache/commitdiff
Add in BalancerGrowth and its functionality... this lays
authorJim Jagielski <jim@apache.org>
Fri, 20 May 2011 16:29:48 +0000 (16:29 +0000)
committerJim Jagielski <jim@apache.org>
Fri, 20 May 2011 16:29:48 +0000 (16:29 +0000)
the framework for adding additional Balancers: post-config
by allowing for shm growth.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1125451 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/mod/mod_proxy.xml
include/ap_mmn.h
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c

index 815a246957d2b7dc5a6e2332d0f3fc5e8f8b1911..289355110a9d340a607a4c410c8a664580eb75fa 100644 (file)
@@ -637,30 +637,46 @@ expressions</description>
 </directivesynopsis>
 
 <directivesynopsis>
-<name>BalancerMember</name>
-<description>Add a member to a load balancing group</description>
-<syntax>BalancerMember [<var>balancerurl</var>] <var>url</var> [<var
-  >key=value [key=value ...]]</var></syntax>
-<contextlist><context>directory</context>
-</contextlist>
-<compatibility>BalancerMember is only available in Apache HTTP Server 2.2
+<name>BalancerGrowth</name>
+<description>Number of additional Balancers that can be added Post-configuration</description>
+    <syntax>BalancerGrowth <var>#</var></syntax>
+    <default>BalancerGrowth 5</default>
+    <contextlist><context>server config</context><context>virtual host</context></contextlist>
+<compatibility>BalancerGrowth is only available in Apache HTTP Server 2.3.13
   and later.</compatibility>
 <usage>
-    <p>This directive adds a member to a load balancing group. It could be used
-    within a <code>&lt;Proxy <var>balancer://</var>...&gt;</code> container
-    directive, and can take any of the key value pair parameters available to
-    <directive module="mod_proxy">ProxyPass</directive> directives.</p>
-    <p>One additional parameter is available only to <directive
-    module="mod_proxy">BalancerMember</directive> directives:
-    <var>loadfactor</var>. This is the member load factor - a number between 1 
-    (default) and 100, which defines the weighted load to be applied to the 
-    member in question.</p>
-    <p>The balancerurl is only needed when not in <code>&lt;Proxy <var>balancer://</var>...&gt;</code>
-    container directive. It corresponds to the url of a balancer defined in
-    <directive module="mod_proxy">ProxyPass</directive> directive.</p>
+    <p>This directive allows for growth potential in the number of
+    Balancers available for a virtualhost in addition to the
+    number pre-configured. It only take effect if there is at
+    least 1 pre-configured Balancer.</p>
 </usage>
 </directivesynopsis>
 
+<directivesynopsis>
+    <name>BalancerMember</name>
+    <description>Add a member to a load balancing group</description>
+    <syntax>BalancerMember [<var>balancerurl</var>] <var>url</var> [<var
+        >key=value [key=value ...]]</var></syntax>
+    <contextlist><context>directory</context>
+    </contextlist>
+    <compatibility>BalancerMember is only available in Apache HTTP Server 2.2
+        and later.</compatibility>
+    <usage>
+        <p>This directive adds a member to a load balancing group. It could be used
+            within a <code>&lt;Proxy <var>balancer://</var>...&gt;</code> container
+            directive, and can take any of the key value pair parameters available to
+            <directive module="mod_proxy">ProxyPass</directive> directives.</p>
+        <p>One additional parameter is available only to <directive
+            module="mod_proxy">BalancerMember</directive> directives:
+            <var>loadfactor</var>. This is the member load factor - a number between 1 
+            (default) and 100, which defines the weighted load to be applied to the 
+            member in question.</p>
+        <p>The balancerurl is only needed when not in <code>&lt;Proxy <var>balancer://</var>...&gt;</code>
+            container directive. It corresponds to the url of a balancer defined in
+            <directive module="mod_proxy">ProxyPass</directive> directive.</p>
+    </usage>
+</directivesynopsis>
+    
 <directivesynopsis>
 <name>ProxySet</name>
 <description>Set various Proxy balancer or member parameters</description>
index 83794beec2b6764a794809d8d573642748135590..394d65abf2020161f1734d0d3aea844149014ad1 100644 (file)
  *                         change AP_DECLARE to AP_CORE_DECLARE: ap_register_log_hooks()
  * 20110329.2 (2.3.12-dev) Add child_status and end_generation hooks.
  * 20110329.3 (2.3.12-dev) Add format field to ap_errorlog_info.
+ * 20110329.4 (2.3.13-dev) bgrowth and max_balancers to proxy_server_conf.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20110329
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 3                    /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 4                    /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index ce5a83a8151ca078d78198b6fbc7ebdd99924368..f387e467c4d7a52b7960f983074d577c559e481d 100644 (file)
@@ -1127,6 +1127,9 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s)
     ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */
     ps->viaopt_set = 0; /* 0 means default */
     ps->req = 0;
+    ps->max_balancers = 0;
+    ps->bgrowth = 5;
+    ps->bgrowth_set = 0;
     ps->req_set = 0;
     ps->recv_buffer_size = 0; /* this default was left unset for some reason */
     ps->recv_buffer_size_set = 0;
@@ -1167,6 +1170,9 @@ static void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
     ps->viaopt_set = overrides->viaopt_set || base->viaopt_set;
     ps->req = (overrides->req_set == 0) ? base->req : overrides->req;
     ps->req_set = overrides->req_set || base->req_set;
+    ps->bgrowth = (overrides->bgrowth_set == 0) ? base->bgrowth : overrides->bgrowth;
+    ps->bgrowth_set = overrides->bgrowth_set || base->bgrowth_set;
+    ps->max_balancers = overrides->max_balancers || base->max_balancers;
     ps->recv_buffer_size = (overrides->recv_buffer_size_set == 0) ? base->recv_buffer_size : overrides->recv_buffer_size;
     ps->recv_buffer_size_set = overrides->recv_buffer_size_set || base->recv_buffer_size_set;
     ps->io_buffer_size = (overrides->io_buffer_size_set == 0) ? base->io_buffer_size : overrides->io_buffer_size;
@@ -1824,6 +1830,21 @@ static const char*
     return NULL;
 }
 
+static const char *set_bgrowth(cmd_parms *parms, void *dummy, const char *arg)
+{
+    proxy_server_conf *psf =
+    ap_get_module_config(parms->server->module_config, &proxy_module);
+
+    int growth = atoi(arg);
+    if (growth < 0 || growth > 1000) {
+        return "BalancerGrowth must be between 0 and 1000";
+    }
+    psf->bgrowth = growth;
+    psf->bgrowth_set = 1;
+
+    return NULL;
+}
+
 static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
 {
     server_rec *s = cmd->server;
@@ -2203,6 +2224,8 @@ static const command_rec proxy_cmds[] =
      "How to handle bad header line in response: IsError | Ignore | StartBody"),
     AP_INIT_RAW_ARGS("BalancerMember", add_member, NULL, RSRC_CONF|ACCESS_CONF,
      "A balancer name and scheme with list of params"),
+    AP_INIT_TAKE1("BalancerGrowth", set_bgrowth, NULL, RSRC_CONF,
+     "Number of additional Balancers that can be added post-config"),
     AP_INIT_TAKE1("ProxyStatus", set_status_opt, NULL, RSRC_CONF,
      "Configure Status: proxy status to one of: on | off | full"),
     AP_INIT_RAW_ARGS("ProxySet", set_proxy_param, NULL, RSRC_CONF|ACCESS_CONF,
index 046f99f9ad31090655065495f1be1e58efe185a0..57e0c02009cd90365ddec631e273dc1231ede08c 100644 (file)
@@ -138,6 +138,8 @@ typedef struct {
     const char *id;
     apr_pool_t *pool;       /* Pool used for allocating this struct */
     int req;                /* true if proxy requests are enabled */
+    int max_balancers;      /* maximum number of allowed balancers */
+    int bgrowth;            /* number of post-config balancers can added */
     enum {
       via_off,
       via_on,
@@ -172,6 +174,7 @@ typedef struct {
     unsigned int badopt_set:1;
     unsigned int proxy_status_set:1;
     unsigned int source_address_set:1;
+    unsigned int bgrowth_set:1;
 } proxy_server_conf;
 
 
index 63efb618af2e919862d9d6c3c300a93d1da8f472..8123cfaafb486a9dbe67591b408093304a7fa36b 100644 (file)
@@ -723,13 +723,14 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
         conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
 
         if (conf->balancers->nelts) {
-            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "Doing balancers create: %d, %d",
+            conf->max_balancers = conf->balancers->nelts + conf->bgrowth;
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "Doing balancers create: %d, %d (%d)",
                          (int)ALIGNED_PROXY_BALANCER_SHARED_SIZE,
-                         (int)conf->balancers->nelts);
+                         (int)conf->balancers->nelts, conf->max_balancers);
 
             rv = storage->create(&new, conf->id,
                                  ALIGNED_PROXY_BALANCER_SHARED_SIZE,
-                                 conf->balancers->nelts, AP_SLOTMEM_TYPE_PREGRAB, pconf);
+                                 conf->max_balancers, AP_SLOTMEM_TYPE_PREGRAB, pconf);
             if (rv != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "balancer slotmem_create failed");
                 return !OK;