Author: jfrederic.clere(a)jboss.com
Date: 2008-03-13 09:38:07 -0400 (Thu, 13 Mar 2008)
New Revision: 1436
Modified:
sandbox/httpd/src/native/mod_manager/mod_manager.c
Log:
Adapt the code to the handler logic.
Modified: sandbox/httpd/src/native/mod_manager/mod_manager.c
===================================================================
--- sandbox/httpd/src/native/mod_manager/mod_manager.c 2008-03-13 13:37:06 UTC (rev 1435)
+++ sandbox/httpd/src/native/mod_manager/mod_manager.c 2008-03-13 13:38:07 UTC (rev 1436)
@@ -142,44 +142,20 @@
*/
return OK;
}
-static manager_process_connection(conn_rec *c)
+/* Process the requests from the ModClusterService */
+static int manager_handler(request_rec *r)
{
- mod_manager_config *mconf = ap_get_module_config(c->base_server->module_config,
&manager_module);
- apr_socket_t *client_socket = ap_get_module_config(c->conn_config,
&core_module);
- node_mess locnode;
- apr_status_t rv;
- apr_size_t len;
- char *balancer;
-
- if (!mconf->enable) {
+ apr_bucket_brigade *input_brigade;
+ char buff[4096];
+ int bufsiz=sizeof(buff);
+ if (strcmp(r->handler, "mod-cluster"))
return DECLINED;
- }
- /* XXX: Check that the node is allowed to send to httpd */
-
- /* get the balancer corresponding to the port */
- balancer = getbalancer(c->base_server, mconf->baldata, c->local_addr);
- if (balancer)
- strcpy((char *)&locnode.node.balancer, balancer);
- else
- locnode.node.balancer[0] = '\0';
-
- /* read the data from jboss node (that fills only the first part of the structure)
*/
- len = 128; /* sizeof(locnode) quick hack use the java test program */
- while (rv = apr_socket_recv(client_socket, (char *) &locnode, &len) ==
APR_SUCCESS) {
- len = 128; /* sizeof(locnode); */
- switch (htonl(locnode.type)) {
- case 1: /* "I am alive message" from TC */
- rv = insert_update_node(nodestatsmem, &locnode.node);
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0,
c->base_server,
- "manager_process_connection insert_update_node
failed");
- }
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, c->base_server,
"manager_process_connection unknown message %d", htonl(locnode.type));
- }
- }
- return OK;
+ 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));
+ apr_brigade_flatten(input_brigade, buff, &bufsiz);
+ buff[bufsiz] = '\0';
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, "%s %s manager_handler buff
%s", r->method, r->uri, buff);
+ return (OK);
}
/*
@@ -203,45 +179,6 @@
mconf->basefilename = apr_pstrdup(cmd->pool, word);
return NULL;
}
-AP_DECLARE_NONSTD(const char *) cmd_manager_enableport(cmd_parms *cmd, void *mconfig, int
arg)
-{
- mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config,
&manager_module);
- mconf->enable = arg;
- return NULL;
-}
-AP_DECLARE_NONSTD(const char *) cmd_manager_uselocalport(cmd_parms *cmd, void *mconfig,
const char *word)
-{
- mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config,
&manager_module);
- char *name = NULL;
- char *ptr;
- if (cmd->directive->parent &&
- strncasecmp(cmd->directive->parent->directive,
- "<Proxy", 6) == 0) {
- const char *pargs = cmd->directive->parent->args;
- name = ap_getword_conf(cmd->temp_pool, &pargs);
- if ((ptr = ap_strchr(name, '>')))
- *ptr = '\0';
- if (strncasecmp(name, "balancer://", 11) == 0) {
- /* store the port and the balancer in the conf */
- struct baldata *baldata = mconf->baldata;
- if (baldata) {
- while (baldata->next)
- baldata = baldata->next;
- baldata->next = apr_palloc(cmd->pool, sizeof(struct baldata));
- baldata = baldata->next;
- } else {
- mconf->baldata = apr_palloc(cmd->pool, sizeof(struct baldata));
- baldata = mconf->baldata;
- }
- baldata->next = NULL;
- baldata->balancer = apr_pstrdup(cmd->pool, &name[11]);
- baldata->port = atoi(word);
- return NULL;
- }
- return apr_pstrcat(cmd->temp_pool, "UseLocalPort: balancer not ok:
", name, NULL);
- }
- return "UseLocalPort should be in a <Proxy balancer /> directive";
-}
static const command_rec manager_cmds[] =
{
AP_INIT_TAKE1(
@@ -249,14 +186,14 @@
cmd_manager_maxcontext,
NULL,
OR_ALL,
- "Maxcontext - number max context support by mod_manager"
+ "Maxcontext - number max context support by mod_cluster"
),
AP_INIT_TAKE1(
"Maxnode",
cmd_manager_maxnode,
NULL,
OR_ALL,
- "Maxnode - number max node support by mod_manager"
+ "Maxnode - number max node support by mod_cluster"
),
AP_INIT_TAKE1(
"MemManagerFile",
@@ -265,18 +202,6 @@
OR_ALL,
"MemManagerFile - base name of the files used to create/attach to shared
memory"
),
- AP_INIT_TAKE1(
- "UseLocalPort",
- cmd_manager_uselocalport,
- NULL,
- OR_ALL,
- "UseLocalPort - Port used to fill balancer nodes"
- ),
- AP_INIT_FLAG("EnableLocalPort",
- cmd_manager_enableport,
- NULL,
- RSRC_CONF,
- "Run a TCP receiver on this host"),
{NULL}
};
@@ -288,8 +213,8 @@
/* Create the shared tables for mod_proxy_cluster */
ap_hook_post_config(manager_init, NULL, NULL, APR_HOOK_MIDDLE);
- /* Process the connections from jboss nodes */
- ap_hook_process_connection(manager_process_connection, NULL, NULL, APR_HOOK_MIDDLE);
+ /* Process the request from the ModClusterService */
+ ap_hook_handler(manager_handler, NULL, NULL, APR_HOOK_MIDDLE);
/* Register nodes table provider */
ap_register_provider(p, "manager" , "shared", "0",
&storage);