JBoss Native SVN: r1625 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-28 10:27:18 -0400 (Wed, 28 May 2008)
New Revision: 1625
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Arrange add and remove logic for workers.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-27 20:44:52 UTC (rev 1624)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-28 14:27:18 UTC (rev 1625)
@@ -73,6 +73,7 @@
nodeinfo_t *node)
{
char url[6+64+7+4]; /* Type :// Host : Port */
+ char *ptr;
/* build the name (scheme and port) when needed */
strcpy(url, node->mess.Type);
@@ -83,8 +84,6 @@
*worker = ap_proxy_get_worker(conf->pool, conf, url);
if (*worker == NULL) {
- char *ptr;
- proxy_worker *proxy_worker;
/* creates it */
const char *err = ap_proxy_add_worker(worker, conf->pool, conf, url);
@@ -92,31 +91,37 @@
ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
"Created: worker for %s failed: %s", url, err);
return;
- }
- proxy_worker = (struct proxy_worker *) *worker;
- /* Get the shared memory for this worker */
- ptr = (char *) node;
- ptr = ptr + node->offset;
- proxy_worker->s = (proxy_worker_stat *) ptr;
- proxy_worker->id = node->mess.id;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
"Created: worker for %s", url);
- /*
- * XXX: The Shared datastatus may already contains a valid information
- */
- if (!proxy_worker->s->status)
- proxy_worker->s->status = PROXY_WORKER_INITIALIZED;
-
- my_ap_proxy_add_worker_to_balancer(conf->pool, balancer, *worker);
+ }
+ } else if ((*worker)->id == 0) {
+ /* We are going to reuse a removed one */
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
- "Created: worker for %s %d (status): %d", url, proxy_worker->id, proxy_worker->s->status);
+ "Created: reusing worker for %s", url);
+ } else {
+ return; /* Done Already existing */
+ }
+ /* Get the shared memory for this worker */
+ ptr = (char *) node;
+ ptr = ptr + node->offset;
+ (*worker)->s = (proxy_worker_stat *) ptr;
- /* XXX: it may be already filled... */
- strncpy(proxy_worker->s->route, node->mess.JVMRoute, PROXY_WORKER_MAX_ROUTE_SIZ);
- proxy_worker->s->route[PROXY_WORKER_MAX_ROUTE_SIZ] = '\0';
- /* XXX: We need that information from TC */
- proxy_worker->s->redirect[0] = '\0';
- }
+ (*worker)->id = node->mess.id;
+ /*
+ * XXX: The Shared datastatus may already contains a valid information
+ */
+ if (!(*worker)->s->status)
+ (*worker)->s->status = PROXY_WORKER_INITIALIZED;
+
+ my_ap_proxy_add_worker_to_balancer(conf->pool, balancer, *worker);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "Created: worker for %s %d (status): %d", url, (*worker)->id, (*worker)->s->status);
+
+ /* XXX: it may be already filled... */
+ strncpy((*worker)->s->route, node->mess.JVMRoute, PROXY_WORKER_MAX_ROUTE_SIZ);
+ (*worker)->s->route[PROXY_WORKER_MAX_ROUTE_SIZ] = '\0';
+ /* XXX: We need that information from TC */
+ (*worker)->s->redirect[0] = '\0';
}
/*
* Add a node to the worker conf
@@ -155,7 +160,7 @@
"add_workers_node done");
}
/*
- * Add a node to the worker conf
+ * Remove a node from the worker conf
*/
static int remove_workers_node(nodeinfo_t *node, proxy_server_conf *conf, apr_pool_t *pool, server_rec *server)
{
@@ -184,6 +189,7 @@
/* No connection in use: clean the worker */
apr_pool_destroy(worker->cp->pool);
worker->cp->pool = NULL;
+ worker->id = 0;
/* XXX: How to remove the worker from the apr_array of the balancer */
@@ -628,7 +634,7 @@
while (!mycandidate && !checked_standby) {
worker = (proxy_worker *)balancer->workers->elts;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: bytraffic for BALANCER (%d)", balancer->workers->nelts);
+ "proxy: bytraffic balancer (%d)", balancer->workers->nelts);
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
if (!checking_standby) { /* first time through */
if (worker->s->lbset > max_lbset)
@@ -1079,11 +1085,6 @@
if (candidate)
candidate->s->elected++;
-/*
- PROXY_THREAD_UNLOCK(balancer);
- return NULL;
-*/
-
if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
"proxy: CLUSTER: (%s). Unlock failed for find_best_worker()", balancer->name);
16 years, 9 months
JBoss Native SVN: r1624 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-27 16:44:52 -0400 (Tue, 27 May 2008)
New Revision: 1624
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Add balancer information in DUMP.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-27 20:43:35 UTC (rev 1623)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-27 20:44:52 UTC (rev 1624)
@@ -581,14 +581,25 @@
ap_set_content_type(r, "text/plain");
+ size = get_max_size_balancer(balancerstatsmem);
+ id = apr_palloc(r->pool, sizeof(int) * size);
+ size = get_ids_used_balancer(balancerstatsmem, id);
+ for (i=0; i<size; i++) {
+ balancerinfo_t *ou;
+ get_balancer(balancerstatsmem, &ou, id[i]);
+ ap_rprintf(r, "balancer: [%d] Name: %s Sticky: %d [%s]/[%s]\n",
+ id[i], ou->balancer, ou->StickySession,
+ ou->StickySessionCookie, ou->StickySessionPath);
+ }
+
size = get_max_size_node(nodestatsmem);
id = apr_palloc(r->pool, sizeof(int) * size);
size = get_ids_used_node(nodestatsmem, id);
for (i=0; i<size; i++) {
nodeinfo_t *ou;
get_node(nodestatsmem, &ou, id[i]);
- ap_rprintf(r, "node: [%d:%d] JVMRoute: %s Domain: [%s] Host: %s Port: %s Type: %s\n",
- id[i], ou->mess.id, ou->mess.JVMRoute, ou->mess.Domain,
+ ap_rprintf(r, "node: [%d:%d] Balancer: %s JVMRoute: %s Domain: [%s] Host: %s Port: %s Type: %s\n",
+ id[i], ou->mess.id, ou->mess.balancer, ou->mess.JVMRoute, ou->mess.Domain,
ou->mess.Host, ou->mess.Port, ou->mess.Type);
}
16 years, 9 months
JBoss Native SVN: r1623 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-27 16:43:35 -0400 (Tue, 27 May 2008)
New Revision: 1623
Modified:
trunk/mod_cluster/native/mod_manager/node.c
Log:
Oops apr_time_t is bigger than a long.
Modified: trunk/mod_cluster/native/mod_manager/node.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/node.c 2008-05-27 15:25:56 UTC (rev 1622)
+++ trunk/mod_cluster/native/mod_manager/node.c 2008-05-27 20:43:35 UTC (rev 1623)
@@ -95,7 +95,7 @@
memcpy(ou, in, sizeof(nodemess_t));
ou->mess.id = id;
ou->updatetime = apr_time_now();
- ou->offset = sizeof(nodemess_t) + sizeof(unsigned long) + sizeof(int);
+ ou->offset = sizeof(nodemess_t) + sizeof(apr_time_t) + sizeof(int);
*data = ou;
return APR_SUCCESS;
}
@@ -125,7 +125,7 @@
ou->updatetime = apr_time_now();
/* set of offset to the proxy_worker_stat */
- ou->offset = sizeof(nodemess_t) + sizeof(unsigned long) + sizeof(int);
+ ou->offset = sizeof(nodemess_t) + sizeof(apr_time_t) + sizeof(int);
/* blank the proxy status information */
memset(ou->stat, '\0', SIZEOFSCORE);
16 years, 9 months
JBoss Native SVN: r1622 - in trunk/mod_cluster/native: mod_manager and 1 other directories.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-27 11:25:56 -0400 (Tue, 27 May 2008)
New Revision: 1622
Modified:
trunk/mod_cluster/native/include/node.h
trunk/mod_cluster/native/mod_manager/mod_manager.c
trunk/mod_cluster/native/mod_manager/node.c
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Add logic to remove the nodes.
Modified: trunk/mod_cluster/native/include/node.h
===================================================================
--- trunk/mod_cluster/native/include/node.h 2008-05-27 06:40:15 UTC (rev 1621)
+++ trunk/mod_cluster/native/include/node.h 2008-05-27 15:25:56 UTC (rev 1622)
@@ -76,7 +76,7 @@
/* config from jboss/tomcat */
nodemess_t mess;
/* filled by httpd */
- unsigned long updatetime; /* time of last received message */
+ apr_time_t updatetime; /* time of last received message */
int offset; /* offset to the proxy_worker_stat structure */
char stat[SIZEOFSCORE]; /* to store the status */
};
@@ -169,5 +169,18 @@
* read the max number of nodes in the shared table
*/
APR_DECLARE(int) (*get_max_size_node)();
+/**
+ * check the nodes for modifications.
+ * XXX: void *data is server_rec *s in fact.
+ */
+APR_DECLARE(apr_time_t) (*worker_nodes_need_update)(void *data, apr_pool_t *pool);
+/*
+ * mark that the worker node are now up to date.
+ */
+APR_DECLARE(int) (*worker_nodes_are_updated)(void *data);
+/*
+ * Remove the node from shared memory (free the slotmem)
+ */
+APR_DECLARE(int) (*remove_node)(nodeinfo_t *node);
};
#endif /*NODE_H*/
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-27 06:40:15 UTC (rev 1621)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-27 15:25:56 UTC (rev 1622)
@@ -97,6 +97,10 @@
int maxnode;
/* max munber of host supported */
int maxhost;
+
+ /* last time the node update logic was called */
+ apr_time_t last_updated;
+
} mod_manager_config;
/*
@@ -114,11 +118,57 @@
{
return(get_max_size_node(nodestatsmem));
}
+static apr_status_t loc_remove_node(nodeinfo_t *node)
+{
+ return (remove_node(nodestatsmem, node));
+}
+
+/* Check is the nodes (in shared memory) were modified since last
+ * call to worker_nodes_are_updated().
+ * return codes:
+ * 0 : No update of the nodes since last time.
+ * x : Last time we changed something in the process.
+ */
+static apr_time_t loc_worker_nodes_need_update(void *data, apr_pool_t *pool)
+{
+ int size, i;
+ int *id;
+ server_rec *s = (server_rec *) data;
+ apr_time_t last = 0;
+ mod_manager_config *mconf = ap_get_module_config(s->module_config, &manager_module);
+
+ size = get_max_size_node(nodestatsmem);
+ id = apr_palloc(pool, sizeof(int) * size);
+ size = get_ids_used_node(nodestatsmem, id);
+ for (i=0; i<size; i++) {
+ nodeinfo_t *ou;
+ get_node(nodestatsmem, &ou, id[i]);
+ if (ou->updatetime > last)
+ last = ou->updatetime;
+ }
+ if (last >= mconf->last_updated) {
+ if (mconf->last_updated == 0)
+ return(1); /* First time */
+ return(mconf->last_updated);
+ }
+
+ return (0);
+}
+/* Store the last update time in the proccess config */
+static int loc_worker_nodes_are_updated(void *data)
+{
+ server_rec *s = (server_rec *) data;
+ mod_manager_config *mconf = ap_get_module_config(s->module_config, &manager_module);
+ mconf->last_updated = apr_time_now();
+}
static const struct node_storage_method node_storage =
{
loc_read_node,
loc_get_ids_used_node,
- loc_get_max_size_node
+ loc_get_max_size_node,
+ loc_worker_nodes_need_update,
+ loc_worker_nodes_are_updated,
+ loc_remove_node
};
/*
@@ -665,12 +715,14 @@
/* Read the node */
node = read_node(nodestatsmem, &nodeinfo);
if (node == NULL) {
+ if (status == REMOVE)
+ return NULL; /* Already done */
*errtype = TYPEMEM;
return MNODERD;
}
/* Process the * APP commands */
- if (strcmp(r->uri, "*") == 0) {
+ if (strcmp(r->uri, "*") == 0 || strcmp(r->uri, "/*") ==0) {
return (process_node_cmd(r, status, errtype, node));
}
@@ -1054,6 +1106,7 @@
mconf->maxcontext = DEFMAXCONTEXT;
mconf->maxnode = DEFMAXNODE;
mconf->maxhost = DEFMAXHOST;
+ mconf->last_updated = 0;
return mconf;
}
@@ -1071,6 +1124,7 @@
mconf->basefilename = NULL;
mconf->maxcontext = DEFMAXCONTEXT;
mconf->maxnode = DEFMAXNODE;
+ mconf->last_updated = 0;
if (mconf2->basefilename)
mconf->basefilename = apr_pstrdup(p, mconf2->basefilename);
Modified: trunk/mod_cluster/native/mod_manager/node.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/node.c 2008-05-27 06:40:15 UTC (rev 1621)
+++ trunk/mod_cluster/native/mod_manager/node.c 2008-05-27 15:25:56 UTC (rev 1622)
@@ -94,7 +94,7 @@
*/
memcpy(ou, in, sizeof(nodemess_t));
ou->mess.id = id;
- ou->updatetime = (unsigned long) apr_time_sec(apr_time_now());
+ ou->updatetime = apr_time_now();
ou->offset = sizeof(nodemess_t) + sizeof(unsigned long) + sizeof(int);
*data = ou;
return APR_SUCCESS;
@@ -122,7 +122,7 @@
memcpy(ou, node, sizeof(nodeinfo_t));
ou->mess.id = ident;
*id = ident;
- ou->updatetime = (unsigned long) apr_time_sec(apr_time_now());
+ ou->updatetime = apr_time_now();
/* set of offset to the proxy_worker_stat */
ou->offset = sizeof(nodemess_t) + sizeof(unsigned long) + sizeof(int);
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-27 06:40:15 UTC (rev 1621)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-27 15:25:56 UTC (rev 1622)
@@ -119,77 +119,121 @@
}
}
/*
- * Create workers corresponding to newer nodes.
+ * Add a node to the worker conf
*/
-static void create_workers_node(proxy_server_conf *conf, apr_pool_t *pool, server_rec *server)
+static int add_workers_node(nodeinfo_t *node, proxy_server_conf *conf, apr_pool_t *pool, server_rec *server)
{
- int *ids, num;
+ char *name = apr_pstrcat(pool, "cluster://", node->mess.balancer, NULL);
+ proxy_balancer *balancer = ap_proxy_get_balancer(pool, conf, name);
+ proxy_worker *worker = NULL;
+ if (!balancer) {
+ /* Create one */
+ ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
+ "add_workers_node: Create balancer %s", name);
+ balancer = apr_array_push(conf->balancers);
+ memset(balancer, 0, sizeof(proxy_balancer));
+ balancer->name = apr_pstrdup(conf->pool, name);
+ balancer->lbmethod = ap_lookup_provider(PROXY_LBMETHOD, "cluster_bytraffic", "0");
+ balancer->workers = apr_array_make(conf->pool, 5, sizeof(proxy_worker));
+ /* XXX Is this a right place to create mutex */
+#if APR_HAS_THREADS
+ if (apr_thread_mutex_create(&(balancer->mutex),
+ APR_THREAD_MUTEX_DEFAULT, conf->pool) != APR_SUCCESS) {
+ /* XXX: Do we need to log something here */
+ ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
+ "add_workers_node: Can't create lock for balancer");
+ }
+#endif
+ }
+ if (balancer) {
+ create_worker(conf, balancer, server, &worker, node);
+ } else {
+ ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
+ "add_workers_node: Can't find balancer");
+ }
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "add_workers_node done");
+}
+/*
+ * Add a node to the worker conf
+ */
+static int remove_workers_node(nodeinfo_t *node, proxy_server_conf *conf, apr_pool_t *pool, server_rec *server)
+{
+ int i;
+ proxy_worker *worker = (proxy_worker *)conf->workers->elts;
+ for (i = 0; i < conf->workers->nelts; i++) {
+ if (worker->id == node->mess.id)
+ break;
+ worker++;
+ }
+ if (i == conf->workers->nelts) {
+ node_storage->remove_node(node);
+ return 0; /* Done ? */
+ }
+ /* prevent other threads using it */
+ worker->s->status = worker->s->status |= PROXY_WORKER_IN_ERROR;
+
+ /* apr_reslist_acquired_count */
+ i = 0;
+ if (worker->cp->res)
+ i = apr_reslist_acquired_count(worker->cp->res);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "remove_workers_node %d", i);
+ if (i == 0) {
+ /* No connection in use: clean the worker */
+ apr_pool_destroy(worker->cp->pool);
+ worker->cp->pool = NULL;
+
+ /* XXX: How to remove the worker from the apr_array of the balancer */
+
+ /* remove the node from the shared memory */
+ node_storage->remove_node(node);
+ return (0);
+ } else
+ return (1); /* We should retry later */
+}
+/*
+ * Create/Remove workers corresponding to updated nodes.
+ */
+static void update_workers_node(proxy_server_conf *conf, apr_pool_t *pool, server_rec *server)
+{
+ int *id, size, i;
+ apr_time_t last;
+ int notok = 0;
+
+ /* Check if we have to do something */
+ last = node_storage->worker_nodes_need_update(server, pool);
+
+ /* nodes_need_update will return 1 if last_updated is zero: first time we are called */
+ if (last == 0)
+ return;
+
/* read the ident of the nodes */
-
- ids = apr_pcalloc(pool, sizeof(int) * node_storage->get_max_size_node());
- num = node_storage->get_ids_used_node(ids);
+ id = apr_pcalloc(pool, sizeof(int) * node_storage->get_max_size_node());
+ size = node_storage->get_ids_used_node(id);
+
/* XXX: How to skip the balancer that aren't controled by mod_manager */
- if (conf->workers->nelts<num) {
- /* There are more workers in shared area than in the local tables */
- proxy_worker *worker;
- int i, j;
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
- "create_workers_node starting");
- worker = (proxy_worker *)conf->workers->elts;
- for (i = 0; i < conf->workers->nelts; i++) {
- /* check the id against the table of used ids */
- for (j=0; j<num; j++) {
- if (worker->id == ids[j]) {
- ids[j] = 0;
- break;
- }
- }
- worker++;
- }
- /* create the workers */
- for (j=0; j<num; j++) {
- if (ids[j]) {
- /* read the node and create the worker */
- nodeinfo_t *node;
- if (node_storage->read_node(ids[j], &node) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
- "create_workers_node can't read id %d", ids[j]);
- continue;
- }
- char *name = apr_pstrcat(pool, "cluster://", node->mess.balancer, NULL);
- proxy_balancer *balancer = ap_proxy_get_balancer(pool, conf, name);
- if (!balancer) {
- /* Create one */
- ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
- "create_workers_node: Create balancer %s", name);
- balancer = apr_array_push(conf->balancers);
- memset(balancer, 0, sizeof(proxy_balancer));
- balancer->name = apr_pstrdup(conf->pool, name);
- balancer->lbmethod = ap_lookup_provider(PROXY_LBMETHOD, "cluster_bytraffic", "0");
- balancer->workers = apr_array_make(conf->pool, 5, sizeof(proxy_worker));
- /* XXX Is this a right place to create mutex */
-#if APR_HAS_THREADS
- if (apr_thread_mutex_create(&(balancer->mutex),
- APR_THREAD_MUTEX_DEFAULT, conf->pool) != APR_SUCCESS) {
- /* XXX: Do we need to log something here */
- ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
- "create_workers_node: Can't create lock for balancer");
- }
-#endif
- }
- if (balancer) {
- create_worker(conf, balancer, server, &worker, node);
- } else {
- ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
- "create_workers_node: Can't find balancer");
- }
- }
- }
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
- "create_workers_node done");
- }
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "update_workers_node starting");
+
+ /* Only process the nodes that have been updated since our last update */
+ for (i=0; i<size; i++) {
+ nodeinfo_t *ou;
+ node_storage->read_node(id[i], &ou);
+ if (ou->updatetime >= last) {
+ /* The node has changed */
+ if (ou->mess.remove)
+ notok = notok + remove_workers_node(ou, conf, pool, server);
+ else
+ add_workers_node(ou, conf, pool, server);
+ }
+ }
+ if (! notok)
+ node_storage->worker_nodes_are_updated(server);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "update_workers_node done");
}
/* reslist constructor */
@@ -576,7 +620,7 @@
balancer->name);
/* create workers for new nodes */
- create_workers_node(conf, r->pool, r->server);
+ update_workers_node(conf, r->pool, r->server);
/* First try to see if we have available candidate */
do {
@@ -743,7 +787,7 @@
proxy_worker *worker;
/* create the workers (that could be the first time) */
- create_workers_node(conf, r->pool, r->server);
+ update_workers_node(conf, r->pool, r->server);
/* search for the worker */
worker = (proxy_worker *)conf->workers->elts;
@@ -808,7 +852,7 @@
apr_sleep(apr_time_make(0, 1000));
/* Create new workers if the shared memory changes */
apr_pool_create(&pool, conf->pool);
- create_workers_node(conf, pool, s);
+ update_workers_node(conf, pool, s);
apr_pool_destroy(pool);
}
apr_thread_exit(thd, 0);
@@ -866,7 +910,7 @@
*/
static int proxy_cluster_trans(request_rec *r)
{
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, r->server,
"proxy_cluster_trans for %d %s %s uri: %s",
r->proxyreq, r->filename, r->handler, r->uri);
@@ -875,7 +919,7 @@
r->filename = apr_pstrcat(r->pool, "proxy:cluster://", balancer, r->uri, NULL);
r->handler = "proxy-server";
r->proxyreq = PROXYREQ_REVERSE;
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, r->server,
"proxy_cluster_trans using %s uri: %s",
balancer, r->filename);
return OK; /* Mod_proxy will process it */
16 years, 9 months
JBoss Native SVN: r1621 - in trunk/mod_cluster/native: mod_manager and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-27 02:40:15 -0400 (Tue, 27 May 2008)
New Revision: 1621
Modified:
trunk/mod_cluster/native/include/node.h
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Add logic to process *-APP * commands.
Add remove to the node description.
Modified: trunk/mod_cluster/native/include/node.h
===================================================================
--- trunk/mod_cluster/native/include/node.h 2008-05-26 18:20:04 UTC (rev 1620)
+++ trunk/mod_cluster/native/include/node.h 2008-05-27 06:40:15 UTC (rev 1621)
@@ -55,6 +55,7 @@
char Port[PORTNODESZ];
char Type[SCHEMENDSZ];
int reversed; /* 1 : reversed... 0 : normal */
+ int remove; /* 1 : removed 0 : normal */
/* node conf part */
int flushpackets;
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 18:20:04 UTC (rev 1620)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-27 06:40:15 UTC (rev 1621)
@@ -565,7 +565,56 @@
return NULL;
}
-/* Process an enable/disable/stop application message */
+/* Process a *-APP command that applies to the node */
+static char * process_node_cmd(request_rec *r, int status, int *errtype, nodeinfo_t *node)
+{
+ /* for read the hosts */
+ int i,j;
+ int size = get_max_size_host(hoststatsmem);
+ int *id = apr_palloc(r->pool, sizeof(int) * size);
+
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "process_node_cmd %d processing node: %d", status, node->mess.id);
+ size = get_ids_used_host(hoststatsmem, id);
+ for (i=0; i<size; i++) {
+ hostinfo_t *ou;
+ get_host(hoststatsmem, &ou, id[i]);
+ if (ou->node != node->mess.id)
+ continue;
+ /* If the host corresponds to a node process all contextes */
+ int sizecontext = get_max_size_context(contextstatsmem);
+ int *idcontext = apr_palloc(r->pool, sizeof(int) * sizecontext);
+ sizecontext = get_ids_used_context(contextstatsmem, idcontext);
+ for (j=0; j<sizecontext; j++) {
+ contextinfo_t *context;
+ get_context(contextstatsmem, &context, idcontext[j]);
+ if (context->vhost == ou->vhost &&
+ context->node == ou->node) {
+ /* Process the context */
+ if (status != REMOVE) {
+ context->status = status;
+ insert_update_context(contextstatsmem, context);
+ } else
+ remove_context(contextstatsmem, context);
+
+ }
+ }
+ if (status == REMOVE) {
+ remove_host(hoststatsmem, ou);
+ }
+ }
+
+ /* The REMOVE-APP * removes the node (well mark it removed) */
+ if (status == REMOVE) {
+ int id;
+ node->mess.remove = 1;
+ insert_update_node(nodestatsmem, node, &id);
+ }
+ return NULL;
+
+}
+
+/* Process an enable/disable/stop/remove application message */
static char * process_appl_cmd(request_rec *r, char *buff, int status, int *errtype)
{
char *JVMRoute;
@@ -620,6 +669,11 @@
return MNODERD;
}
+ /* Process the * APP commands */
+ if (strcmp(r->uri, "*") == 0) {
+ return (process_node_cmd(r, status, errtype, node));
+ }
+
/* Read the ID of the virtual corresponding to the first Alias */
hostinfo_t hostinfo;
hostinfo_t *host;
16 years, 9 months
JBoss Native SVN: r1620 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-26 14:20:04 -0400 (Mon, 26 May 2008)
New Revision: 1620
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Arrange *-APP Context/Alias.
Arrange REMOVE-APP.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 16:22:33 UTC (rev 1619)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 18:20:04 UTC (rev 1620)
@@ -64,6 +64,8 @@
#define SCONBAD "SYNTAX: Context without Alias"
#define SBADFLD "SYNTAX: Invalid field \"%s\" in message"
#define SCMDUNS "SYNTAX: Command is not supported"
+#define SMULALB "SYNTAX: Only one Alias in APP command"
+#define SMULCTB "SYNTAX: Only one Context in APP command"
#define TYPEMEM 2
#define MNODEUI "MEM: Can't update or insert node"
@@ -336,6 +338,7 @@
while (*ptr) {
if (*ptr == ',') {
*ptr = '\0';
+ info.id = 0;
strncpy(info.context, previous, sizeof(info.context));
if (status != REMOVE)
insert_update_context(mem, &info);
@@ -348,6 +351,7 @@
}
ptr ++;
}
+ info.id = 0;
strncpy(info.context, previous, sizeof(info.context));
if (status != REMOVE)
insert_update_context(mem, &info);
@@ -506,6 +510,8 @@
/* Insert the Alias and corresponding Context */
phost = vhost;
+ if (phost->host == NULL && phost->context == NULL)
+ return NULL; /* Alias and Context missing */
int vid = 1; /* zero and "" is empty */
while (phost) {
insert_update_hosts(hoststatsmem, phost->host, id, vid);
@@ -566,7 +572,6 @@
nodeinfo_t nodeinfo;
nodeinfo_t *node;
struct cluster_host *vhost;
- struct cluster_host *phost;
char **ptr = process_buff(r, buff);
if (ptr == NULL) {
@@ -575,11 +580,10 @@
}
/* Map nothing by default */
+ vhost = apr_palloc(r->pool, sizeof(struct cluster_host));
vhost->host = NULL;
vhost->context = NULL;
vhost->next = NULL;
- vhost = apr_palloc(r->pool, sizeof(struct cluster_host));
- phost = vhost;
int i = 0;
while (ptr[i]) {
@@ -592,26 +596,18 @@
nodeinfo.mess.id = 0;
}
if (strcasecmp(ptr[i], "Alias") == 0) {
- if (phost->host && !phost->context) {
+ if (vhost->host) {
*errtype = TYPESYNTAX;
- return SALIBAD;
+ return SMULALB;
}
- if (phost->host) {
- phost->next = apr_palloc(r->pool, sizeof(struct cluster_host));
- phost = phost->next;
- phost->next = NULL;
- phost->host = ptr[i+1];
- phost->context = NULL;
- } else {
- phost->host = ptr[i+1];
- }
+ vhost->host = ptr[i+1];
}
if (strcasecmp(ptr[i], "Context") == 0) {
- if (phost->context) {
+ if (vhost->context) {
*errtype = TYPESYNTAX;
- return SCONBAD;
+ return SMULCTB;
}
- phost->context = ptr[i+1];
+ vhost->context = ptr[i+1];
}
i++;
i++;
@@ -642,7 +638,7 @@
return NULL;
/* If the Host doesn't exist yet create it */
int vid = 1; /* XXX: That is not really the right value, but that works most time */
- insert_update_hosts(hoststatsmem, phost->host, node->mess.id, vid);
+ insert_update_hosts(hoststatsmem, vhost->host, node->mess.id, vid);
hostinfo.id = 0;
if (vhost->host != NULL)
strcpy(hostinfo.host, vhost->host);
@@ -656,7 +652,25 @@
}
/* Now update each context from Context: part */
- insert_update_contexts(contextstatsmem, phost->context, node->mess.id, host->vhost, status);
+ insert_update_contexts(contextstatsmem, vhost->context, node->mess.id, host->vhost, status);
+
+ /* Remove the host if all the contextes have been removed */
+ if (status == REMOVE) {
+ int size = get_max_size_context(contextstatsmem);
+ int *id = apr_palloc(r->pool, sizeof(int) * size);
+ size = get_ids_used_context(contextstatsmem, id);
+ for (i=0; i<size; i++) {
+ contextinfo_t *ou;
+ get_context(contextstatsmem, &ou, id[i]);
+ if (ou->vhost == host->vhost &&
+ ou->node == node->mess.id)
+ break;
+ }
+ if (i==size) {
+ hostinfo.id = host->vhost;
+ remove_host(hoststatsmem, &hostinfo);
+ }
+ }
return NULL;
}
static char * process_enable(request_rec *r, char *buff, int *errtype)
16 years, 9 months
JBoss Native SVN: r1619 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-26 12:22:33 -0400 (Mon, 26 May 2008)
New Revision: 1619
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Arrange the remove logic.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 15:10:16 UTC (rev 1618)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 16:22:33 UTC (rev 1619)
@@ -316,6 +316,7 @@
}
/*
* Insert the context from Context information
+ * Note that if status is REMOVE remove_context will be called.
*/
static int insert_update_contexts(mem_t *mem, char *str, int node, int vhost, int status)
{
@@ -336,7 +337,11 @@
if (*ptr == ',') {
*ptr = '\0';
strncpy(info.context, previous, sizeof(info.context));
- insert_update_context(mem, &info);
+ if (status != REMOVE)
+ insert_update_context(mem, &info);
+ else
+ remove_context(mem, &info);
+
if (!ret)
ret = info.id;
previous = ptr + 1;
@@ -632,6 +637,9 @@
hostinfo.id = 0;
host = read_host(hoststatsmem, &hostinfo);
if (host == NULL) {
+ /* If REMOVE ignores it */
+ if (status == REMOVE)
+ return NULL;
/* If the Host doesn't exist yet create it */
int vid = 1; /* XXX: That is not really the right value, but that works most time */
insert_update_hosts(hoststatsmem, phost->host, node->mess.id, vid);
16 years, 9 months
JBoss Native SVN: r1618 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-26 11:10:16 -0400 (Mon, 26 May 2008)
New Revision: 1618
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Arrange buff size and error message.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 14:17:41 UTC (rev 1617)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 15:10:16 UTC (rev 1618)
@@ -62,7 +62,7 @@
#define STYPBIG "SYNTAX: Type field too big"
#define SALIBAD "SYNTAX: Alias without Context"
#define SCONBAD "SYNTAX: Context without Alias"
-#define SBADFLD "SYNTAX: Invalid field name in message"
+#define SBADFLD "SYNTAX: Invalid field \"%s\" in message"
#define SCMDUNS "SYNTAX: Command is not supported"
#define TYPEMEM 2
@@ -265,13 +265,13 @@
i++;
}
}
- ptr = apr_palloc(r->pool, sizeof(char *) * (i + 1));
+ ptr = apr_palloc(r->pool, sizeof(char *) * (i + 2));
if (ptr == NULL)
return NULL;
s = buff;
ptr[0] = s;
- ptr[i] = NULL;
+ ptr[i+1] = NULL;
i = 1;
for (; *s != '\0'; s++) {
if (*s == '&' || *s == '=') {
@@ -711,7 +711,7 @@
}
else {
*errtype = TYPESYNTAX;
- return SBADFLD;
+ return apr_psprintf(r->pool, SBADFLD, ptr[i]);
}
i++;
i++;
@@ -813,7 +813,7 @@
return DECLINED;
/* Use a buffer to read the message */
- buff = apr_palloc(r->pool, MAXMESSSIZE);
+ buff = apr_pcalloc(r->pool, MAXMESSSIZE);
input_brigade = apr_brigade_create(r->connection->pool, r->connection->bucket_alloc);
ap_get_brigade(r->input_filters, input_brigade, AP_MODE_READBYTES, APR_BLOCK_READ, MAXMESSSIZE);
apr_brigade_flatten(input_brigade, buff, &bufsiz);
16 years, 9 months
JBoss Native SVN: r1617 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-26 10:17:41 -0400 (Mon, 26 May 2008)
New Revision: 1617
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Create the host when receiving a *_APP command containing the host.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 13:16:45 UTC (rev 1616)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 14:17:41 UTC (rev 1617)
@@ -49,6 +49,7 @@
#define DEFMAXCONTEXT 100
#define DEFMAXNODE 10
#define DEFMAXHOST 20
+#define MAXMESSSIZE 1024
/* Error messages */
#define TYPESYNTAX 1
@@ -631,8 +632,19 @@
hostinfo.id = 0;
host = read_host(hoststatsmem, &hostinfo);
if (host == NULL) {
- *errtype = TYPEMEM;
- return MHOSTRD;
+ /* If the Host doesn't exist yet create it */
+ int vid = 1; /* XXX: That is not really the right value, but that works most time */
+ insert_update_hosts(hoststatsmem, phost->host, node->mess.id, vid);
+ hostinfo.id = 0;
+ if (vhost->host != NULL)
+ strcpy(hostinfo.host, vhost->host);
+ else
+ hostinfo.host[0] = '\0';
+ host = read_host(hoststatsmem, &hostinfo);
+ if (host == NULL) {
+ *errtype = TYPEMEM;
+ return MHOSTRD;
+ }
}
/* Now update each context from Context: part */
@@ -794,19 +806,22 @@
apr_bucket_brigade *input_brigade;
char *errstring = NULL;
int errtype = 0;
- char buff[4096];
- int bufsiz=sizeof(buff);
+ char *buff;
+ int bufsiz=MAXMESSSIZE;
if (strcmp(r->handler, "mod-cluster"))
return DECLINED;
+
+ /* Use a buffer to read the message */
+ buff = apr_palloc(r->pool, MAXMESSSIZE);
input_brigade = apr_brigade_create(r->connection->pool, r->connection->bucket_alloc);
- ap_get_brigade(r->input_filters, input_brigade, AP_MODE_READBYTES, APR_BLOCK_READ, sizeof(buff));
+ ap_get_brigade(r->input_filters, input_brigade, AP_MODE_READBYTES, APR_BLOCK_READ, MAXMESSSIZE);
apr_brigade_flatten(input_brigade, buff, &bufsiz);
buff[bufsiz] = '\0';
/* XXX: Size limit it? */
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "manager_handler %s processing: %s", r->method, buff);
+ "manager_handler %s processing: \"%s\"", r->method, buff);
decodeenc(buff);
if (strcasecmp(r->method, "CONFIG") == 0)
errstring = process_config(r, buff, &errtype);
16 years, 9 months
JBoss Native SVN: r1616 - trunk/build/patch.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-26 09:16:45 -0400 (Mon, 26 May 2008)
New Revision: 1616
Modified:
trunk/build/patch/apr-1.2.12.patch
trunk/build/patch/apr-util-1.2.12.patch
Log:
Add missing patch prefix
Modified: trunk/build/patch/apr-1.2.12.patch
===================================================================
--- trunk/build/patch/apr-1.2.12.patch 2008-05-26 09:44:33 UTC (rev 1615)
+++ trunk/build/patch/apr-1.2.12.patch 2008-05-26 13:16:45 UTC (rev 1616)
@@ -1,5 +1,5 @@
---- apr.hw
-+++ apr.hw
+--- include/apr.hw
++++ include/apr.hw
@@ -217,7 +217,7 @@
#define APR_HAVE_IN_ADDR 1
#define APR_HAVE_INET_ADDR 1
Modified: trunk/build/patch/apr-util-1.2.12.patch
===================================================================
--- trunk/build/patch/apr-util-1.2.12.patch 2008-05-26 09:44:33 UTC (rev 1615)
+++ trunk/build/patch/apr-util-1.2.12.patch 2008-05-26 13:16:45 UTC (rev 1616)
@@ -1,5 +1,5 @@
---- apu.hw
-+++ apu.hw
+--- include/apu.hw
++++ include/apu.hw
@@ -101,7 +101,7 @@
#define APU_HAVE_SQLITE3 0
#define APU_HAVE_ORACLE 0
16 years, 9 months