Author: jfrederic.clere(a)jboss.com
Date: 2008-05-29 06:13:06 -0400 (Thu, 29 May 2008)
New Revision: 1640
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Arrange remove node and create.
Add default value for create.
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-29 10:11:44 UTC
(rev 1639)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-29 10:13:06 UTC
(rev 1640)
@@ -107,22 +107,34 @@
(*worker)->s = (proxy_worker_stat *) ptr;
(*worker)->id = node->mess.id;
+ (*worker)->route = apr_pstrdup(conf->pool, node->mess.JVMRoute);
+ (*worker)->redirect = apr_pstrdup(conf->pool, "");
+ (*worker)->smax = node->mess.smax;
+ (*worker)->ttl = node->mess.ttl;
+ (*worker)->flush_packets = node->mess.flushpackets;
+ (*worker)->flush_wait = node->mess.flushwait;
+ (*worker)->ping_timeout = node->mess.ping;
+ (*worker)->ping_timeout_set = 1;
+ (*worker)->keepalive = 1;
+ (*worker)->keepalive_set = 1;
+ (*worker)->is_address_reusable = 1;
+
/*
- * XXX: The Shared datastatus may already contains a valid information
+ * The Shared datastatus may already contains a valid information
*/
- if (!(*worker)->s->status)
+ if (!(*worker)->s->status) {
(*worker)->s->status = PROXY_WORKER_INITIALIZED;
+ 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';
+ }
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
*/
@@ -193,8 +205,6 @@
/* 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 */
@@ -846,6 +856,26 @@
proxy_node_isup
};
+/*
+ * Remove node that have beeen marked removed for more than 10 seconds.
+ */
+static void remove_removed_node(apr_pool_t *pool)
+{
+ int *id, size, i;
+ apr_time_t now = apr_time_now();
+
+ /* read the ident of the nodes */
+ id = apr_pcalloc(pool, sizeof(int) * node_storage->get_max_size_node());
+ size = node_storage->get_ids_used_node(id);
+ for (i=0; i<size; i++) {
+ nodeinfo_t *ou;
+ node_storage->read_node(id[i], &ou);
+ if (ou->mess.remove && (now - ou->updatetime) >=
apr_time_from_sec(10)) {
+ /* remove the node from the shared memory */
+ node_storage->remove_node(ou);
+ }
+ }
+}
static void * APR_THREAD_FUNC proxy_cluster_watchdog_func(apr_thread_t *thd, void *data)
{
apr_pool_t *pool;
@@ -856,9 +886,11 @@
for (;;) {
apr_sleep(apr_time_make(0, 1000));
+ apr_pool_create(&pool, conf->pool);
/* Create new workers if the shared memory changes */
- apr_pool_create(&pool, conf->pool);
update_workers_node(conf, pool, s);
+ /* cleanup removed node in shared memory */
+ remove_removed_node(pool);
apr_pool_destroy(pool);
}
apr_thread_exit(thd, 0);
Show replies by date