Author: jfrederic.clere(a)jboss.com
Date: 2008-03-29 04:45:41 -0400 (Sat, 29 Mar 2008)
New Revision: 1486
Modified:
sandbox/httpd/src/native/mod_manager/mod_manager.c
Log:
Add logic to process the STATUS message.
Modified: sandbox/httpd/src/native/mod_manager/mod_manager.c
===================================================================
--- sandbox/httpd/src/native/mod_manager/mod_manager.c 2008-03-29 08:41:21 UTC (rev 1485)
+++ sandbox/httpd/src/native/mod_manager/mod_manager.c 2008-03-29 08:45:41 UTC (rev 1486)
@@ -392,7 +392,7 @@
/* Insert or update node description */
int id;
if (insert_update_node(nodestatsmem, &nodeinfo, &id) != APR_SUCCESS)
- return 500;
+ return 500;
/* Insert the Alias and corresponding Context */
phost = vhost;
@@ -540,8 +540,56 @@
{
return process_appl_cmd(r, buff, REMOVE);
}
+
+/*
+ * Process the STATUS command
+ * Load -1 : Broken
+ * Load 0 : Standby.
+ * Load 1-100 : Load factor.
+ */
static int process_status(request_rec *r, char *buff)
{
+ int Load;
+ nodeinfo_t nodeinfo;
+ nodeinfo_t *node;
+ char **ptr = process_buff(r, buff);
+ if (ptr == NULL)
+ return 500;
+
+ int i = 0;
+ while (ptr[i]) {
+ if (strcasecmp(ptr[i], "JVMRoute") == 0) {
+ if (strlen(ptr[i+1])>=sizeof(nodeinfo.mess.JVMRoute))
+ return 500;
+ strcpy(nodeinfo.mess.JVMRoute, ptr[i+1]);
+ nodeinfo.mess.id = 0;
+ }
+ else if (strcasecmp(ptr[i], "Load") == 0) {
+ Load = atoi(ptr[i+1]);
+ }
+ else
+ return 500;
+ i++;
+ i++;
+ }
+
+ /* Read the node */
+ node = read_node(nodestatsmem, &nodeinfo);
+ if (node == NULL)
+ return 500;
+
+ /*
+ * If the node is usualable do a ping/pong to prevent Split-Brain Syndrome
+ * and update the worker status and load factor acccording to the test result.
+ */
+ ap_set_content_type(r, "text/plain");
+ ap_rprintf(r, "Type=STATUS-RSP&JVMRoute=%s", nodeinfo.mess.JVMRoute);
+
+ if (proxy_cluster_isup(r, node->mess.id, Load) != OK)
+ ap_rprintf(r, "&State=NOTOK\n");
+ else
+ ap_rprintf(r, "&State=OK\n");
+
return OK;
}