Greetings All, The link below is a proposed diff patch to jk_worker_status.c, modifying the 'service()' routine, to do the following: http://normw.gknw.com/patches/jk_worker_status.c.diff
- implement a single point of entry and exit so that all commands call 's->afterRequest(env, s)' routine on exit, - all html-based commands now have the 'links' at the top of the page, - apply classes to some html tags for more specific format control in style sheets if required, - the 'scoreboard' link is replaced by an 'endpoints=' link for platforms not having SHM, - provide for an 'all=' option alluded to in earlier versions of this module, content presently undefined, - provide for a 'help' option, content presently undefined. Help could take the form of an html table or an external file if required, - resetScoreboard() now returns true or false if SHM is available, and the related command now displays the correct message, - if an 'update' occurs, the message is displayed below the html 'links' so the links don't move up and down, - unknown status commands return an error message rather that just display the 'default' page. The diff file makes all this difficult to see; below is pseudo-code of the revised service() structure. The changes have been successfully compiled and tested to work as expected on a NetWare platform. Norm --------------------------------------------------------------- if query=NULL, query='def' /* default */ ... * Display response headers and stylesheet if required. * Test for update, log result and inc lbver if SHM installed * Check for text commands if query='dmp', dmp() else if query='lst', lst() else if query='qry', qry() else { * Output html screen heading and links if update, if SHM, message('Update') else message('No SHM') if query='get', get() else if query='set', set() else if query='inv', invoke() else if query='cfgOrig', cfgOrig() else if query='cfgParsed', cfgParsed() else if query='scoreboard.reset', reset() else if query='rld', if SHM, message('Reload') else message('No SHM') else if query='scoreboard', scoreboard() else if query='endpoints', endpoints() else if query='all', message('Undefined') else if query='def', default data else if query='help', message('Undefined') else message('Unknown command') } /* Tidy up and exit. */ s->afterRequest(env, s); --------------------------------------------------------------- --- jk_worker_status.c.orig 2004-05-08 07:05:53.000000000 +1000 +++ jk_worker_status.c 2004-05-30 08:58:28.000000000 +1000 @@ -305,14 +305,14 @@ } } -static void jk2_worker_status_resetScoreboard(jk_env_t *env, +static int jk2_worker_status_resetScoreboard(jk_env_t *env, jk_ws_service_t *s, jk_workerEnv_t *wenv) { int i, j; if (wenv->shm == NULL || wenv->shm->head == NULL) { - return; + return JK_FALSE; } for (i = 0; i < wenv->shm->head->lastSlot; i++) { @@ -336,6 +336,7 @@ } } } + return JK_TRUE; } /** That's the 'bulk' data - everything that was configured, after substitution @@ -1106,7 +1107,7 @@ if (s->query_string == NULL) { - s->query_string = ""; + s->query_string = "def="; } /* Generate the header */ @@ -1157,122 +1158,188 @@ } } - /** Check for Scoreboard Reset. **/ + /* Updating the config is the first thing done. + All other operations happen on the new config. + */ + w->workerEnv->config->update(env, w->workerEnv->config, &didUpdate); - if (strcmp(s->query_string, "scoreboard.reset") == 0) { - jk2_worker_status_resetScoreboard(env, s, s->workerEnv); - s->jkprintf(env, s, "Scoreboard reset\n"); - } + env->l->jkLog(env, env->l, JK_LOG_DEBUG, "status.update check %d\n", didUpdate); - /** Updating the config is the first thing we do. - All other operations will happen on the update config. - */ - w->workerEnv->config->update(env, w->workerEnv->config, &didUpdate); - env->l->jkLog(env, env->l, JK_LOG_DEBUG, - "status.update check %d\n", didUpdate); + /* If Updated, raise Scoreboard version to force + a config reload - tell the user a bit later. + */ if (didUpdate) { + jk_shm_t *shm = w->workerEnv->shm; - /* Update the scoreboard's version - all other - jk2 processes will see this and update - */ if (shm != NULL && shm->head != NULL) { + shm->head->lbVer++; - s->jkprintf(env, s, "Updated config version to %d\n", - shm->head->lbVer); - } - else { - s->jkprintf(env, s, "Update detected. No scoreboard.\n"); } } + /* Do Text based commands without HTML Header */ - /* Increment the scoreboard version counter, reload */ - if (strncmp(s->query_string, "rld=", 4) == 0) { - jk_shm_t *shm = w->workerEnv->shm; + /** List mbeans and their attributes. **/ + if (strncmp(s->query_string, "lst=", 4) == 0) { - /* Update the scoreboard's version - all other - jk2 processes will see this and update - */ - if (shm != NULL && shm->head != NULL) { - shm->head->lbVer++; - s->jkprintf(env, s, "Updated config version to %d\n", - shm->head->lbVer); - } - else { - s->jkprintf(env, s, "Reload requested. No scoreboard.\n"); - } - return JK_OK; + jk2_worker_status_list(env, w, s); } - /** list all mbeans and their attributes */ - if (strncmp(s->query_string, "lst=", 4) == 0) { - return jk2_worker_status_list(env, w, s); - } + /** Dump multiple attributes. **/ + else if (strncmp(s->query_string, "dmp=", 4) == 0) { - /** Dump multiple attributes */ - if (strncmp(s->query_string, "dmp=", 4) == 0) { - return jk2_worker_status_dmp(env, w, s); + jk2_worker_status_dmp(env, w, s); } - /** Commons-modeler */ - if (strncmp(s->query_string, "qry=", 4) == 0) { - return jk2_worker_status_qry(env, w, s); - } + /** Commons-modeler display. **/ + else if (strncmp(s->query_string, "qry=", 4) == 0) { - /** Get a single attribute. This also works for attributes that are not listed in getAtt **/ - if (strncmp(s->query_string, "get=", 4) == 0) { - return jk2_worker_status_get(env, w, s); + jk2_worker_status_qry(env, w, s); } - /** Set an attribute. Works for attributes that are not listed in setAtt **/ - if (strncmp(s->query_string, "set=", 4) == 0) { - return jk2_worker_status_set(env, w, s); - } + else { - if (strncmp(s->query_string, "inv=", 4) == 0) { - return jk2_worker_status_invoke(env, w, s); - } + /* Do the HTML options - Screen Headings first */ - s->jkprintf(env, s, "Status information for child %d<br>", - s->workerEnv->childId); - s->jkprintf(env, s, - " <a href='jkstatus?cfgOrig=1'>[Original config]</a>\n"); - s->jkprintf(env, s, - " <a href='jkstatus?cfgParsed=1'>[Processed config]</a>\n"); - s->jkprintf(env, s, - " <a href='jkstatus?scoreboard=1'>[Scoreboard info]</a>\n"); - s->jkprintf(env, s, - " <a href='jkstatus'>[Workers, Channels and URIs]</a>\n"); + s->jkprintf(env, s, "<a name=top></a>\n<h1>Status Information for Child: %d</h1>\n", s->workerEnv->childId); + s->jkprintf(env, s, "<p class=hdr>\n [<a href='jkstatus?cfgOrig=1'>Original Config</a>]\n"); + s->jkprintf(env, s, " [<a href='jkstatus?cfgParsed=1'>Processed Config</a>]\n"); - if (strncmp(s->query_string, "cfgOrig=", 8) == 0) { - jk2_worker_status_displayConfigProperties(env, s, s->workerEnv); - return JK_OK; - } + /* Customise the links if SHM available */ - if (strncmp(s->query_string, "cfgParsed=", 10) == 0) { - jk2_worker_status_displayActiveProperties(env, s, s->workerEnv); - return JK_OK; - } +#if APR_HAS_SHARED_MEMORY - if (strncmp(s->query_string, "scoreboard=", 11) == 0) { - jk2_worker_status_displayScoreboardInfo(env, s, s->workerEnv); - return JK_OK; - } - if (strncmp(s->query_string, "endpoints=", 10) == 0) { - jk2_worker_status_displayEndpointInfo(env, s, s->workerEnv); - return JK_OK; - } + s->jkprintf(env, s, " [<a href='jkstatus?scoreboard=1'>Scoreboard Info</a>]\n"); +#else + s->jkprintf(env, s, " [<a href='jkstatus?endpoints=1'>EndPoint Info</a>]\n"); + +#endif + + s->jkprintf(env, s, " [<a href='jkstatus'>Workers, Channels and URIs</a>]\n"); + s->jkprintf(env, s, " [<a href='jkstatus?all='>All Info</a>]\n"); + s->jkprintf(env, s, " [<a href='jkstatus?help'>Help</a>]</p>\n"); + + /* Show Update Message if it occurred */ - /* Body */ - jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "ajp13"); - jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, - "channel.socket"); - jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "channel.un"); - jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "channel.jni"); - jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "uri"); + if (didUpdate) { + + jk_shm_t *shm = w->workerEnv->shm; + + if (shm != NULL && shm->head != NULL) { + + s->jkprintf(env, s, "<p class=msg>Update Detected. Config version now: %d\</p>n", shm->head->lbVer); + } + else { + + s->jkprintf(env, s, "<p class=wrn>Update Detected. Reload failed. No Scoreboard installed.</p>\n"); + } + } + + /* Do the HTML options - commands next */ + + /** Get a single Object attribute. **/ + if (strncmp(s->query_string, "get=", 4) == 0) { + + jk2_worker_status_get(env, w, s); + } + /** Set a single Object attribute. **/ + else if (strncmp(s->query_string, "set=", 4) == 0) { + + jk2_worker_status_set(env, w, s); + } + + /** Invoke an Object service. **/ + else if (strncmp(s->query_string, "inv=", 4) == 0) { + + jk2_worker_status_invoke(env, w, s); + } + + /** Show original configuration settings. **/ + else if (strncmp(s->query_string, "cfgOrig=", 8) == 0) { + + jk2_worker_status_displayConfigProperties(env, s, s->workerEnv); + } + + /** Show parsed configuration settings. **/ + else if (strncmp(s->query_string, "cfgParsed=", 10) == 0) { + + jk2_worker_status_displayActiveProperties(env, s, s->workerEnv); + } + + /** Reset Scoreboard counters. **/ + else if (strcmp(s->query_string, "scoreboard.reset") == 0) { + + if (jk2_worker_status_resetScoreboard(env, s, s->workerEnv)) { + + s->jkprintf(env, s, "<p class=msg>Scoreboard was Reset.</p>\n"); + } + else { + + s->jkprintf(env, s, "<p class=wrn>Scoreboard Reset failed. No Scoreboard installed.</p>\n"); + } + } + + /** Force Configuration Reload. **/ + else if (strncmp(s->query_string, "rld=", 4) == 0) { + + jk_shm_t *shm = w->workerEnv->shm; + + if (shm != NULL && shm->head != NULL) { + + shm->head->lbVer++; + + s->jkprintf(env, s, "<p class=msg>Reload initiated. Config version now: %d\</p>n", shm->head->lbVer); + } + else { + + s->jkprintf(env, s, "<p class=wrn>Reload failed. No Scoreboard installed.</p>\n"); + } + } + + /** Show Scoreboard details. **/ + else if (strncmp(s->query_string, "scoreboard=", 11) == 0) { + + jk2_worker_status_displayScoreboardInfo(env, s, s->workerEnv); + } + + /** Show Endpoints - useful if no SHM. **/ + else if (strncmp(s->query_string, "endpoints=", 10) == 0) { + + jk2_worker_status_displayEndpointInfo(env, s, s->workerEnv); + } + + /** Show 'All' information. **/ + else if (strncmp(s->query_string, "all=", 4) == 0) { + + s->jkprintf(env, s, "<p class=msg>The ALL= option not currently defined.</p>\n"); + } + /** Show 'default' information. **/ + else if (strncmp(s->query_string, "def=", 4) == 0) { + + jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "ajp13"); + jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "channel.socket"); + jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "channel.un"); + jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "channel.jni"); + jk2_worker_status_displayRuntimeType(env, s, s->workerEnv, "uri"); + + } + /** Show 'help' information. **/ + else if (strncmp(s->query_string, "help", 4) == 0) { + + s->jkprintf(env, s, "<p class=msg>Help Information not currently defined.</p>\n"); + } + /** An unknown command. **/ + else { + + s->jkprintf(env, s, "<p class=wrn>Unknown Status Command!? [%s]</p>\n", s->query_string); + } + } + + /** Tidy up and exit. **/ s->afterRequest(env, s); + return JK_OK; } --------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]