Author: rjung Date: Wed Jan 9 15:26:35 2008 New Revision: 610611 URL: http://svn.apache.org/viewvc?rev=610611&view=rev Log: Add "dump" action to status worker, which dumps our initial configuration.
Modified: tomcat/connectors/trunk/jk/native/common/jk_status.c tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml tomcat/connectors/trunk/jk/xdocs/reference/status.xml Modified: tomcat/connectors/trunk/jk/native/common/jk_status.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_status.c?rev=610611&r1=610610&r2=610611&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_status.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_status.c Wed Jan 9 15:26:35 2008 @@ -109,8 +109,9 @@ #define JK_STATUS_CMD_RESET (5) #define JK_STATUS_CMD_VERSION (6) #define JK_STATUS_CMD_RECOVER (7) +#define JK_STATUS_CMD_DUMP (8) #define JK_STATUS_CMD_DEF (JK_STATUS_CMD_LIST) -#define JK_STATUS_CMD_MAX (JK_STATUS_CMD_RECOVER) +#define JK_STATUS_CMD_MAX (JK_STATUS_CMD_DUMP) #define JK_STATUS_CMD_TEXT_UNKNOWN ("unknown") #define JK_STATUS_CMD_TEXT_LIST ("list") #define JK_STATUS_CMD_TEXT_SHOW ("show") @@ -119,6 +120,7 @@ #define JK_STATUS_CMD_TEXT_RESET ("reset") #define JK_STATUS_CMD_TEXT_VERSION ("version") #define JK_STATUS_CMD_TEXT_RECOVER ("recover") +#define JK_STATUS_CMD_TEXT_DUMP ("dump") #define JK_STATUS_CMD_TEXT_DEF (JK_STATUS_CMD_TEXT_LIST) #define JK_STATUS_CMD_PROP_CHECK_WORKER 0x00000001 @@ -129,8 +131,9 @@ #define JK_STATUS_CMD_PROP_BACK_LIST 0x00000020 #define JK_STATUS_CMD_PROP_FMT 0x00000040 #define JK_STATUS_CMD_PROP_SWITCH_RO 0x00000080 -#define JK_STATUS_CMD_PROP_LINK_HELP 0x00000100 -#define JK_STATUS_CMD_PROP_LEGEND 0x00000200 +#define JK_STATUS_CMD_PROP_DUMP_LINK 0x00000100 +#define JK_STATUS_CMD_PROP_LINK_HELP 0x00000200 +#define JK_STATUS_CMD_PROP_LEGEND 0x00000400 #define JK_STATUS_MIME_UNKNOWN (0) #define JK_STATUS_MIME_HTML (1) @@ -319,6 +322,7 @@ JK_STATUS_CMD_TEXT_RESET, JK_STATUS_CMD_TEXT_VERSION, JK_STATUS_CMD_TEXT_RECOVER, + JK_STATUS_CMD_TEXT_DUMP, NULL }; @@ -795,6 +799,8 @@ return JK_STATUS_CMD_VERSION; else if (!strcmp(cmd, JK_STATUS_CMD_TEXT_RECOVER)) return JK_STATUS_CMD_RECOVER; + else if (!strcmp(cmd, JK_STATUS_CMD_TEXT_DUMP)) + return JK_STATUS_CMD_DUMP; return JK_STATUS_CMD_UNKNOWN; } @@ -831,14 +837,21 @@ if (cmd == JK_STATUS_CMD_LIST || cmd == JK_STATUS_CMD_SHOW || cmd == JK_STATUS_CMD_VERSION) + props |= JK_STATUS_CMD_PROP_DUMP_LINK; + if (cmd == JK_STATUS_CMD_LIST || + cmd == JK_STATUS_CMD_SHOW || + cmd == JK_STATUS_CMD_VERSION || + cmd == JK_STATUS_CMD_DUMP) props |= JK_STATUS_CMD_PROP_HEAD | JK_STATUS_CMD_PROP_FMT; if (cmd == JK_STATUS_CMD_SHOW || - cmd == JK_STATUS_CMD_VERSION) + cmd == JK_STATUS_CMD_VERSION || + cmd == JK_STATUS_CMD_DUMP) props |= JK_STATUS_CMD_PROP_BACK_LIST; if (cmd == JK_STATUS_CMD_SHOW || cmd == JK_STATUS_CMD_EDIT || - cmd == JK_STATUS_CMD_VERSION) + cmd == JK_STATUS_CMD_VERSION || + cmd == JK_STATUS_CMD_DUMP) props |= JK_STATUS_CMD_PROP_BACK_LINK; if (cmd != JK_STATUS_CMD_EDIT && cmd != JK_STATUS_CMD_UPDATE && @@ -846,7 +859,8 @@ cmd != JK_STATUS_CMD_RECOVER) props |= JK_STATUS_CMD_PROP_READONLY; if (cmd != JK_STATUS_CMD_LIST && - cmd != JK_STATUS_CMD_VERSION) + cmd != JK_STATUS_CMD_VERSION && + cmd != JK_STATUS_CMD_DUMP) props |= JK_STATUS_CMD_PROP_CHECK_WORKER; return props; @@ -3108,6 +3122,63 @@ return JK_FALSE; } +static int dump_config(jk_ws_service_t *s, + status_endpoint_t *p, + int mime, jk_logger_t *l) +{ + status_worker_t *w = p->worker; + jk_worker_env_t *we = w->we; + jk_map_t *init_data = we->init_data; + + JK_TRACE_ENTER(l); + + if (init_data) { + int l = jk_map_size(init_data); + int i; + if (mime == JK_STATUS_MIME_HTML) { + jk_puts(s, "<hr/><h2>Configuration Data</h2><hr/>\n"); + jk_puts(s, "This dump does not include any changes applied by the status worker\n"); + jk_puts(s, "to the configuration after the initial startup\n"); + jk_puts(s, "<PRE>\n"); + } + else if (mime == JK_STATUS_MIME_XML) { + jk_print_xml_start_elt(s, w, 2, 0, "configuration"); + } + else if (mime == JK_STATUS_MIME_TXT) { + jk_puts(s, "Configuration:\n"); + } + for (i=0;i<l;i++) { + const char *name = jk_map_name_at(init_data, i); + if (name) { + const char *value = jk_map_value_at(init_data, i); + if (!value) + value = "(null)"; + if (mime == JK_STATUS_MIME_HTML || + mime == JK_STATUS_MIME_PROP || + mime == JK_STATUS_MIME_TXT) { + jk_putv(s, name, "=", value, "\n", NULL); + } + else if (mime == JK_STATUS_MIME_XML) { + jk_print_xml_att_string(s, 4, name, value); + } + } + } + if (mime == JK_STATUS_MIME_HTML) { + jk_puts(s, "</PRE>\n"); + } + else if (mime == JK_STATUS_MIME_XML) { + jk_print_xml_stop_elt(s, 2, 1); + } + } + else { + JK_TRACE_EXIT(l); + return JK_FALSE; + } + + JK_TRACE_EXIT(l); + return JK_TRUE; +} + /* * Return values of service() method for status worker: * return value is_error reason @@ -3553,6 +3624,12 @@ jk_puts(s, "] \n"); } } + if (cmd_props & JK_STATUS_CMD_PROP_DUMP_LINK) { + jk_puts(s, "["); + status_write_uri(s, p, "Dump", JK_STATUS_CMD_DUMP, JK_STATUS_MIME_UNKNOWN, + NULL, NULL, 0, 0, NULL, l); + jk_puts(s, "] \n"); + } if (cmd_props & JK_STATUS_CMD_PROP_LINK_HELP) { jk_puts(s, "["); if (cmd == JK_STATUS_CMD_LIST) { @@ -3581,6 +3658,11 @@ if(edit_worker(s, p, l) != JK_TRUE) { err = "Error in generating this worker's configuration form."; } + } + } + if (cmd == JK_STATUS_CMD_DUMP) { + if (dump_config(s, p, mime, l) == JK_FALSE) { + err = "Dumping configuration failed"; } } if (cmd_props & JK_STATUS_CMD_PROP_LEGEND) { Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=610611&r1=610610&r2=610611&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original) +++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Wed Jan 9 15:26:35 2008 @@ -44,7 +44,10 @@ <subsection name="Native"> <changelog> <update> - LB: Use property table to decide which cmd action uses which + Status: Add "dump" action to dump our initial configuration. (rjung) + </update> + <update> + Status: Use property table to decide which cmd action uses which output elements. (rjung) </update> <update> Modified: tomcat/connectors/trunk/jk/xdocs/reference/status.xml URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/reference/status.xml?rev=610611&r1=610610&r2=610611&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/xdocs/reference/status.xml (original) +++ tomcat/connectors/trunk/jk/xdocs/reference/status.xml Wed Jan 9 15:26:35 2008 @@ -94,6 +94,12 @@ <li> <b>version</b>: only show version information of the web server and the JK software </li> +<li> +<b>dump</b>: list the original workers configuration. <b>Caution</b>: the dump will only contain +the configuration that was used during startup. Any changes applied later by the dynamic management +interface of the status worker itself will not be contained in this dump. +The dump action has been added in version 1.2.27. +</li> </ul> </p> </subsection> @@ -227,7 +233,7 @@ </source> When writing HTML output, the status worker then includes the line <source> -<link rel="stylesheet" type="text/css" href="/private/admin/static/mystatus.css" /> +<link rel="stylesheet" type="text/css" href="/private/admin/static/mystatus.css" /> </source> There is no sample stylesheet included with the mod_jk release, and by default the attribute css is empty, so no stylesheet reference will be included in the pages. The HTML code @@ -366,18 +372,22 @@ <br/> <p> This section should help you building automation scripts based on the jk status -management interface. This interface is still not stable, we expect further -improvements in the next releases. It is well possible, that the request parameters -might change in an incompatible way. So be prepared to change you scripts when -updating to future versions. +management interface. This interface is stable in the sense, that we only expect +to add further parameters in the future. Existing parameters from previous versions +will keep their original semantics. We also expect the output formats XML, Properties +and Text to be kept stable. So please use those, if you want to parse status worker +output in your automation scripts. </p> <subsection name="Actions"> <br/> <p> The action is determined by the parameter <b>cmd</b>. It can have the values "list", "show", -"edit", "update", "reset", "recover" and "version". If you omit the "cmd" parameter, +"edit", "update", "reset", "recover", "version" and "dump". If you omit the "cmd" parameter, the default "list" will be used. -All actions except for "list" and "refresh" need additional parameters. +All actions except for "list", "refresh", "version" and "dump" need additional parameters. +</p> +<p> +The action "dump" has been added in version 1.2.27. </p> </subsection> <subsection name="Output Format"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]