JBoss Native SVN: r1645 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-30 12:14:03 -0400 (Fri, 30 May 2008)
New Revision: 1645
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Add the missing return (Thanks Mladen).
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-30 15:34:33 UTC (rev 1644)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-30 16:14:03 UTC (rev 1645)
@@ -265,6 +265,7 @@
if (!data) {
/* first call do nothing */
apr_pool_userdata_set((const void *)1, userdata_key, apr_pool_cleanup_null, s->process->pool);
+ return OK;
}
if (mconf->basefilename) {
16 years, 6 months
JBoss Native SVN: r1644 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-30 11:34:33 -0400 (Fri, 30 May 2008)
New Revision: 1644
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Well that is using prefork() but httpd will core otherwise.
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-30 13:02:54 UTC (rev 1643)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-30 15:34:33 UTC (rev 1644)
@@ -714,7 +714,11 @@
{
/* create the new connection if the previous was destroyed */
if (!worker->cp->conn) {
- connection_constructor((void **)&conn, worker, worker->cp->pool);
+ /* XXX: What appends is worker->cp->pool is NULL */
+ if (worker->cp->pool)
+ connection_constructor((void **)&conn, worker, worker->cp->pool);
+ else
+ rv = APR_ENOPOOL;
}
else {
conn = worker->cp->conn;
16 years, 6 months
JBoss Native SVN: r1643 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-30 09:02:54 -0400 (Fri, 30 May 2008)
New Revision: 1643
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Arrange the shared memory handling (problem reported by Mladen).
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-30 07:23:54 UTC (rev 1642)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-30 13:02:54 UTC (rev 1643)
@@ -258,7 +258,15 @@
char *context;
char *host;
char *balancer;
+ void *data;
+ const char *userdata_key = "mod_manager_init";
mod_manager_config *mconf = ap_get_module_config(s->module_config, &manager_module);
+ apr_pool_userdata_get(&data, userdata_key, s->process->pool);
+ if (!data) {
+ /* first call do nothing */
+ apr_pool_userdata_set((const void *)1, userdata_key, apr_pool_cleanup_null, s->process->pool);
+ }
+
if (mconf->basefilename) {
node = apr_pstrcat(ptemp, mconf->basefilename, ".node", NULL);
context = apr_pstrcat(ptemp, mconf->basefilename, ".context", NULL);
@@ -1091,6 +1099,54 @@
}
/*
+ * Attach to the shared memory when the child is created.
+ */
+static void manager_child_init(apr_pool_t *p, server_rec *s)
+{
+ char *node;
+ char *context;
+ char *host;
+ char *balancer;
+ mod_manager_config *mconf = ap_get_module_config(s->module_config, &manager_module);
+
+ if (mconf->basefilename) {
+ node = apr_pstrcat(p, mconf->basefilename, ".node", NULL);
+ context = apr_pstrcat(p, mconf->basefilename, ".context", NULL);
+ host = apr_pstrcat(p, mconf->basefilename, ".host", NULL);
+ balancer = apr_pstrcat(p, mconf->basefilename, ".balancer", NULL);
+ } else {
+ node = "manager.node";
+ context = "manager.context";
+ host = "manager.host";
+ host = "manager.balancer";
+ }
+
+ nodestatsmem = get_mem_node(node, &mconf->maxnode, p, storage);
+ if (nodestatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "get_mem_node %s failed", node);
+ return;
+ }
+
+ contextstatsmem = get_mem_context(context, &mconf->maxcontext, p, storage);
+ if (contextstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "get_mem_context failed");
+ return;
+ }
+
+ hoststatsmem = get_mem_host(host, &mconf->maxhost, p, storage);
+ if (hoststatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "get_mem_host failed");
+ return;
+ }
+
+ balancerstatsmem = get_mem_balancer(balancer, &mconf->maxhost, p, storage);
+ if (balancerstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "get_mem_balancer failed");
+ return;
+ }
+}
+
+/*
* Supported directives.
*/
AP_DECLARE_NONSTD(const char *) cmd_manager_maxcontext(cmd_parms *cmd, void *mconfig, const char *word)
@@ -1172,6 +1228,9 @@
/* Create the shared tables for mod_proxy_cluster */
ap_hook_post_config(manager_init, NULL, NULL, APR_HOOK_MIDDLE);
+ /* Attach to the shared tables with create the child */
+ ap_hook_child_init(manager_child_init, NULL, NULL, APR_HOOK_MIDDLE);
+
/* post read_request handling: to be handle to use ProxyPass / */
ap_hook_translate_name(manager_trans, NULL, aszSucc,
APR_HOOK_FIRST);
16 years, 6 months
JBoss Native SVN: r1642 - sandbox/aloha/httpd/modules/manager.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-30 03:23:54 -0400 (Fri, 30 May 2008)
New Revision: 1642
Removed:
sandbox/aloha/httpd/modules/manager/mm_node.c
Modified:
sandbox/aloha/httpd/modules/manager/mm_app.c
sandbox/aloha/httpd/modules/manager/mm_asmm.c
sandbox/aloha/httpd/modules/manager/mm_asmm.h
sandbox/aloha/httpd/modules/manager/mm_util.c
Log:
Some code cleanup
Modified: sandbox/aloha/httpd/modules/manager/mm_app.c
===================================================================
--- sandbox/aloha/httpd/modules/manager/mm_app.c 2008-05-29 14:34:51 UTC (rev 1641)
+++ sandbox/aloha/httpd/modules/manager/mm_app.c 2008-05-30 07:23:54 UTC (rev 1642)
@@ -41,6 +41,8 @@
static const char *memberapp_params[] = {
"",
+ "Member",
+ "Host",
"State",
/* Statistical data */
"Busy",
@@ -77,21 +79,30 @@
return NULL;
}
-static mmdb_app_pool_t *get_app_pool(const char *value, apr_uint32_t *id)
+static const char *get_member_name(apr_uint32_t id)
{
- apr_uint32_t next = 0;
- mmdb_app_pool_t *app_pool;
- asmm_slotmem_t *app_pool_db = mmdb_table_getn(MMDB_APP_POOL);
+ mmdb_member_t *member;
+ asmm_slotmem_t *member_db = mmdb_table_getn(MMDB_MEMBER);
- while ((app_pool = asmm_slot_next(app_pool_db, &next))) {
- if (strcasecmp(value, app_pool->name))
- continue;
- *id = next - 1;
- return app_pool;
+ if ((member = asmm_slot(member_db, id))) {
+ return member->name;
}
return NULL;
}
+static void del_app_members(apr_uint32_t app_id)
+{
+ apr_uint32_t next = 0;
+ mmdb_memberapp_t *memberapp;
+ asmm_slotmem_t *memberapp_db = mmdb_table_getn(MMDB_MEMBERAPP);
+
+ while ((memberapp = asmm_slot_next(memberapp_db, &next))) {
+ if (memberapp->app_id != app_id)
+ continue;
+ asmm_free(memberapp_db, memberapp);
+ }
+}
+
static void rdo_app_info_print(int pi, int pp,
mmdb_app_t *app,
request_rec *r)
@@ -117,31 +128,38 @@
static void rdo_memberapp_info_print(int pi, int pp,
mmdb_memberapp_t *mem,
+ mmdb_app_t *app,
request_rec *r)
{
if (pp) {
ap_rvputs(r, memberapp_params[pi], "=", NULL);
}
switch (pi) {
- case 1: /* State */
+ case 1: /* Member */
+ ap_rvputs(r, get_member_name(mem->member_id), NULL);
+ break;
+ case 2: /* Host */
+ ap_rvputs(r, get_host_name(app->host_id), NULL);
+ break;
+ case 3: /* State */
ap_rputs(mm_state_name_get(mem->state), r);
break;
- case 2: /* Busy */
+ case 4: /* Busy */
ap_rprintf(r, "%u", mem->busy);
break;
- case 3: /* Transactions */
+ case 5: /* Transactions */
ap_rprintf(r, "%u", mem->transactions);
break;
- case 4: /* ClientErrors */
+ case 6: /* ClientErrors */
ap_rprintf(r, "%u", mem->err_client);
break;
- case 5: /* NodeErrors */
+ case 7: /* NodeErrors */
ap_rprintf(r, "%u", mem->err_node);
break;
- case 6: /* Readed */
+ case 8: /* Readed */
ap_rprintf(r, "%" APR_UINT64_T_FMT, mem->readed);
break;
- case 7: /* Transferred */
+ case 9: /* Transferred */
ap_rprintf(r, "%" APR_UINT64_T_FMT, mem->transferred);
break;
}
@@ -230,6 +248,7 @@
int cmd_offset,
int wcm,
mmdb_memberapp_t *mem,
+ mmdb_app_t *app,
request_rec *r)
{
int cnt = 0;
@@ -267,7 +286,7 @@
}
else if (cnt == 1 && m) {
/* Single param */
- rdo_memberapp_info_print(m, wcm, mem, r);
+ rdo_memberapp_info_print(m, wcm, mem, app, r);
ap_rputs(CRLF, r);
}
else {
@@ -281,7 +300,7 @@
MM_FFNMATCH) == APR_SUCCESS) {
if (sep++)
ap_rputs("; ", r);
- rdo_memberapp_info_print(j, 1, mem, r);
+ rdo_memberapp_info_print(j, 1, mem, app, r);
}
j++;
}
@@ -291,7 +310,7 @@
if (!strcasecmp(ce[i].key, memberapp_params[j])) {
if (sep++)
ap_rputs("; ", r);
- rdo_memberapp_info_print(j, 1, mem, r);
+ rdo_memberapp_info_print(j, 1, mem, app, r);
break;
}
j++;
@@ -321,11 +340,16 @@
if (app_pool->applications)
app_pool->applications--;
}
- if ((app_pool = get_app_pool(value, &app_pool_id))) {
- app->state = mm_state_get(value);
+ if ((app_pool = asmm_slot_search(mmdb_table_getn(MMDB_APP_POOL),
+ value, 1,
+ offsetof(mmdb_app_pool_t, name),
+ &app_pool_id))) {
+ app->app_pool_id = app_pool_id;
if (app_pool_id)
app_pool->applications++;
}
+ else
+ return MME_ENODEV;
break;
case 3: /* State */
app->state = mm_state_get(value);
@@ -350,7 +374,7 @@
request_rec *r)
{
switch (pi) {
- case 1: /* State */
+ case 3: /* State */
mem->state = mm_state_get(value);
break;
default:
@@ -466,7 +490,10 @@
{
int wdone = 0;
int cblind = 0;
+ int cnt = 0;
int wcm;
+ const apr_array_header_t *ca = apr_table_elts(cmd_table);
+ apr_table_entry_t *ce = (apr_table_entry_t *)ca->elts;
apr_uint32_t next = 0;
apr_uint32_t mapp = 0;
@@ -524,6 +551,7 @@
if (*name != '~')
wcm = apr_fnmatch_test(name);
while ((app = asmm_slot_next(app_db, &next))) {
+ /* Count the number of matches */
if (wcm) {
if (apr_fnmatch(name, app->url,
cblind ? MM_FFNMATCH : 0) != APR_SUCCESS)
@@ -531,6 +559,17 @@
}
else if (cblind ? strcasecmp(name, app->url) : strcmp(name, app->url))
continue;
+ cnt++;
+ }
+ next = 0;
+ while ((app = asmm_slot_next(app_db, &next))) {
+ if (wcm) {
+ if (apr_fnmatch(name, app->url,
+ cblind ? MM_FFNMATCH : 0) != APR_SUCCESS)
+ continue;
+ }
+ else if (cblind ? strcasecmp(name, app->url) : strcmp(name, app->url))
+ continue;
if (host) {
if (prev_id != app->host_id)
continue;
@@ -538,10 +577,16 @@
*/
switch (cmd) {
case mm_mcmp_info:
- if (wcm)
+ if (cnt > 1) {
ap_rvputs(r, "@" MM_RES_APPLICATION "/",
- app->url, ": ", NULL);
- rdo_app_info(cmd_table, cmd_offset, wcm, app, r);
+ app->url, NULL);
+ if (cmd_offset < ca->nelts)
+ ap_rputs(": ", r);
+ else
+ ap_rputs(CRLF, r);
+ }
+ if (cmd_offset < ca->nelts)
+ rdo_app_info(cmd_table, cmd_offset, cnt - 1, app, r);
break;
case mm_mcmp_config:
if (rdo_app_config(cfg, cmd_table, cmd_offset,
@@ -558,6 +603,28 @@
app->state = mm_state_stopped;
break;
case mm_mcmp_delete:
+ if (app->state != mm_state_stopped) {
+ /* Application must be stopped before */
+ mm_send_response_ex(r, mm_response_error, MME_EBUSY, NULL);
+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
+ "mod_manager: Application not stopped: %s",
+ app->url);
+ return APR_SUCCESS;
+ }
+ else {
+ /* Delete Application and MemberApplication entries */
+ if (app->app_pool_id > 0 ) {
+ /* Unreference from ApplicationPool */
+ if ((app_pool = asmm_slot(app_pool_db,
+ app->app_pool_id))) {
+ if (app_pool->applications)
+ app_pool->applications--;
+ }
+ }
+ del_app_members(next - 1);
+ asmm_free(app_db, app);
+ }
+ break;
default:
mm_send_response_ex(r, mm_response_error, MME_EPERM, NULL);
ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
@@ -585,11 +652,17 @@
}
switch (cmd) {
case mm_mcmp_info:
- if (wcm)
+ if (cnt > 1) {
ap_rvputs(r, "@" MM_RES_APPLICATION "/",
- app->url, ": ", NULL);
- rdo_memberapp_info(cmd_table, cmd_offset, wcm,
- memberapp, r);
+ app->url, NULL);
+ if (cmd_offset < ca->nelts)
+ ap_rputs(": ", r);
+ else
+ ap_rputs(CRLF, r);
+ }
+ if (cmd_offset < ca->nelts)
+ rdo_memberapp_info(cmd_table, cmd_offset, cnt - 1,
+ memberapp, app, r);
break;
case mm_mcmp_config:
if (rdo_memberapp_config(cfg, cmd_table, cmd_offset,
@@ -653,8 +726,12 @@
}
}
wdone++;
- if (!wcm)
- break;
+ /* Multiple Applications with the same name
+ * can exist in the database (belonging to different Hosts).
+ * Match them all instead breaking up on the first match.
+ * if (!wcm)
+ * break;
+ */
}
if (!wdone && host) {
if (cmd == mm_mcmp_config && !wcm) {
Modified: sandbox/aloha/httpd/modules/manager/mm_asmm.c
===================================================================
--- sandbox/aloha/httpd/modules/manager/mm_asmm.c 2008-05-29 14:34:51 UTC (rev 1641)
+++ sandbox/aloha/httpd/modules/manager/mm_asmm.c 2008-05-30 07:23:54 UTC (rev 1642)
@@ -1557,3 +1557,42 @@
apr_set_os_error(APR_EOF);
return NULL;
}
+
+void *asmm_slot_find(asmm_slotmem_t *mem,
+ const void *key,
+ int (*compare )(const void *, const void *),
+ apr_uint32_t *slot)
+{
+ apr_uint32_t i, section = 0;
+ apr_byte_t *data = NULL;
+ asmm_mem_node_t *node;
+ asmm_mem_data_t *bmp;
+
+ if (!mem) {
+ apr_set_os_error(APR_ENOMEM);
+ return NULL;
+ }
+ bmp = mem->sections;
+ if (bmp && bmp->hdr->flags & ASMM_DIRTY) {
+ apr_set_os_error(APR_EBADF);
+ return NULL;
+ }
+ while (bmp) {
+ for (i = 0; i < bmp->hdr->nblocks; i++) {
+ data = bmp->data + i * bmp->hdr->blksize;
+ node = (asmm_mem_node_t *)data;
+ if (node->size) {
+ void *sd = data + sizeof(asmm_mem_node_t);
+ if ((*compare)(key, sd) == 0) {
+ if (slot)
+ *slot = i + section * bmp->hdr->nblocks;
+ return sd;
+ }
+ }
+ }
+ bmp = bmp->next;
+ section++;
+ }
+ apr_set_os_error(APR_EOF);
+ return NULL;
+}
Modified: sandbox/aloha/httpd/modules/manager/mm_asmm.h
===================================================================
--- sandbox/aloha/httpd/modules/manager/mm_asmm.h 2008-05-29 14:34:51 UTC (rev 1641)
+++ sandbox/aloha/httpd/modules/manager/mm_asmm.h 2008-05-30 07:23:54 UTC (rev 1642)
@@ -275,6 +275,22 @@
apr_uint32_t *slot);
/**
+ * Search for memory slot
+ * @param mem The slotmem descriptor to use.
+ * @param key The memory key to find.
+ * @param compare Compare function used for search.
+ * The first parameter is a pointer to the key for the search
+ * and the second parameter is a pointer to the array element
+ * to be compared with the key. Compare function must return 0
+ * if there is a match.
+ * @param slot On success the slot number.
+ */
+void *asmm_slot_find(asmm_slotmem_t *mem,
+ const void *key,
+ int (*compare )(const void *, const void *),
+ apr_uint32_t *slot);
+
+/**
* Get memory address
* @param mem The slotmem descriptor to use.
* @param index Allocated memory index
Deleted: sandbox/aloha/httpd/modules/manager/mm_node.c
===================================================================
--- sandbox/aloha/httpd/modules/manager/mm_node.c 2008-05-29 14:34:51 UTC (rev 1641)
+++ sandbox/aloha/httpd/modules/manager/mm_node.c 2008-05-30 07:23:54 UTC (rev 1642)
@@ -1,766 +0,0 @@
-/*
- * ModManager - JBoss Aloha
- *
- * Copyright(c) 2008 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 Mladen Turk
- */
-
-/* Manager Node object resource routines */
-#include "mm_api.h"
-
-static mm_resource_provider_t *this_provider = NULL;
-static int server_limit = 0;
-static int thread_limit = 0;
-static int max_clients = 0;
-static int max_childs = 0;
-static int max_requests_per_child = 0;
-static int max_threads_per_child = 0;
-
-static const char *member_params[] = {
- "",
- "Balancer",
- "Type",
- "Address",
- "Port",
- "Route",
- "Domain",
- "Ping",
- "MaxConnections",
- "MinConnections",
- "MaxClients",
- "TTL",
- "LF",
- "Distance",
- "Activation",
- "FlushMode",
- "FlushTimeout",
- /* Statistical data */
- "State",
- "Error",
- "Busy",
- "Connected",
- "Elected",
- "StickySessions",
- "ClientErrors",
- "NodeErrors",
- "Trace",
- "TraceErrors",
- "Readed",
- "Transferred",
- NULL
-};
-
-static const char *get_balancer_name(apr_uint32_t id)
-{
- mmdb_balancer_t *balancer;
- asmm_slotmem_t *balancer_db = mmdb_table_getn(MMDB_BALANCER);
-
- if ((balancer = asmm_slot(balancer_db, id))) {
- return balancer->name;
- }
- return NULL;
-}
-
-static const char *get_flush_name(mm_flush_mode_e mode)
-{
- switch(mode) {
- case mm_flush_wait:
- return "T";
- break;
- case mm_flush_auto:
- return "A";
- break;
- }
- return "N";
-}
-
-static mm_flush_mode_e get_flush_mode(const char *mode)
-{
- switch(apr_toupper(*mode)) {
- case 'T':
- return mm_flush_wait;
- break;
- case 'A':
- return mm_flush_auto;
- break;
- }
- return mm_flush_none;
-}
-
-static apr_status_t add_app_members(apr_uint32_t member_id,
- apr_uint32_t balancer_id)
-{
- apr_uint32_t napp = 0;
- apr_uint32_t nhost = 0;
- mmdb_host_t *host;
- mmdb_app_t *app;
- mmdb_memberapp_t *memberapp;
- asmm_slotmem_t *host_db = mmdb_table_getn(MMDB_HOST);
- asmm_slotmem_t *app_db = mmdb_table_getn(MMDB_APPLICATION);
- asmm_slotmem_t *memberapp_db = mmdb_table_getn(MMDB_MEMBERAPP);
-
- while ((host = asmm_slot_next(host_db, &nhost))) {
- if (host->balancer_id != balancer_id)
- continue;
- napp = 0;
- while ((app = asmm_slot_next(app_db, &napp))) {
- if (app->host_id != (nhost - 1))
- continue;
- if (!(memberapp = asmm_salloc(memberapp_db)))
- return apr_get_os_error();
- memberapp->app_id = napp - 1;
- memberapp->member_id = member_id;
- memberapp->state = app->state;
- }
- }
- return APR_SUCCESS;
-}
-
-static void del_app_members(apr_uint32_t member_id)
-{
- apr_uint32_t next = 0;
- mmdb_memberapp_t *memberapp;
- asmm_slotmem_t *memberapp_db = mmdb_table_getn(MMDB_MEMBERAPP);
-
- while ((memberapp = asmm_slot_next(memberapp_db, &next))) {
- if (memberapp->member_id != member_id)
- continue;
- asmm_free(memberapp_db, memberapp);
- }
-}
-
-
-static void rdo_member_info_print(int pi, int pp,
- mmdb_member_t *mem,
- request_rec *r)
-{
- char buf[512];
- const char *p;
-
- if (pp) {
- ap_rvputs(r, member_params[pi], "=", NULL);
- }
- switch (pi) {
- case 1: /* Balancer */
- ap_rvputs(r, get_balancer_name(mem->balancer_id), NULL);
- break;
- case 2: /* Type */
- ap_rputs(mm_protocol_name_get(mem->type), r);
- break;
- case 3: /* Address */
- ap_rvputs(r, mem->address, NULL);
- break;
- case 4: /* Port */
- ap_rprintf(r, "%u", mem->port);
- break;
- case 5: /* Route */
- ap_rvputs(r, mem->route, NULL);
- break;
- case 6: /* Domain */
- ap_rvputs(r, mem->domain, NULL);
- break;
- case 7: /* Ping */
- ap_rprintf(r, "%u", mem->ping);
- break;
- case 8: /* MaxConnections */
- ap_rprintf(r, "%u", mem->max_conn);
- break;
- case 9: /* MinConnections */
- ap_rprintf(r, "%u", mem->min_conn);
- break;
- case 10: /* MaxClients */
- ap_rprintf(r, "%u", mem->max_clients);
- break;
- case 11: /* TTL */
- ap_rprintf(r, "%u", mem->ttl);
- break;
- case 12: /* LF */
- ap_rprintf(r, "%u", mem->lf);
- break;
- case 13: /* Distance */
- ap_rprintf(r, "%u", mem->distance);
- break;
- case 14: /* Activation */
- ap_rputs(mm_state_name_get(mem->activation), r);
- break;
- case 15: /* FlushMode */
- ap_rputs(get_flush_name(mem->flush), r);
- break;
- case 16: /* FlushTimeout */
- ap_rprintf(r, "%" APR_TIME_T_FMT, apr_time_as_msec(mem->flush_wait));
- break;
- case 17: /* State */
- ap_rputs(mm_state_name_get(mem->state), r);
- break;
- case 18: /* Error */
- if (!(p = mm_strerror(mem->err))) {
- if (!(p = apr_strerror(mem->err, buf, sizeof(buf))))
- p = "Unknown Error";
- }
- if (pp)
- ap_rprintf(r, "\"%d: %s\"", mem->err, p);
- else
- ap_rprintf(r, "%d: %s", mem->err, p);
- break;
- case 19: /* Busy */
- ap_rprintf(r, "%u", mem->busy);
- break;
- case 20: /* Connected */
- ap_rprintf(r, "%u", mem->connected);
- break;
- case 21: /* Elected */
- ap_rprintf(r, "%u", mem->elected);
- break;
- case 22: /* StickySessions */
- ap_rprintf(r, "%u", mem->ssessions);
- break;
- case 23: /* ClientErrors */
- ap_rprintf(r, "%u", mem->err_client);
- break;
- case 24: /* NodeErrors */
- ap_rprintf(r, "%u", mem->err_node);
- break;
- case 25: /* Trace */
- ap_rprintf(r, "%u", mem->trace);
- break;
- case 26: /* TraceErrors */
- ap_rprintf(r, "%u", mem->err_trace);
- break;
- case 27: /* Readed */
- ap_rprintf(r, "%" APR_UINT64_T_FMT, mem->readed);
- break;
- case 28: /* Transferred */
- ap_rprintf(r, "%" APR_UINT64_T_FMT, mem->transferred);
- break;
- }
-}
-
-/* Dump Member info */
-static void rdo_member_info(apr_table_t *cmd_table,
- int cmd_offset,
- int wcm,
- mmdb_member_t *mem,
- request_rec *r)
-{
- int cnt = 0;
- int i, j, m = 0;
-
- const apr_array_header_t *ca = apr_table_elts(cmd_table);
- apr_table_entry_t *ce = (apr_table_entry_t *)ca->elts;
-
- /* Step 1: Figure out the number of requested params */
- for (i = cmd_offset; i < ca->nelts; i++) {
- j = 1;
- if (apr_fnmatch_test(ce[i].key)) {
- while (member_params[j]) {
- if (apr_fnmatch(ce[i].key, member_params[j],
- MM_FFNMATCH) == APR_SUCCESS) {
- cnt++;
- }
- j++;
- }
- }
- else {
- while (member_params[j]) {
- if (!strcasecmp(ce[i].key, member_params[j])) {
- m = j;
- cnt++;
- break;
- }
- j++;
- }
- }
- }
- if (!cnt) {
- /* No params. Just print OK */
- mm_send_response_ex(r, mm_response_ok, 0, NULL);
- }
- else if (cnt == 1 && m) {
- /* Single param */
- rdo_member_info_print(m, wcm, mem, r);
- ap_rputs(CRLF, r);
- }
- else {
- int sep = 0;
- /* Multiple params */
- for (i = cmd_offset; i < ca->nelts; i++) {
- j = 1;
- if (apr_fnmatch_test(ce[i].key)) {
- while (member_params[j]) {
- if (apr_fnmatch(ce[i].key, member_params[j],
- MM_FFNMATCH) == APR_SUCCESS) {
- if (sep++)
- ap_rputs("; ", r);
- rdo_member_info_print(j, 1, mem, r);
- }
- j++;
- }
- }
- else {
- while (member_params[j]) {
- if (!strcasecmp(ce[i].key, member_params[j])) {
- if (sep++)
- ap_rputs("; ", r);
- rdo_member_info_print(j, 1, mem, r);
- break;
- }
- j++;
- }
- }
- }
- if (sep)
- ap_rputs(CRLF, r);
- }
-}
-
-static apr_status_t rdo_member_config_do(int pi,
- const char *value,
- mmdb_member_t *mem,
- request_rec *r)
-{
- int i;
-
- switch (pi) {
- case 2: /* Type */
- if (mem->state == mm_state_stopped)
- mem->type = mm_protocol_get(value);
- else
- return MME_EPERM;
- break;
- case 3: /* Address */
- if (mem->state == mm_state_stopped)
- MM_SSAFE_COPY(mem->address, value);
- else
- return MME_EPERM;
- break;
- case 4: /* Port */
- if (mem->state == mm_state_stopped)
- mem->port = atoi(value);
- else
- return MME_EPERM;
- break;
- case 5: /* Route */
- MM_SSAFE_COPY(mem->route, value);
- break;
- case 6: /* Domain */
- MM_SSAFE_COPY(mem->domain, value);
- break;
- case 7: /* Ping */
- mem->ping = atoi(value);
- break;
- case 8: /* MaxConnections */
- i = atoi(value);
- if (i < 1 || i > max_threads_per_child)
- return MME_EINVAL;
- else
- mem->max_conn = i;
- break;
- case 9: /* MinConnections */
- i = atoi(value);
- if (i < 1 || i > (int)mem->max_conn)
- return MME_EINVAL;
- else
- mem->min_conn = i;
- break;
- case 10: /* MaxClients */
- i = atoi(value);
- if (i < 1 || i > max_clients)
- return MME_EINVAL;
- else
- mem->max_clients = i;
- break;
- case 11: /* TTL */
- mem->ttl = atoi(value);
- break;
- case 12: /* LF */
- mem->lf = atoi(value);
- break;
- case 13: /* Distance */
- mem->distance = atoi(value);
- break;
- case 14: /* Activation */
- mem->activation = mm_state_get(value);
- break;
- case 15: /* FlushMode */
- mem->flush = get_flush_mode(value);
- break;
- case 16: /* FlushTimeout */
- mem->flush_wait = atoi(value) * APR_TIME_C(1000);
- break;
- default:
- return MME_EPERM;
- break;
- }
- return APR_SUCCESS;
-}
-
-/* Configure Member */
-static int rdo_member_config(mm_server_conf_t *cfg,
- apr_table_t *cmd_table,
- int cmd_offset,
- apr_uint32_t member_id,
- mmdb_member_t *member,
- request_rec *r)
-{
- int cnt = 0;
- int i, j;
- apr_status_t rc;
-
- const apr_array_header_t *ca = apr_table_elts(cmd_table);
- apr_table_entry_t *ce = (apr_table_entry_t *)ca->elts;
-
- /* Step 1: Figure out the number of requested params */
- for (i = cmd_offset; i < ca->nelts; i++) {
- j = 1;
- if (apr_fnmatch_test(ce[i].key)) {
- /* Wildchar params not allowed for config */
- continue;
- }
- else {
- while (member_params[j]) {
- if (!strcasecmp(ce[i].key, member_params[j])) {
- if (!ce[i].val || !*(ce[i].val)) {
- /* Empty value */
- mm_send_response_ex(r, mm_response_error, MME_EINVAL,
- NULL);
- return 1;
- }
- if ((rc = rdo_member_config_do(j, ce[i].val,
- member, r)) != APR_SUCCESS) {
- /* Parameter value error */
- mm_send_response_ex(r, mm_response_error,
- rc, NULL);
- return 1;
- }
- cnt++;
- break;
- }
- j++;
- }
- }
- }
- return 0;
-}
-
-static apr_status_t rdo_member(mm_server_conf_t *cfg,
- mm_mcmp_command_e cmd,
- const char *name,
- mm_resource_provider_t *prev,
- apr_uint32_t prev_id,
- void *prev_rec,
- apr_table_t *cmd_table,
- int cmd_offset,
- request_rec *r)
-{
- int wdone = 0;
- int wcm;
- const apr_array_header_t *ca = apr_table_elts(cmd_table);
- apr_table_entry_t *ce = (apr_table_entry_t *)ca->elts;
- apr_uint32_t next = 0;
- mmdb_member_t *member;
-
- asmm_slotmem_t *member_db = mmdb_table_getn(MMDB_MEMBER);
-
- if (!member_db)
- return APR_ENOMEM;
- if (!name || !*name) {
- mm_send_response_ex(r, mm_response_error, MME_EINVAL, NULL);
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "mod_manager: [%s] empty member name",
- mm_mcmp_command_name_get(cmd));
- return APR_SUCCESS;
- }
- wcm = apr_fnmatch_test(name);
- while ((member = asmm_slot_next(member_db, &next))) {
- if (wcm) {
- if (apr_fnmatch(name, member->name,
- MM_FFNMATCH) != APR_SUCCESS)
- continue;
- }
- else if (strcasecmp(name, member->name))
- continue;
- if (cmd_offset < ca->nelts) {
- mm_resource_provider_t *mp = mm_lookup_resource_provider(ce[cmd_offset].key);
- if (mp) {
- apr_status_t rc;
- if (mp == this_provider) {
- mm_send_response_ex(r, mm_response_error, MME_EINVAL, NULL);
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "mod_manager: [%s] recursion not allowed: %s",
- mm_mcmp_command_name_get(cmd),
- this_provider->name);
- return APR_SUCCESS;
- }
- rc = (*mp->func)(cfg, cmd,
- ce[cmd_offset].val, this_provider,
- next - 1, member,
- cmd_table, cmd_offset + 1, r);
- if (rc != APR_SUCCESS) {
- }
- wdone++;
- if (wcm)
- continue;
- else
- break;
- }
- }
- switch (cmd) {
- case mm_mcmp_info:
- if (wcm) {
- ap_rvputs(r, MM_RES_MEMBER "/", member->name, NULL);
- if (cmd_offset < ca->nelts)
- ap_rputs(": ", r);
- else
- ap_rputs(CRLF, r);
- }
- if (cmd_offset < ca->nelts)
- rdo_member_info(cmd_table, cmd_offset, wcm, member, r);
- break;
- case mm_mcmp_enable:
- member->state = mm_state_active;
- member->activation = mm_state_active;
- break;
- case mm_mcmp_disable:
- member->state = mm_state_disabled;
- member->activation = mm_state_disabled;
- break;
- case mm_mcmp_stop:
- member->state = mm_state_stopped;
- member->activation = mm_state_stopped;
- break;
- case mm_mcmp_reset:
- /* Reset statistical data */
- member->elected = 0;
- member->ssessions = 0;
- member->err_client = 0;
- member->err_node = 0;
- member->err_trace = 0;
- member->trace = 0;
- member->readed = 0;
- member->transferred = 0;
- break;
- case mm_mcmp_delete:
- if (member->state != mm_state_stopped) {
- /* Member must be stopped before */
- mm_send_response_ex(r, mm_response_error, MME_EBUSY, NULL);
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "mod_manager: Member not stopped: %s",
- member->name);
- return APR_SUCCESS;
- }
- else {
- /* Delete Member entry */
- mmdb_balancer_t *pbal = NULL;
- if (member->balancer_id)
- pbal = asmm_slot(mmdb_table_getn(MMDB_MEMBER),
- member->balancer_id);
- del_app_members(next - 1);
- asmm_free(member_db, member);
- if (pbal && pbal->members)
- pbal->members--;
- }
- break;
- case mm_mcmp_config:
- if (prev && prev->id == MMDB_BALANCER) {
- mmdb_balancer_t *nbal = (mmdb_balancer_t *)prev_rec;
- if (prev_id != member->balancer_id) {
- mmdb_balancer_t *pbal = NULL;
- if (member->balancer_id)
- pbal = asmm_slot(mmdb_table_getn(MMDB_MEMBER),
- member->balancer_id);
- /* Attach the Member to another Balancer */
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "mod_manager: Member: %s assigned to "
- "Balancer: %s",
- member->name, nbal->name);
- member->balancer_id = prev_id;
- nbal->members++;
- if (pbal && pbal->members)
- pbal->members--;
- }
- }
- if (rdo_member_config(cfg, cmd_table, cmd_offset,
- next - 1, member, r))
- return APR_SUCCESS;
- break;
- default:
- mm_send_response_ex(r, mm_response_error, MME_EPERM, NULL);
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "mod_manager: [%s] not allowed for Balancer",
- mm_mcmp_command_name_get(cmd));
- return APR_SUCCESS;
- break;
-
- }
- wdone++;
- if (!wcm)
- break;
- }
- if (!wdone) {
- if (cmd == mm_mcmp_config && !wcm) {
- apr_uint32_t member_id;
- if (prev && prev->id != MMDB_BALANCER) {
- mm_send_response_ex(r, mm_response_utype, 0, prev->name, NULL);
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "mod_manager: type %s in not balancer for "
- "Member: %s",
- prev->name, name);
- return APR_SUCCESS;
- }
- if (!prev) {
- /* Use _default_ balancer */
- prev_id = 0;
- }
- /* Add new Member */
- if (!(member = asmm_salloc_ex(member_db, &member_id)))
- return apr_get_os_error();
- MM_SSAFE_COPY(member->name, name);
- member->balancer_id = prev_id;
- member->state = mm_state_stopped;
- member->activation = mm_state_stopped;
- member->lf = 1;
- member->max_conn = max_threads_per_child;
- member->min_conn = max_threads_per_child;
- member->max_clients = max_clients;
- /* Update Member from provided params */
- if (rdo_member_config(cfg, cmd_table, cmd_offset,
- member_id, member, r)) {
- /* There was an error during initial config
- * Delete member we created
- */
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "mod_manager: failed creating member: %s",
- name);
- asmm_free(member_db, member);
- return APR_SUCCESS;
- }
- if (!member->route[0])
- strcpy(member->route, member->name);
- if (!member->address[0])
- strcpy(member->address, MM_DEFAULT_ADDRESS);
- if (member->type == mm_protocol_unknown)
- member->type = MM_DEFAULT_PROTOCOL;
- if (!member->port) {
- switch (member->type) {
- case mm_protocol_ajp:
- member->port = MM_DEFAULT_AJP_PORT;
- break;
- case mm_protocol_http:
- member->port = MM_DEFAULT_HTTP_PORT;
- break;
- case mm_protocol_https:
- member->port = MM_DEFAULT_HTTPS_PORT;
- break;
- default:
- mm_send_response_ex(r, mm_response_error,
- MME_EINVAL, NULL);
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "mod_manager: Unknown protocol %d for "
- "Member: %s",
- member->type, member->name);
- asmm_free(member_db, member);
- return APR_SUCCESS;
- break;
- }
- }
- if (member->min_conn > member->max_conn)
- member->min_conn = member->max_conn;
- member->state = mm_state_stopped;
- /* Add Applications linked to the Member's Balancer */
- if (add_app_members(member_id, member->balancer_id) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
- "mod_manager: adding MemberApplication for: %s",
- member->name);
- del_app_members(member_id);
- asmm_free(member_db, member);
- return APR_SUCCESS;
- }
- if (prev_rec) {
- ((mmdb_balancer_t *)prev_rec)->members++;
- }
- }
- else {
- mm_send_response_ex(r, mm_response_utype, 0, MM_RES_MEMBER "/",
- name, NULL);
- ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
- "mod_manager: unknown member: %s", name);
- return APR_SUCCESS;
- }
- }
- switch (cmd) {
- case mm_mcmp_info:
- break;
- default:
- if (!prev)
- mm_send_response_ex(r, mm_response_ok, 0, NULL);
- break;
- }
- return APR_SUCCESS;
-}
-
-static apr_status_t rdo_member_init(mm_server_conf_t *cfg)
-{
-
- ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit);
- ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit);
- ap_mpm_query(AP_MPMQ_MAX_REQUESTS_DAEMON, &max_requests_per_child);
- ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_childs);
- if (max_childs < 1)
- max_childs = 1;
- ap_mpm_query(AP_MPMQ_MAX_THREADS, &max_threads_per_child);
- if (max_threads_per_child < 1)
- max_threads_per_child = 1;
- max_clients = max_childs * max_threads_per_child;
- return APR_SUCCESS;
-}
-
-static apr_status_t ini_member(mm_server_conf_t *cfg,
- mm_resource_op_e op,
- apr_pool_t *pool)
-{
- switch (op) {
- case mm_resource_init:
- case mm_resource_open:
- case mm_resource_child_init:
- return rdo_member_init(cfg);
- break;
- case mm_resource_close:
- /* Nothing to do for a Member */
- break;
- }
- return APR_SUCCESS;
-}
-
-static mm_resource_provider_t member_provider = {
- MMDB_MEMBER,
- MM_RES_MEMBER,
- rdo_member,
- ini_member,
- NULL
-};
-
-/* Exported register function */
-void mm_register_resource_member(apr_pool_t *pool)
-{
- this_provider = &member_provider;
- mm_register_resource_provider(pool, this_provider);
-}
Modified: sandbox/aloha/httpd/modules/manager/mm_util.c
===================================================================
--- sandbox/aloha/httpd/modules/manager/mm_util.c 2008-05-29 14:34:51 UTC (rev 1641)
+++ sandbox/aloha/httpd/modules/manager/mm_util.c 2008-05-30 07:23:54 UTC (rev 1642)
@@ -609,7 +609,7 @@
{ MMDB_MEMBER,
"Member",
sizeof(mmdb_member_t),
- 1,
+ 64,
ASMM_HAS_LOCK,
ASMM_UNLIMITED,
NULL,
16 years, 6 months
JBoss Native SVN: r1641 - 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-29 10:34:51 -0400 (Thu, 29 May 2008)
New Revision: 1641
Modified:
trunk/mod_cluster/native/include/node.h
trunk/mod_cluster/native/mod_manager/mod_manager.c
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
And parser of all the parameters defined in the wiki spec's.
Modified: trunk/mod_cluster/native/include/node.h
===================================================================
--- trunk/mod_cluster/native/include/node.h 2008-05-29 10:13:06 UTC (rev 1640)
+++ trunk/mod_cluster/native/include/node.h 2008-05-29 14:34:51 UTC (rev 1641)
@@ -60,9 +60,10 @@
/* node conf part */
int flushpackets;
int flushwait;
- int ping;
+ apr_time_t ping;
int smax;
- int ttl;
+ apr_time_t ttl;
+ apr_time_t timeout;
/* part updated in httpd */
int id; /* id in table and worker id */
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-29 10:13:06 UTC (rev 1640)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-29 14:34:51 UTC (rev 1641)
@@ -57,6 +57,7 @@
#define TYPESYNTAX 1
#define SMESPAR "SYNTAX: Can't parse message"
#define SBALBIG "SYNTAX: Balancer field too big"
+#define SBAFBIG "SYNTAX: A field is too big"
#define SROUBIG "SYNTAX: JVMRoute field too big"
#define SDOMBIG "SYNTAX: Domain field too big"
#define SHOSBIG "SYNTAX: Host field too big"
@@ -414,13 +415,18 @@
/*
* Process a CONFIG message
+ * Balancer: <Balancer name>
+ * <balancer configuration>
+ * StickySession StickySessionCookie StickySessionPath StickySessionRemove
+ * StickySessionForce Timeout Maxattempts
* JvmRoute?: <JvmRoute>
* Domain: <Domain>
* <Host: <Node IP>
* Port: <Connector Port>
* Type: <Type of the connector>
- * Reserved: <Use connection pool initiated by Tomcat *.
- * (<node conf>
+ * Reserved: <Use connection pool initiated by Tomcat *.>
+ * <node conf>
+ * flushpackets flushwait ping smax ttl
* Virtual hosts in JBossAS
* Alias: <vhost list>
* Context corresponding to the applications.
@@ -469,6 +475,7 @@
ap_mpm_query(AP_MPMQ_MAX_THREADS, &mpm_threads);
nodeinfo.mess.smax = mpm_threads + 1;
nodeinfo.mess.ttl = apr_time_from_sec(60);
+ nodeinfo.mess.timeout = 0;
/* Fill default balancer values */
memset(&balancerinfo, '\0', sizeof(balancerinfo));
@@ -477,6 +484,7 @@
strcpy(balancerinfo.StickySessionCookie, "JSESSIONID");
strcpy(balancerinfo.StickySessionPath, "jsessionid");
balancerinfo.Maxattempts = 1;
+ balancerinfo.Timeout = 0;
int i = 0;
while (ptr[i]) {
@@ -489,6 +497,39 @@
strcpy(nodeinfo.mess.balancer, ptr[i+1]);
strcpy(balancerinfo.balancer, ptr[i+1]);
}
+ if (strcasecmp(ptr[i], "StickySession") == 0) {
+ if (strcasecmp(ptr[i+1], "no") == 0)
+ balancerinfo.StickySession = 0;
+ }
+ if (strcasecmp(ptr[i], "StickySessionCookie") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(balancerinfo.StickySessionCookie)) {
+ *errtype = TYPESYNTAX;
+ return SBAFBIG;
+ }
+ strcpy(balancerinfo.StickySessionCookie, ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "StickySessionPath") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(balancerinfo.StickySessionPath)) {
+ *errtype = TYPESYNTAX;
+ return SBAFBIG;
+ }
+ strcpy(balancerinfo.StickySessionPath, ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "StickySessionRemove") == 0) {
+ if (strcasecmp(ptr[i+1], "yes") == 0)
+ balancerinfo.StickySession = 1;
+ }
+ if (strcasecmp(ptr[i], "StickySessionForce") == 0) {
+ if (strcasecmp(ptr[i+1], "no") == 0)
+ balancerinfo.StickySessionForce = 0;
+ }
+ if (strcasecmp(ptr[i], "WaitWorker") == 0) {
+ balancerinfo.Timeout = apr_time_from_sec(atoi(ptr[i+1]));
+ }
+ if (strcasecmp(ptr[i], "Maxattempts") == 0) {
+ balancerinfo.Maxattempts = atoi(ptr[i+1]);
+ }
+
/* XXX: Node part */
if (strcasecmp(ptr[i], "JVMRoute") == 0) {
if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.JVMRoute)) {
@@ -530,6 +571,31 @@
nodeinfo.mess.reversed = 1;
}
}
+ if (strcasecmp(ptr[i], "flushpackets") == 0) {
+ if (strcasecmp(ptr[i+1], "on") == 0) {
+ nodeinfo.mess.flushpackets = flush_on;
+ }
+ else if (strcasecmp(ptr[i+1], "auto") == 0) {
+ nodeinfo.mess.flushpackets = flush_auto;
+ }
+ }
+ if (strcasecmp(ptr[i], "flushwait") == 0) {
+ nodeinfo.mess.flushwait = atoi(ptr[i+1]) * 1000;
+ }
+ if (strcasecmp(ptr[i], "ping") == 0) {
+ nodeinfo.mess.ping = apr_time_from_sec(atoi(ptr[i+1]));
+ }
+ if (strcasecmp(ptr[i], "smax") == 0) {
+ nodeinfo.mess.smax = atoi(ptr[i+1]);
+ }
+ if (strcasecmp(ptr[i], "ttl") == 0) {
+ nodeinfo.mess.ttl = apr_time_from_sec(atoi(ptr[i+1]));
+ }
+ if (strcasecmp(ptr[i], "Timeout") == 0) {
+ nodeinfo.mess.timeout = apr_time_from_sec(atoi(ptr[i+1]));
+ }
+
+ /* Hosts and contexts (optional paramters) */
if (strcasecmp(ptr[i], "Alias") == 0) {
if (phost->host && !phost->context) {
*errtype = TYPESYNTAX;
@@ -597,9 +663,11 @@
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",
+ ap_rprintf(r, "balancer: [%d] Name: %s Sticky: %d [%s]/[%s] remove: %d force: %d Timeout: %d Maxtry: %d\n",
id[i], ou->balancer, ou->StickySession,
- ou->StickySessionCookie, ou->StickySessionPath);
+ ou->StickySessionCookie, ou->StickySessionPath,
+ ou->StickySessionRemove, ou->StickySessionForce, ou->Timeout,
+ ou->Maxattempts);
}
size = get_max_size_node(nodestatsmem);
@@ -608,9 +676,11 @@
for (i=0; i<size; i++) {
nodeinfo_t *ou;
get_node(nodestatsmem, &ou, id[i]);
- ap_rprintf(r, "node: [%d:%d] Balancer: %s JVMRoute: %s Domain: [%s] Host: %s Port: %s Type: %s\n",
+ ap_rprintf(r, "node: [%d:%d] Balancer: %s JVMRoute: %s Domain: [%s] Host: %s Port: %s Type: %s flushpackets: %d flushwait: %d ping: %d smax: %d ttl: %d timeout: %d\n",
id[i], ou->mess.id, ou->mess.balancer, ou->mess.JVMRoute, ou->mess.Domain,
- ou->mess.Host, ou->mess.Port, ou->mess.Type);
+ ou->mess.Host, ou->mess.Port, ou->mess.Type,
+ ou->mess.flushpackets, ou->mess.flushwait/1000, apr_time_sec(ou->mess.ping), ou->mess.smax,
+ apr_time_sec(ou->mess.ttl), apr_time_sec(ou->mess.timeout));
}
size = get_max_size_host(hoststatsmem);
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:13:06 UTC (rev 1640)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-29 14:34:51 UTC (rev 1641)
@@ -111,6 +111,10 @@
(*worker)->redirect = apr_pstrdup(conf->pool, "");
(*worker)->smax = node->mess.smax;
(*worker)->ttl = node->mess.ttl;
+ if (node->mess.timeout) {
+ (*worker)->timeout_set = 1;
+ (*worker)->timeout = node->mess.timeout;
+ }
(*worker)->flush_packets = node->mess.flushpackets;
(*worker)->flush_wait = node->mess.flushwait;
(*worker)->ping_timeout = node->mess.ping;
16 years, 6 months
JBoss Native SVN: r1640 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
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);
16 years, 7 months
JBoss Native SVN: r1639 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-29 06:11:44 -0400 (Thu, 29 May 2008)
New Revision: 1639
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Add default values.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-29 08:27:13 UTC (rev 1638)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-29 10:11:44 UTC (rev 1639)
@@ -36,6 +36,8 @@
#include "http_protocol.h"
#include "http_core.h"
#include "scoreboard.h"
+#include "mod_proxy.h"
+#include "ap_mpm.h"
#include "mod_proxy_cluster.h"
@@ -429,6 +431,7 @@
/* Process the node/balancer description */
nodeinfo_t nodeinfo;
balancerinfo_t balancerinfo;
+ int mpm_threads;
char *JVMRoute;
char *Domain;
char *Host;
@@ -459,6 +462,13 @@
strcpy(nodeinfo.mess.Port, "8009");
strcpy(nodeinfo.mess.Type, "ajp");
nodeinfo.mess.reversed = 0;
+ nodeinfo.mess.remove = 0; /* not marked as removed */
+ nodeinfo.mess.flushpackets = flush_off; /* FLUSH_OFF; See enum flush_packets in proxy.h flush_off */
+ nodeinfo.mess.flushwait = PROXY_FLUSH_WAIT;
+ nodeinfo.mess.ping = apr_time_from_sec(10);
+ ap_mpm_query(AP_MPMQ_MAX_THREADS, &mpm_threads);
+ nodeinfo.mess.smax = mpm_threads + 1;
+ nodeinfo.mess.ttl = apr_time_from_sec(60);
/* Fill default balancer values */
memset(&balancerinfo, '\0', sizeof(balancerinfo));
16 years, 7 months
JBoss Native SVN: r1638 - sandbox/aloha/httpd/modules/manager.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-29 04:27:13 -0400 (Thu, 29 May 2008)
New Revision: 1638
Modified:
sandbox/aloha/httpd/modules/manager/mm_module.c
Log:
Run database maintenance in child
Modified: sandbox/aloha/httpd/modules/manager/mm_module.c
===================================================================
--- sandbox/aloha/httpd/modules/manager/mm_module.c 2008-05-29 08:20:30 UTC (rev 1637)
+++ sandbox/aloha/httpd/modules/manager/mm_module.c 2008-05-29 08:27:13 UTC (rev 1638)
@@ -500,6 +500,11 @@
apr_sleep(MM_TM_RESOLUTION);
if (!is_mc_running)
break;
+ /* Maintain database.
+ * Attach new memory segments if added by parent
+ */
+ mmdb_maintain(s);
+
if (++step >= MM_TM_MAINTAIN_STEP) {
mm_maintain_callback_run(mm_maintain_full);
step = 0;
16 years, 7 months
JBoss Native SVN: r1637 - sandbox/aloha/httpd/modules/manager.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-29 04:20:30 -0400 (Thu, 29 May 2008)
New Revision: 1637
Modified:
sandbox/aloha/httpd/modules/manager/mm_asmm.c
Log:
Add sections on maintain instead close/open
Modified: sandbox/aloha/httpd/modules/manager/mm_asmm.c
===================================================================
--- sandbox/aloha/httpd/modules/manager/mm_asmm.c 2008-05-29 07:50:46 UTC (rev 1636)
+++ sandbox/aloha/httpd/modules/manager/mm_asmm.c 2008-05-29 08:20:30 UTC (rev 1637)
@@ -649,7 +649,7 @@
static apr_status_t add_slotmem_segment(asmm_slotmem_t *mem)
{
- apr_status_t rv;
+ apr_status_t rv = APR_SUCCESS;
apr_uint16_t n;
asmm_mem_data_t *bmp = NULL;
asmm_mem_data_t *p = NULL;
@@ -852,14 +852,25 @@
apr_status_t asmm_slotmem_maintain(asmm_slotmem_t *mem)
{
apr_status_t rv = APR_SUCCESS;
- if (mem && mem->sections->hdr->flags & ASMM_NEW_SECTION) {
- if (mem->lock)
- (void)apr_global_mutex_lock(mem->lock);
- rv = new_slotmem_segment(mem);
- mem->sections->hdr->flags &= ~ASMM_NEW_SECTION;
- if (mem->lock)
- (void)apr_global_mutex_unlock(mem->lock);
+
+ if (!mem || !mem->sections)
+ return APR_ENOMEM;
+ if (mem->maxsections) {
+ if (mem->sections->hdr->flags & ASMM_NEW_SECTION) {
+ _ASMM_VLOCK(mem);
+ rv = new_slotmem_segment(mem);
+ mem->sections->hdr->flags &= ~ASMM_NEW_SECTION;
+ _ASMM_UNLOCK(mem);
+ }
}
+ else {
+ /* Opened memory */
+ if (mem->sections->hdr->timestamp != mem->timestamp) {
+ _ASMM_VLOCK(mem);
+ rv = add_slotmem_segment(mem);
+ _ASMM_UNLOCK(mem);
+ }
+ }
return rv;
}
16 years, 7 months
JBoss Native SVN: r1636 - sandbox/aloha/docs/html.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-29 03:50:46 -0400 (Thu, 29 May 2008)
New Revision: 1636
Modified:
sandbox/aloha/docs/html/index.html
Log:
Add link to blank page
Modified: sandbox/aloha/docs/html/index.html
===================================================================
--- sandbox/aloha/docs/html/index.html 2008-05-29 07:40:36 UTC (rev 1635)
+++ sandbox/aloha/docs/html/index.html 2008-05-29 07:50:46 UTC (rev 1636)
@@ -6,6 +6,8 @@
<meta value="mturk(a)redhat.com" name="email"/>
</head>
<body>
- This page intentionally left blank.
+ <img src="./images/jboss_logo.gif">
+ <br/><br/><br/>
+ <h2><a href="modcluster.html">ModCluster - Documentation</a></h2>
</body>
</html>
\ No newline at end of file
16 years, 7 months