From jbossnative-commits at lists.jboss.org Mon Jul 20 15:23:46 2009
Content-Type: multipart/mixed; boundary="===============4705453984425924328=="
MIME-Version: 1.0
From: jbossnative-commits at lists.jboss.org
To: jbossnative-commits at lists.jboss.org
Subject: [jbossnative-commits] JBoss Native SVN: r2497 -
trunk/mod_cluster/native/mod_manager.
Date: Mon, 20 Jul 2009 10:29:34 -0400
Message-ID: <200907201429.n6KETYR3025620@svn01.web.mwc.hst.phx2.redhat.com>
--===============4705453984425924328==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: jfrederic.clere(a)jboss.com
Date: 2009-07-20 10:29:34 -0400 (Mon, 20 Jul 2009)
New Revision: 2497
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Fix MODCLUSTER-50, and sort the node by domain.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2009-07-20 08:12:06 =
UTC (rev 2496)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2009-07-20 14:29:34 =
UTC (rev 2497)
@@ -89,6 +89,11 @@
/* Internal substitution for node commands */
#define NODE_COMMAND "/NODE_COMMAND"
=
+/* range of the commands */
+#define RANGECONTEXT 0
+#define RANGENODE 1
+#define RANGEDOMAIN 2
+
/* shared memory */
mem_t *contextstatsmem =3D NULL;
mem_t *nodestatsmem =3D NULL;
@@ -1385,6 +1390,15 @@
ap_rprintf(r, "Disable Contexts",
r->uri, balancer_nonce, node_string(r, JVMRoute));
}
+static void domain_command_string(request_rec *r, int status, char *Domain)
+{
+ if (status =3D=3D ENABLED)
+ ap_rprintf(r, "Enable Nodes ",
+ r->uri, balancer_nonce, Domain);
+ if (status =3D=3D DISABLED)
+ ap_rprintf(r, "Disable Nodes",
+ r->uri, balancer_nonce, Domain);
+}
=
/*
* Process the parameters and display corresponding informations.
@@ -1512,6 +1526,60 @@
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"manager_handler %s error: %s", r->method, errstring);
}
+static void sort_nodes(nodeinfo_t *nodes, int nbnodes)
+{
+ int i;
+ int changed =3D -1;
+ if (nbnodes <=3D1)
+ return;
+ while(changed) {
+ changed =3D 0;
+ for (i=3D0; i 0) {
+ nodeinfo_t node;
+ node =3D nodes[i+1];
+ nodes[i+1] =3D nodes[i];
+ nodes[i] =3D node;
+ changed =3D -1;
+ }
+ }
+ }
+}
+static char *process_domain(request_rec *r, char **ptr, int *errtype, cons=
t char *cmd, const char *domain)
+{
+ int size, i;
+ int *id;
+ int pos;
+ char *errstring =3D NULL;
+ size =3D get_max_size_node(nodestatsmem);
+ id =3D apr_palloc(r->pool, sizeof(int) * size);
+ size =3D get_ids_used_node(nodestatsmem, id);
+
+ for (pos=3D0;ptr[pos]!=3DNULL && ptr[pos+1]!=3DNULL; pos=3Dpos+2) ;
+
+ ptr[pos] =3D apr_pstrdup(r->pool, "JVMRoute");
+ ptr[pos+2] =3D NULL;
+ ptr[pos+3] =3D NULL;
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server, "pro=
cess_domain");
+ for (i=3D0; imess.Domain, domain) !=3D 0)
+ continue;
+ /* add the JVMRoute */
+ ptr[pos+1] =3D apr_pstrdup(r->pool, ou->mess.JVMRoute);
+ if (strcasecmp(cmd, "ENABLE-APP") =3D=3D 0)
+ errstring =3D process_enable(r, ptr, errtype, RANGENODE);
+ else if (strcasecmp(cmd, "DISABLE-APP") =3D=3D 0)
+ errstring =3D process_disable(r, ptr, errtype, RANGENODE);
+ else if (strcasecmp(cmd, "STOP-APP") =3D=3D 0)
+ errstring =3D process_stop(r, ptr, errtype, RANGENODE);
+ else if (strcasecmp(cmd, "REMOVE-APP") =3D=3D 0)
+ errstring =3D process_remove(r, ptr, errtype, RANGENODE);
+ }
+ return errstring;
+}
static int manager_info(request_rec *r)
{
int size, i, sizesessionid;
@@ -1519,6 +1587,9 @@
apr_table_t *params =3D apr_table_make(r->pool, 10);
int access_status;
const char *name;
+ nodeinfo_t *nodes;
+ int nbnodes =3D 0;
+ char *domain =3D "";
=
if (r->args) {
char *args =3D apr_pstrdup(r->pool, r->args);
@@ -1556,6 +1627,7 @@
const char *val =3D apr_table_get(params, "Refresh");
const char *cmd =3D apr_table_get(params, "Cmd");
const char *typ =3D apr_table_get(params, "Range");
+ const char *domain =3D apr_table_get(params, "Domain");
/* Process the Refresh parameter */
if (val) {
long t =3D atol(val);
@@ -1563,7 +1635,7 @@
}
/* Process command if any */
if (cmd !=3D NULL && typ !=3DNULL) {
- int global =3D 0;
+ int global =3D RANGECONTEXT;
char *errstring =3D NULL;
int errtype =3D 0;
int i;
@@ -1571,7 +1643,15 @@
const apr_array_header_t *arr =3D apr_table_elts(params);
const apr_table_entry_t *elts =3D (const apr_table_entry_t *)a=
rr->elts;
=
- ptr =3D apr_palloc(r->pool, sizeof(char *) * (arr->nelts + 1) =
* 2);
+ if (strcasecmp(typ,"NODE")=3D=3D0)
+ global =3D RANGENODE;
+ else if (strcasecmp(typ,"DOMAIN")=3D=3D0)
+ global =3D RANGEDOMAIN;
+
+ if (global =3D=3D RANGEDOMAIN)
+ ptr =3D apr_palloc(r->pool, sizeof(char *) * (arr->nelts +=
2) * 2);
+ else
+ ptr =3D apr_palloc(r->pool, sizeof(char *) * (arr->nelts +=
1) * 2);
for (i =3D 0; i < arr->nelts; i++) {
ptr[i*2] =3D elts[i].key;
ptr[i*2+1] =3D elts[i].val;
@@ -1579,9 +1659,9 @@
ptr[arr->nelts*2] =3D NULL;
ptr[arr->nelts*2+1] =3D NULL;
=
- if (strcasecmp(typ,"NODE")=3D=3D0)
- global =3D 1;
- if (strcasecmp(cmd, "ENABLE-APP") =3D=3D 0)
+ if (global =3D=3D RANGEDOMAIN)
+ errstring =3D process_domain(r, ptr, &errtype, cmd, domain=
);
+ else if (strcasecmp(cmd, "ENABLE-APP") =3D=3D 0)
errstring =3D process_enable(r, ptr, &errtype, global);
else if (strcasecmp(cmd, "DISABLE-APP") =3D=3D 0)
errstring =3D process_disable(r, ptr, &errtype, global);
@@ -1631,12 +1711,32 @@
size =3D get_max_size_node(nodestatsmem);
id =3D apr_palloc(r->pool, sizeof(int) * size);
size =3D get_ids_used_node(nodestatsmem, id);
+
+
+ /* read the node to sort them by domain */
+ nodes =3D apr_palloc(r->pool, sizeof(nodeinfo_t) * size);
for (i=3D0; imess.Domain) !=3D 0) {
+ ap_rprintf(r, " Domain %s: ", ou->mess.Domain);
+ domain =3D ou->mess.Domain;
+ domain_command_string(r, ENABLED, domain);
+ domain_command_string(r, DISABLED, domain);
+ ap_rprintf(r, "
\n");
+ }
ap_rprintf(r, " Node %s (%s://%s:%s): ",
ou->mess.JVMRoute, ou->mess.Type, ou->mess.Host, ou->me=
ss.Port);
=
--===============4705453984425924328==--