You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jf...@apache.org on 2006/08/01 17:44:34 UTC
svn commit: r427623 - in /httpd/httpd/branches/httpd-proxy-scoreboard:
modules/proxy/ support/
Author: jfclere
Date: Tue Aug 1 08:44:33 2006
New Revision: 427623
URL: http://svn.apache.org/viewvc?rev=427623&view=rev
Log:
Arrange the health_checker: add set_slotmem_storage_method(),
create_slotmem() and attach_slotmem(). Arrange corresponding
files.
Start using the health logic in the balancer.
Arrange ap_proxy_add_worker_to_balancer().
Modified:
httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c
httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_balancer.c
httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.c
httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.h
httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c
httpd/httpd/branches/httpd-proxy-scoreboard/support/proxymonitor.c
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c?rev=427623&r1=427622&r2=427623&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c Tue Aug 1 08:44:33 2006
@@ -124,6 +124,36 @@
return APR_SUCCESS;
}
+/* set the storage to use */
+static void set_slotmem_storage_method(const slotmem_storage_method *storage)
+{
+ checkstorage = storage;
+}
+
+static apr_status_t create_slotmem(char *name, int item_num, apr_pool_t *pool)
+{
+ apr_status_t rv;
+ if (checkstorage == NULL)
+ return APR_EGENERAL;
+
+ rv = checkstorage->ap_slotmem_create(&myscore, name, sizeof(struct proxy_worker_conf), item_num, pool);
+ return rv;
+}
+
+static apr_status_t attach_slotmem(char *name, int *item_num, apr_pool_t *pool)
+{
+ apr_status_t rv;
+ apr_size_t item_size;
+ if (checkstorage == NULL)
+ return APR_EGENERAL;
+
+ rv = checkstorage->ap_slotmem_attach(&myscore, name, &item_size, item_num, pool);
+ if (rv != APR_SUCCESS)
+ return rv;
+ if (item_size != sizeof(struct proxy_worker_conf))
+ return APR_ENOSHMAVAIL;
+ return APR_SUCCESS;
+}
/* read the size of the entry: to create the shared area */
static int getentrysize()
{
@@ -328,7 +358,9 @@
/* The stuff we provide */
static const health_worker_method worker_storage = {
- &getentrysize,
+ &set_slotmem_storage_method,
+ &create_slotmem,
+ &attach_slotmem,
&add_entry,
&del_entry,
&get_health,
@@ -342,24 +374,4 @@
const health_worker_method *health_checker_get_storage()
{
return(&worker_storage);
-}
-
-/* handle the slotmem storage */
-void health_checker_init_slotmem_storage(const slotmem_storage_method * storage)
-{
- checkstorage = storage;
-}
-const slotmem_storage_method * health_checker_get_slotmem_storage()
-{
- return(checkstorage);
-}
-
-/* handle the slotmen itself */
-void health_checker_init_slotmem(ap_slotmem_t *score)
-{
- myscore = score;
-}
-ap_slotmem_t *health_checker_get_slotmem()
-{
- return(myscore);
}
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_balancer.c?rev=427623&r1=427622&r2=427623&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_balancer.c Tue Aug 1 08:44:33 2006
@@ -23,6 +23,8 @@
#include "apr_version.h"
#include "apr_hooks.h"
+#include "mod_proxy_health_checker.h"
+
#if APR_HAVE_UNISTD_H
#include <unistd.h> /* for getpid() */
#endif
@@ -181,11 +183,19 @@
int i;
int checking_standby = 0;
int checked_standby = 0;
-
proxy_worker *worker;
+ const health_worker_method *worker_storage;
+ worker_storage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
+
while (!checked_standby) {
worker = (proxy_worker *)balancer->workers->elts;
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+ if (worker_storage) {
+ int health;
+ worker_storage->get_health(worker->id, &health);
+ if (health != HEALTH_OK)
+ continue;
+ }
if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
continue;
if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
@@ -215,6 +225,12 @@
proxy_worker *rworker = NULL;
rworker = find_route_worker(balancer, worker->s->redirect, r);
/* Check if the redirect worker is usable */
+ if (rworker && worker_storage) {
+ int health;
+ worker_storage->get_health(worker->id, &health);
+ if (health != HEALTH_OK)
+ continue;
+ }
if (rworker && !PROXY_WORKER_IS_USABLE(rworker)) {
/*
* If the worker is in error state run
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.c?rev=427623&r1=427622&r2=427623&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.c Tue Aug 1 08:44:33 2006
@@ -17,18 +17,20 @@
static int healthck_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp)
{
- slotmem_storage_method *checkstorage;
+ const slotmem_storage_method *checkstorage;
const health_worker_method *worker_storage;
ap_slotmem_t *myscore;
- checkstorage = ap_lookup_provider(SLOTMEM_STORAGE, "shared", "0");
- if (checkstorage) {
- health_checker_init_slotmem_storage(checkstorage);
- }
worker_storage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
- if (checkstorage && worker_storage) {
- checkstorage->ap_slotmem_create(&myscore, "proxy/checker", worker_storage->getentrysize(), 128, pconf);
- health_checker_init_slotmem(myscore);
+ if (worker_storage) {
+ checkstorage = ap_lookup_provider(SLOTMEM_STORAGE, "shared", "0");
+ if (checkstorage) {
+ worker_storage->set_slotmem_storage_method(checkstorage);
+ } else {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "proxy: The health checker needs a shared memory slotmem provider");
+ return APR_EGENERAL;
+ }
}
return OK;
}
@@ -40,6 +42,14 @@
worker_storage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
if (worker_storage) {
+ apr_status_t rv;
+ rv = worker_storage->create_slotmem("proxy/checker", ap_proxy_lb_workers(), pconf);
+ if (rv != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
+ "proxy: BALANCER: The health checker can't create slotmem");
+ return APR_EGENERAL;
+ }
+
while (s) {
void *sconf = s->module_config;
proxy_server_conf *conf;
@@ -56,7 +66,7 @@
for (j = 0; j< conf->balancers->nelts; j++) {
proxy_worker *myworker = (proxy_worker *)balancer->workers->elts;
for (k = 0; k < balancer->workers->nelts; k++) {
- if (myworker->id == worker->id) {
+ if (strcmp(myworker->name, worker->name) == 0) {
name = balancer->name;
break;
}
@@ -64,6 +74,7 @@
}
if (name)
break;
+ balancer++;
}
if (!name) {
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.h?rev=427623&r1=427622&r2=427623&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.h (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/mod_proxy_health_checker.h Tue Aug 1 08:44:33 2006
@@ -29,8 +29,12 @@
/* allow health check method on workers in a non httpd process */
struct health_worker_method {
- /* read the size of the entry: to create the shared area */
- int (* getentrysize)(void);
+ /* set the slotmem_storage_method to use */
+ void (*set_slotmem_storage_method)(const slotmem_storage_method *slotmem_storage);
+ /* create the slotmem to store the shared information */
+ apr_status_t (*create_slotmem)(char *name, int item_num, apr_pool_t *pool);
+ /* attach to existing shared slotmem */
+ apr_status_t (*attach_slotmem)(char *name, int *item_num, apr_pool_t *pool);
/* copy the worker information in the shared area so the health-checker can extract the part it need */
apr_status_t (*add_entry)(proxy_worker *worker, const char *balancer_name, int id);
/* XXX : Remove the entry */
@@ -101,6 +105,3 @@
* Other routines.
*/
const health_worker_method *health_checker_get_storage();
-void health_checker_init_slotmem_storage(const slotmem_storage_method * storage);
-void health_checker_init_slotmem(ap_slotmem_t *score);
-const slotmem_storage_method * health_checker_get_slotmem_storage();
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c?rev=427623&r1=427622&r2=427623&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/proxy_util.c Tue Aug 1 08:44:33 2006
@@ -1385,9 +1385,6 @@
runtime = apr_array_push(balancer->workers);
memcpy(runtime, worker, sizeof(proxy_worker));
- runtime->id = proxy_lb_workers;
- /* Increase the total runtime count */
- proxy_lb_workers++;
}
Modified: httpd/httpd/branches/httpd-proxy-scoreboard/support/proxymonitor.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/support/proxymonitor.c?rev=427623&r1=427622&r2=427623&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/support/proxymonitor.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/support/proxymonitor.c Tue Aug 1 08:44:33 2006
@@ -66,22 +66,21 @@
/* XXX: hack to use a part of the mod_sharedmem and mod_proxy_health_checker */
static apr_status_t init_healthck(apr_pool_t *pool, int *num)
{
- apr_size_t size;
apr_status_t rv;
const slotmem_storage_method *checkstorage;
- ap_slotmem_t *myscore;
-
+
+ /* Initialise the providers */
sharedmem_initglobalpool(pool);
+ worker_storage = health_checker_get_storage();
checkstorage = sharedmem_getstorage();
- rv = checkstorage->ap_slotmem_attach(&myscore, "proxy/checker", &size, num, pool);
+
+ worker_storage->set_slotmem_storage_method(checkstorage);
+ rv = worker_storage->attach_slotmem("proxy/checker", num, pool);
+
if (rv != APR_SUCCESS) {
apr_file_printf(errfile, "Can't attach to httpd memory error: %d\n", rv);
return rv;
}
-
- health_checker_init_slotmem_storage(checkstorage);
- health_checker_init_slotmem(myscore);
- worker_storage = health_checker_get_storage();
return rv;
}