Commit 14cda2ec authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Add in BalancerGrowth and its functionality... this lays

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
parent 00c760e6
Loading
Loading
Loading
Loading
+16 −0
Changes for docs/manual/mod/mod_proxy.xml: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -636,6 +636,22 @@ expressions</description>
</usage>
</directivesynopsis>

<directivesynopsis>
<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 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>
+2 −1
Changes for include/ap_mmn.h: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -321,6 +321,7 @@
 *                         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" */
@@ -328,7 +329,7 @@
#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
+23 −0
Changes for modules/proxy/mod_proxy.c: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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,
+3 −0
Changes for modules/proxy/mod_proxy.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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;


+4 −3
Changes for modules/proxy/mod_proxy_balancer.c: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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;