Author: jfrederic.clere(a)jboss.com
Date: 2009-07-24 09:55:00 -0400 (Fri, 24 Jul 2009)
New Revision: 2507
Added:
trunk/mod_cluster/native/include/domain.h
trunk/mod_cluster/native/mod_manager/domain.c
Modified:
trunk/mod_cluster/native/mod_manager/Makefile.in
trunk/mod_cluster/native/mod_manager/mod_manager.c
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Add shared area with removed node for the domain handling (fix for MODCLUSTER-82).
Added: trunk/mod_cluster/native/include/domain.h
===================================================================
--- trunk/mod_cluster/native/include/domain.h (rev 0)
+++ trunk/mod_cluster/native/include/domain.h 2009-07-24 13:55:00 UTC (rev 2507)
@@ -0,0 +1,161 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2009 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+#ifndef DOMAIN_H
+#define DOMAIN_H
+
+/**
+ * @file domain.h
+ * @brief domain description Storage Module for Apache
+ *
+ * @defgroup MEM domain
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#define DOMAINEXE ".domain"
+
+#ifndef MEM_T
+typedef struct mem mem_t;
+#define MEM_T
+#endif
+
+#include "mod_clustersize.h"
+
+/* status of the domain as read/store in httpd. */
+struct domaininfo {
+ char domain[DOMAINNDSZ]; /* domain value */
+ char JVMRoute[JVMROUTESZ]; /* corresponding node */
+ char balancer[BALANCERSZ]; /* name of the balancer */
+
+ unsigned long updatetime; /* time of last received message */
+ int id; /* id in table */
+};
+typedef struct domaininfo domaininfo_t;
+
+
+/**
+ * Insert(alloc) and update a domain record in the shared table
+ * @param pointer to the shared table.
+ * @param domain domain to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+apr_status_t insert_update_domain(mem_t *s, domaininfo_t *domain);
+
+/**
+ * read a domain record from the shared table
+ * @param pointer to the shared table.
+ * @param domain domain to read from the shared table.
+ * @return address of the read domain or NULL if error.
+ */
+domaininfo_t * read_domain(mem_t *s, domaininfo_t *domain);
+
+/**
+ * get a domain record from the shared table
+ * @param pointer to the shared table.
+ * @param domain address of the domain read from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t get_domain(mem_t *s, domaininfo_t **domain, int ids);
+
+/**
+ * remove(free) a domain record from the shared table
+ * @param pointer to the shared table.
+ * @param domain domain to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t remove_domain(mem_t *s, domaininfo_t *domain);
+
+/*
+ * get the ids for the used (not free) domains in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of domain existing or -1 if error.
+ */
+int get_ids_used_domain(mem_t *s, int *ids);
+
+/*
+ * get the size of the table (max size).
+ * @param pointer to the shared table.
+ * @return size of the existing table or -1 if error.
+ */
+int get_max_size_domain(mem_t *s);
+
+/**
+ * attach to the shared domain table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+mem_t * get_mem_domain(char *string, int *num, apr_pool_t *p, slotmem_storage_method
*storage);
+/**
+ * create a shared domain table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param persist tell if the slotmem element are persistent.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+mem_t * create_mem_domain(char *string, int *num, int persist, apr_pool_t *p,
slotmem_storage_method *storage);
+
+/**
+ * provider for the mod_proxy_cluster or mod_jk modules.
+ */
+struct domain_storage_method {
+/**
+ * the domain corresponding to the ident
+ * @param ids ident of the domain to read.
+ * @param domain address of pointer to return the domain.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t (* read_domain)(int ids, domaininfo_t **domain);
+/**
+ * read the list of ident of used domains.
+ * @param ids address to store the idents.
+ * @return APR_SUCCESS if all went well
+ */
+int (* get_ids_used_domain)(int *ids);
+/**
+ * read the max number of domains in the shared table
+ */
+int (*get_max_size_domain)();
+/*
+ * Remove the domain from shared memory (free the slotmem)
+ */
+apr_status_t (*remove_domain)(domaininfo_t *domain);
+/*
+ * Insert a new domain or update existing one.
+ */
+apr_status_t (*insert_update_domain)(domaininfo_t *domain);
+/*
+ * Find the domain using the JVMRoute and balancer information
+ */
+apr_status_t (*find_domain)(domaininfo_t **node, const char *route, const char
*balancer);
+};
+#endif /*DOMAIN_H*/
Modified: trunk/mod_cluster/native/mod_manager/Makefile.in
===================================================================
--- trunk/mod_cluster/native/mod_manager/Makefile.in 2009-07-24 13:34:39 UTC (rev 2506)
+++ trunk/mod_cluster/native/mod_manager/Makefile.in 2009-07-24 13:55:00 UTC (rev 2507)
@@ -15,8 +15,8 @@
mod_manager.so: mod_manager.la
$(top_builddir)/build/instdso.sh SH_LIBTOOL='$(LIBTOOL)' mod_manager.la `pwd`
-mod_manager.la: mod_manager.slo node.slo context.slo host.slo balancer.slo sessionid.slo
- $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_manager.lo node.lo
context.lo host.lo balancer.lo sessionid.lo
+mod_manager.la: mod_manager.slo node.slo context.slo host.slo balancer.slo sessionid.slo
domain.slo
+ $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_manager.lo node.lo
context.lo host.lo balancer.lo sessionid.lo domain.lo
clean:
rm -f *.o *.lo *.slo *.so
Added: trunk/mod_cluster/native/mod_manager/domain.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/domain.c (rev 0)
+++ trunk/mod_cluster/native/mod_manager/domain.c 2009-07-24 13:55:00 UTC (rev 2507)
@@ -0,0 +1,246 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2009 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+/**
+ * @file domain.c
+ * @brief domain description Storage Module for Apache
+ *
+ * @defgroup MEM domains
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_time.h"
+
+#include "slotmem.h"
+#include "domain.h"
+
+struct mem {
+ ap_slotmem_t *slotmem;
+ const slotmem_storage_method *storage;
+ int num;
+ apr_pool_t *p;
+};
+
+static mem_t * create_attach_mem_domain(char *string, int *num, int type, apr_pool_t *p,
slotmem_storage_method *storage) {
+ mem_t *ptr;
+ const char *storename;
+ apr_status_t rv;
+
+ ptr = apr_pcalloc(p, sizeof(mem_t));
+ if (!ptr) {
+ return NULL;
+ }
+ ptr->storage = storage;
+ storename = apr_pstrcat(p, string, DOMAINEXE, NULL);
+ if (type)
+ rv = ptr->storage->ap_slotmem_create(&ptr->slotmem, storename,
sizeof(domaininfo_t), *num, type, p);
+ else {
+ apr_size_t size = sizeof(domaininfo_t);
+ rv = ptr->storage->ap_slotmem_attach(&ptr->slotmem, storename,
&size, num, p);
+ }
+ if (rv != APR_SUCCESS) {
+ return NULL;
+ }
+ ptr->num = *num;
+ ptr->p = p;
+ return ptr;
+}
+/**
+ * Insert(alloc) and update a domain record in the shared table
+ * @param pointer to the shared table.
+ * @param domain domain to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+static apr_status_t insert_update(void* mem, void **data, int id, apr_pool_t *pool)
+{
+ domaininfo_t *in = (domaininfo_t *)*data;
+ domaininfo_t *ou = (domaininfo_t *)mem;
+ if (strcmp(in->JVMRoute, ou->JVMRoute) == 0 && strcmp(in->balancer,
ou->balancer) == 0) {
+ memcpy(ou, in, sizeof(domaininfo_t));
+ ou->id = id;
+ ou->updatetime = apr_time_sec(apr_time_now());
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+apr_status_t insert_update_domain(mem_t *s, domaininfo_t *domain)
+{
+ apr_status_t rv;
+ domaininfo_t *ou;
+ int ident;
+
+ domain->id = 0;
+ rv = s->storage->ap_slotmem_do(s->slotmem, insert_update, &domain,
s->p);
+ if (domain->id != 0 && rv == APR_SUCCESS) {
+ return APR_SUCCESS; /* updated */
+ }
+
+ /* we have to insert it */
+ rv = s->storage->ap_slotmem_alloc(s->slotmem, &ident, (void **)
&ou);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ memcpy(ou, domain, sizeof(domaininfo_t));
+ ou->id = ident;
+ ou->updatetime = apr_time_sec(apr_time_now());
+
+ return APR_SUCCESS;
+}
+
+/**
+ * read a domain record from the shared table
+ * @param pointer to the shared table.
+ * @param domain domain to read from the shared table.
+ * @return address of the read domain or NULL if error.
+ */
+static apr_status_t loc_read_domain(void* mem, void **data, int id, apr_pool_t *pool) {
+ domaininfo_t *in = (domaininfo_t *)*data;
+ domaininfo_t *ou = (domaininfo_t *)mem;
+
+ if (strcmp(in->JVMRoute, ou->JVMRoute) == 0 && strcmp(in->balancer,
ou->balancer) == 0) {
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+domaininfo_t * read_domain(mem_t *s, domaininfo_t *domain)
+{
+ apr_status_t rv;
+ domaininfo_t *ou = domain;
+
+ if (domain->id)
+ rv = s->storage->ap_slotmem_mem(s->slotmem, domain->id, (void **)
&ou);
+ else {
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_domain, &ou,
s->p);
+ }
+ if (rv == APR_SUCCESS)
+ return ou;
+ return NULL;
+}
+/**
+ * get a domain record from the shared table
+ * @param pointer to the shared table.
+ * @param domain address where the domain is locate in the shared table.
+ * @param ids in the domain table.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t get_domain(mem_t *s, domaininfo_t **domain, int ids)
+{
+ return(s->storage->ap_slotmem_mem(s->slotmem, ids, (void **) domain));
+}
+
+/**
+ * remove(free) a domain record from the shared table
+ * @param pointer to the shared table.
+ * @param domain domain to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t remove_domain(mem_t *s, domaininfo_t *domain)
+{
+ apr_status_t rv;
+ domaininfo_t *ou = domain;
+ if (domain->id)
+ s->storage->ap_slotmem_free(s->slotmem, domain->id, domain);
+ else {
+ /* XXX: for the moment January 2007 ap_slotmem_free only uses ident to remove */
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_domain, &ou,
s->p);
+ if (rv == APR_SUCCESS)
+ rv = s->storage->ap_slotmem_free(s->slotmem, ou->id, domain);
+ }
+ return rv;
+}
+
+/**
+ * find a domain record from the shared table using JVMRoute and balancer
+ * @param pointer to the shared table.
+ * @param domain address where the node is located in the shared table.
+ * @param route JVMRoute to search
+ * @return APR_SUCCESS if all went well
+ */
+apr_status_t find_domain(mem_t *s, domaininfo_t **domain, const char *route, const char
*balancer)
+{
+ domaininfo_t ou;
+ apr_status_t rv;
+
+ strcpy(ou.JVMRoute, route);
+ strcpy(ou.balancer, balancer);
+ *domain = &ou;
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_domain, domain,
s->p);
+ return rv;
+}
+
+
+/*
+ * get the ids for the used (not free) domains in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of domain existing or -1 if error.
+ */
+int get_ids_used_domain(mem_t *s, int *ids)
+{
+ return (s->storage->ap_slotmem_get_used(s->slotmem, ids));
+}
+
+/*
+ * read the size of the table.
+ * @param pointer to the shared table.
+ * @return number of domain existing or -1 if error.
+ */
+int get_max_size_domain(mem_t *s)
+{
+ return (s->storage->ap_slotmem_get_max_size(s->slotmem));
+}
+
+/**
+ * attach to the shared domain table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+mem_t * get_mem_domain(char *string, int *num, apr_pool_t *p, slotmem_storage_method
*storage)
+{
+ return(create_attach_mem_domain(string, num, 0, p, storage));
+}
+/**
+ * create a shared domain table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param persist tell if the slotmem element are persistent.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+mem_t * create_mem_domain(char *string, int *num, int persist, apr_pool_t *p,
slotmem_storage_method *storage)
+{
+ return(create_attach_mem_domain(string, num, CREATE_SLOTMEM|persist, p, storage));
+}
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2009-07-24 13:34:39 UTC (rev 2506)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2009-07-24 13:55:00 UTC (rev 2507)
@@ -50,6 +50,7 @@
#include "context.h"
#include "balancer.h"
#include "sessionid.h"
+#include "domain.h"
#define DEFMAXCONTEXT 100
#define DEFMAXNODE 20
@@ -94,12 +95,16 @@
#define RANGENODE 1
#define RANGEDOMAIN 2
+/* define HAVE_CLUSTER_EX_DEBUG to have extented debug in mod_cluster */
+#define HAVE_CLUSTER_EX_DEBUG 0
+
/* shared memory */
mem_t *contextstatsmem = NULL;
mem_t *nodestatsmem = NULL;
mem_t *hoststatsmem = NULL;
mem_t *balancerstatsmem = NULL;
mem_t *sessionidstatsmem = NULL;
+mem_t *domainstatsmem = NULL;
slotmem_storage_method *storage = NULL;
balancer_method *balancerhandler = NULL;
@@ -301,6 +306,43 @@
loc_insert_update_sessionid
};
+/*
+ * routines for the domain_storage_method
+ */
+static apr_status_t loc_read_domain(int ids, domaininfo_t **domain)
+{
+ return (get_domain(domainstatsmem, domain, ids));
+}
+static int loc_get_ids_used_domain(int *ids)
+{
+ return(get_ids_used_domain(domainstatsmem, ids));
+}
+static int loc_get_max_size_domain()
+{
+ return(get_max_size_domain(domainstatsmem));
+}
+static apr_status_t loc_remove_domain(domaininfo_t *domain)
+{
+ return (remove_domain(domainstatsmem, domain));
+}
+static apr_status_t loc_insert_update_domain(domaininfo_t *domain)
+{
+ return (insert_update_domain(domainstatsmem, domain));
+}
+static apr_status_t loc_find_domain(domaininfo_t **domain, const char *route, const char
*balancer)
+{
+ return (find_domain(domainstatsmem, domain, route, balancer));
+}
+static const struct domain_storage_method domain_storage =
+{
+ loc_read_domain,
+ loc_get_ids_used_domain,
+ loc_get_max_size_domain,
+ loc_remove_domain,
+ loc_insert_update_domain,
+ loc_find_domain
+};
+
/* helper for the handling of the Alias: host1,... Context: context1,... */
struct cluster_host {
char *host;
@@ -320,6 +362,7 @@
char *host;
char *balancer;
char *sessionid;
+ char *domain;
void *data;
const char *userdata_key = "mod_manager_init";
apr_uuid_t uuid;
@@ -337,12 +380,14 @@
host = apr_pstrcat(ptemp, mconf->basefilename, ".host", NULL);
balancer = apr_pstrcat(ptemp, mconf->basefilename, ".balancer",
NULL);
sessionid = apr_pstrcat(ptemp, mconf->basefilename, ".sessionid",
NULL);
+ domain = apr_pstrcat(ptemp, mconf->basefilename, ".domain", NULL);
} else {
node = ap_server_root_relative(ptemp, "logs/manager.node");
context = ap_server_root_relative(ptemp, "logs/manager.context");
host = ap_server_root_relative(ptemp, "logs/manager.host");
balancer = ap_server_root_relative(ptemp, "logs/manager.balancer");
sessionid = ap_server_root_relative(ptemp, "logs/manager.sessionid");
+ domain = ap_server_root_relative(ptemp, "logs/manager.domain");
}
/* Get a provider to handle the shared memory */
@@ -382,6 +427,12 @@
return !OK;
}
+ domainstatsmem = create_mem_domain(domain, &mconf->maxnode,
mconf->persistent, p, storage);
+ if (domainstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_domain
failed");
+ return !OK;
+ }
+
/* Get a provider to ping/pong logics */
balancerhandler = ap_lookup_provider("proxy_cluster", "balancer",
"0");
@@ -1488,6 +1539,30 @@
ap_rprintf(r, "</pre>");
}
+
+#if HAVE_CLUSTER_EX_DEBUG
+static void manager_domain(request_rec *r)
+{
+ int size, i;
+ int *id;
+
+ /* Process the domain information: the remove node belonging to a domain are stored
there */
+ ap_rprintf(r, "<h1>Domain:</h1>");
+ ap_rprintf(r, "<pre>");
+ size = get_max_size_domain(domainstatsmem);
+ id = apr_palloc(r->pool, sizeof(int) * size);
+ size = get_ids_used_domain(domainstatsmem, id);
+ for (i=0; i<size; i++) {
+ domaininfo_t *ou;
+ if (get_domain(domainstatsmem, &ou, id[i]) != APR_SUCCESS)
+ continue;
+ ap_rprintf(r, "dom: %s route: %s balancer: %s\n", ou->domain,
ou->JVMRoute, ou->balancer);
+ }
+ ap_rprintf(r, "</pre>");
+
+}
+#endif
+
static int count_sessionid(request_rec *r, char *route)
{
int size, i;
@@ -1772,6 +1847,9 @@
/* Display the sessions */
if (sizesessionid)
manager_sessionid(r);
+#if HAVE_CLUSTER_EX_DEBUG
+ manager_domain(r);
+#endif
ap_rputs("</body></html>\n", r);
@@ -2056,6 +2134,7 @@
ap_register_provider(p, "manager" , "shared", "2",
&context_storage);
ap_register_provider(p, "manager" , "shared", "3",
&balancer_storage);
ap_register_provider(p, "manager" , "shared", "4",
&sessionid_storage);
+ ap_register_provider(p, "manager" , "shared", "5",
&domain_storage);
}
/*
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2009-07-24 13:34:39 UTC
(rev 2506)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2009-07-24 13:55:00 UTC
(rev 2507)
@@ -47,6 +47,7 @@
#include "context.h"
#include "balancer.h"
#include "sessionid.h"
+#include "domain.h"
#if APR_HAVE_UNISTD_H
/* for getpid() */
@@ -72,6 +73,7 @@
static struct context_storage_method *context_storage = NULL;
static struct balancer_storage_method *balancer_storage = NULL;
static struct sessionid_storage_method *sessionid_storage = NULL;
+static struct domain_storage_method *domain_storage = NULL;
static apr_thread_mutex_t *lock = NULL;
@@ -87,6 +89,7 @@
#define TIMEINTERVAL apr_time_from_sec(1) /* recalcul the lbstatus based on number of
request in the time interval */
#define TIMESESSIONID 300 /* after 5 minutes the sessionid have
probably timeout */
+#define TIMEDOMAIN 300 /* after 5 minutes the sessionid have
probably timeout */
/* reslist constructor */
/* XXX: Should use the proxy_util one. */
@@ -655,6 +658,31 @@
}
}
+/*
+ * remove the domain that have timeout
+ */
+static void remove_timeout_domain(apr_pool_t *pool, server_rec *server)
+{
+ int *id, size, i;
+ apr_time_t now;
+
+ now = apr_time_sec(apr_time_now());
+
+ /* read the ident of the domain */
+ id = apr_pcalloc(pool, sizeof(int) * domain_storage->get_max_size_domain());
+ size = domain_storage->get_ids_used_domain(id);
+
+ for (i=0; i<size; i++) {
+ domaininfo_t *ou;
+ if (domain_storage->read_domain(id[i], &ou) != APR_SUCCESS)
+ continue;
+ if (ou->updatetime < (now - TIMEDOMAIN)) {
+ /* Remove it */
+ domain_storage->remove_domain(ou);
+ }
+ }
+}
+
/* Retrieve the parameter with the given name
* Something like 'JSESSIONID=12345...N'
* XXX: Should use the mod_proxy_balancer ones.
@@ -1333,6 +1361,21 @@
continue;
if (ou->mess.remove && (now - ou->updatetime) >=
apr_time_from_sec(WAITFORREMOVE) &&
(now - ou->mess.lastcleantry) >= apr_time_from_sec(WAITFORREMOVE)) {
+ /* if it has a domain store it in the domain */
+#if HAVE_CLUSTER_EX_DEBUG
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "remove_removed_node: %s %s %s", ou->mess.JVMRoute,
ou->mess.balancer, ou->mess.Domain);
+#endif
+ if (ou->mess.Domain[0] != '\0') {
+ domaininfo_t dom;
+ strcpy(dom.JVMRoute, ou->mess.JVMRoute);
+ strcpy(dom.balancer, ou->mess.balancer);
+ strcpy(dom.domain, ou->mess.Domain);
+ if (domain_storage->insert_update_domain(&dom)!=APR_SUCCESS) {
+ remove_timeout_domain(pool, server);
+ domain_storage->insert_update_domain(&dom);
+ }
+ }
/* remove the node from the shared memory */
node_storage->remove_node(ou);
}
@@ -1453,10 +1496,46 @@
"proxy_cluster_post_config: Can't find mod_manager for
sessionids");
return !OK;
}
+ domain_storage = ap_lookup_provider("manager" , "shared",
"5");
+ if (domain_storage == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, s,
+ "proxy_cluster_post_config: Can't find mod_manager for
domains");
+ return !OK;
+ }
return OK;
}
+/* Given the route find the corresponding domain (if there is a domain) */
+static apr_status_t find_domain(request_rec *r, char **domain, char *route, const char
*balancer)
+{
+ nodeinfo_t *ou;
+ domaininfo_t *dom;
+#if HAVE_CLUSTER_EX_DEBUG
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "find_domain: finding node for %s: %s", route, balancer);
+#endif
+ if (node_storage->find_node(&ou, route) == APR_SUCCESS) {
+ if (!strcmp(balancer, ou->mess.balancer)) {
+ if (ou->mess.Domain[0] != '\0') {
+ *domain = ou->mess.Domain;
+ }
+ return APR_SUCCESS;
+ }
+ }
+
+#if HAVE_CLUSTER_EX_DEBUG
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "find_domain: finding domain for %s: %s", route, balancer);
+#endif
+ /* We can't find the node, because it was removed... */
+ if (domain_storage->find_domain(&dom, route, balancer ) == APR_SUCCESS) {
+ *domain = dom->domain;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+
/**
* Find the balancer corresponding to the node information
*/
@@ -1473,6 +1552,8 @@
if (balancer->sticky == NULL)
continue;
+ if (strlen(balancer->name)<=11)
+ continue;
sessionid = cluster_get_sessionid(r, balancer->sticky, r->uri,
&sticky_used);
if (sessionid) {
@@ -1482,34 +1563,32 @@
if ((route = strchr(sessionid, '.')) != NULL )
route++;
if (route && *route) {
- nodeinfo_t *ou;
+ char *domain = NULL;
#if HAVE_CLUSTER_EX_DEBUG
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"cluster: Found route %s", route);
#endif
- if (node_storage->find_node(&ou, route) == APR_SUCCESS) {
- if (strlen(balancer->name)>11 &&
!strcmp(&balancer->name[11], ou->mess.balancer)) {
+ if (find_domain(r, &domain, route, &balancer->name[11]) ==
APR_SUCCESS) {
#if HAVE_CLUSTER_EX_DEBUG
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "cluster: Found balancer %s for %s",
ou->mess.balancer, route);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "cluster: Found balancer %s for %s",
&balancer->name[11], route);
#endif
- /* here we have the route and domain for find_session_route ...
*/
- apr_table_setn(r->notes, "session-sticky",
sticky_used);
- if (sessionid_storage)
- apr_table_setn(r->notes, "session-id",
sessionid);
- apr_table_setn(r->notes, "session-route", route);
+ /* here we have the route and domain for find_session_route ... */
+ apr_table_setn(r->notes, "session-sticky",
sticky_used);
+ if (sessionid_storage)
+ apr_table_setn(r->notes, "session-id", sessionid);
+ apr_table_setn(r->notes, "session-route", route);
- apr_table_setn(r->subprocess_env,
"BALANCER_SESSION_ROUTE", route);
- apr_table_setn(r->subprocess_env,
"BALANCER_SESSION_STICKY", sticky_used);
- if (ou->mess.Domain[0] != '\0') {
+ apr_table_setn(r->subprocess_env,
"BALANCER_SESSION_ROUTE", route);
+ apr_table_setn(r->subprocess_env,
"BALANCER_SESSION_STICKY", sticky_used);
+ if (domain) {
#if HAVE_CLUSTER_EX_DEBUG
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "cluster: Found domain %s for %s",
ou->mess.Domain, route);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "cluster: Found domain %s for %s", domain,
route);
#endif
- apr_table_setn(r->notes, "CLUSTER_DOMAIN",
ou->mess.Domain);
- }
- return &balancer->name[11];
+ apr_table_setn(r->notes, "CLUSTER_DOMAIN", domain);
}
+ return &balancer->name[11];
}
}
}