[Proxool-cvs] proxool/src/java/org/logicalcobwebs/proxool/admin/servlet AdminServlet.java,1.8,1.9
UNMAINTAINED!
Brought to you by:
billhorsman
From: <bil...@us...> - 2005-09-26 13:31:24
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/admin/servlet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6431/src/java/org/logicalcobwebs/proxool/admin/servlet Modified Files: AdminServlet.java Log Message: Smartened up AdminServlet Index: AdminServlet.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/admin/servlet/AdminServlet.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AdminServlet.java 29 Sep 2003 17:49:19 -0000 1.8 --- AdminServlet.java 26 Sep 2005 13:31:14 -0000 1.9 *************** *** 8,19 **** import org.logicalcobwebs.logging.Log; import org.logicalcobwebs.logging.LogFactory; ! import org.logicalcobwebs.proxool.ConnectionInfoIF; ! import org.logicalcobwebs.proxool.ConnectionPoolDefinitionIF; ! import org.logicalcobwebs.proxool.ProxoolException; ! import org.logicalcobwebs.proxool.ProxoolFacade; ! import org.logicalcobwebs.proxool.Version; import org.logicalcobwebs.proxool.admin.SnapshotIF; import org.logicalcobwebs.proxool.admin.StatisticsIF; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; --- 8,16 ---- import org.logicalcobwebs.logging.Log; import org.logicalcobwebs.logging.LogFactory; ! import org.logicalcobwebs.proxool.*; import org.logicalcobwebs.proxool.admin.SnapshotIF; import org.logicalcobwebs.proxool.admin.StatisticsIF; + import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; *************** *** 25,31 **** import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; ! import java.util.Calendar; /** --- 22,29 ---- import java.text.DecimalFormat; import java.text.SimpleDateFormat; + import java.util.Calendar; import java.util.Date; import java.util.Iterator; ! import java.util.Properties; /** *************** *** 38,41 **** --- 36,47 ---- * <servlet-name>Admin</servlet-name> * <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class> + * <init-param> + * <param-name>output</param-name> + * <param-value>full|simple</param-value> + * </init-param> + * <init-param> + * <param-name>cssFile</param-name> + * <param-value>/my_path/my.css</param-value> + * </init-param> * </servlet> * *************** *** 55,67 **** private static final Log LOG = LogFactory.getLog(AdminServlet.class); ! protected static final String ACTION_LIST = "list"; ! private static final String ACTION_STATS = "stats"; ! protected static final String ACTION_CHART = "chart"; protected static final String TYPE = "type"; protected static final String TYPE_CONNECTIONS = "1"; protected static final String TYPE_ACTIVITY_LEVEL = "2"; ! private static final String STYLE_CAPTION = "text-align: right; color: #333333;"; ! private static final String STYLE_DATA = "background: white;"; ! private static final String STYLE_NO_DATA = "color: #666666;"; /** --- 61,105 ---- private static final Log LOG = LogFactory.getLog(AdminServlet.class); ! private static final String[] STATUS_CLASSES = {"null", "available", "active", "offline"}; ! protected static final String TYPE = "type"; protected static final String TYPE_CONNECTIONS = "1"; protected static final String TYPE_ACTIVITY_LEVEL = "2"; ! ! public static final String OUTPUT_FULL = "full"; ! ! public static final String OUTPUT_SIMPLE = "simple"; ! ! private String output; ! ! private String cssFile; ! private static final String STATISTIC = "statistic"; ! private static final String CORE_PROPERTY = "core-property"; ! private static final String STANDARD_PROPERTY = "standard-property"; ! private static final String DELEGATED_PROPERTY = "delegated-property"; ! private static final String SNAPSHOT = "snapshot"; ! ! public void init(ServletConfig servletConfig) throws ServletException { ! super.init(servletConfig); ! ! // Get output parameter. Default to OUTPUT_FULL. ! output = servletConfig.getInitParameter("output"); ! if (output != null) { ! if (output.equalsIgnoreCase(OUTPUT_FULL)) { ! output = OUTPUT_FULL; ! } else if (output.equalsIgnoreCase(OUTPUT_SIMPLE)) { ! output = OUTPUT_SIMPLE; ! } else { ! LOG.warn("Unrecognised output parameter for " + this.getClass().getName() + ". Expected: " + OUTPUT_FULL + " or " + OUTPUT_SIMPLE); ! output = null; ! } ! } ! if (output == null) { ! output = OUTPUT_FULL; ! } ! ! cssFile = servletConfig.getInitParameter("cssFile"); ! ! } /** *************** *** 74,81 **** private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.00"); ! private static final String LEVEL = "level"; ! private static final String LEVEL_MORE = "more"; ! private static final String LEVEL_LESS = "less"; ! private static final String ACTION = "action"; private static final String ALIAS = "alias"; private static final String CONNECTION_ID = "id"; --- 112,122 ---- private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.00"); ! private static final String DETAIL = "detail"; ! private static final String DETAIL_MORE = "more"; ! private static final String DETAIL_LESS = "less"; ! private static final String TAB = "tab"; ! private static final String TAB_DEFINITION = "definition"; ! private static final String TAB_SNAPSHOT = "snapshot"; ! private static final String TAB_STATISTICS = "statistics"; private static final String ALIAS = "alias"; private static final String CONNECTION_ID = "id"; *************** *** 90,171 **** String link = request.getRequestURI(); - // Check the action, and default to stats - String action = request.getParameter(ACTION); - if (action == null) { - action = ACTION_STATS; - } - String level = request.getParameter(LEVEL); - String connectionId = request.getParameter(CONNECTION_ID); - // Check the alias and if not defined and there is only one ! // then use that. Otherwise show the list. String alias = request.getParameter(ALIAS); String[] aliases = ProxoolFacade.getAliases(); if (alias == null) { ! if (aliases.length == 1) { alias = aliases[0]; - } else { - action = ACTION_LIST; } } ! ! // Check we can find the pool. If not, show the list ! if (alias != null) { try { ! ProxoolFacade.getConnectionPoolDefinition(alias); } catch (ProxoolException e) { ! action = ACTION_LIST; } } - openHtml(response.getOutputStream()); try { ! if (action.equals(ACTION_LIST)) { ! response.setContentType("text/html"); ! doList(response.getOutputStream(), alias, link, level); ! } else if (action.equals(ACTION_STATS)) { response.setContentType("text/html"); ! doStats(response.getOutputStream(), alias, link, level, connectionId); ! } else { ! LOG.error("Unrecognised action '" + action + "'"); } } catch (ProxoolException e) { ! LOG.error("Problem", e); } - response.getOutputStream().println("<div style=\"text-align: right; width: 550px; color: #333333;\">Proxool " + Version.getVersion() + "</div>"); - closeHtml(response.getOutputStream()); } ! private void doStats(ServletOutputStream out, String alias, String link, String level, String connectionId) throws ProxoolException, IOException { ! doList(out, alias, link, level); ! doDefinition(out, alias, link); ! doSnapshot(out, alias, link, level, connectionId); ! doStatistics(out, alias, link); } ! private void doStatistics(ServletOutputStream out, String alias, String link) throws ProxoolException, IOException { ! StatisticsIF[] statisticsArray = ProxoolFacade.getStatistics(alias); ! ConnectionPoolDefinitionIF cpd = ProxoolFacade.getConnectionPoolDefinition(alias); for (int i = 0; i < statisticsArray.length; i++) { StatisticsIF statistics = statisticsArray[i]; - out.print("<b>Statistics</b> from "); - out.print(TIME_FORMAT.format(statistics.getStartDate())); - out.print(" to "); - out.print(TIME_FORMAT.format(statistics.getStopDate())); ! openTable(out); // Served ! printDefinitionEntry(out, "Served", statistics.getServedCount() + " (" + DECIMAL_FORMAT.format(statistics.getServedPerSecond()) + "/s)"); // Refused ! printDefinitionEntry(out, "Refused", statistics.getRefusedCount() + " (" + DECIMAL_FORMAT.format(statistics.getRefusedPerSecond()) + "/s)"); // averageActiveTime ! printDefinitionEntry(out, "Average active time", DECIMAL_FORMAT.format(statistics.getAverageActiveTime() / 1000) + "s"); // activityLevel --- 131,241 ---- String link = request.getRequestURI(); // Check the alias and if not defined and there is only one ! // then use that. String alias = request.getParameter(ALIAS); + // Check we can find the pool. + ConnectionPoolDefinitionIF def = null; + if (alias != null) { + try { + def = ProxoolFacade.getConnectionPoolDefinition(alias); + } catch (ProxoolException e) { + alias = null; + } + } String[] aliases = ProxoolFacade.getAliases(); if (alias == null) { ! if (aliases.length > 0) { alias = aliases[0]; } } ! if (def == null && alias != null) { try { ! def = ProxoolFacade.getConnectionPoolDefinition(alias); } catch (ProxoolException e) { ! throw new ServletException("Couldn't find pool with alias " + alias); } } + String tab = request.getParameter(TAB); + if (tab == null) { + tab = TAB_DEFINITION; + } + + // If we are showing the snapshot, are we showing it in detail or not? + String snapshotDetail = request.getParameter(DETAIL); + + // If we are showing the snapshot, are we drilling down into a connection? + String snapshotConnectionId = request.getParameter(CONNECTION_ID); + try { ! if (output.equals(OUTPUT_FULL)) { response.setContentType("text/html"); ! openHtml(response.getOutputStream()); ! } ! response.getOutputStream().println("<div class=\"version\">Proxool " + Version.getVersion() + "</div>"); ! doList(response.getOutputStream(), alias, tab, link); ! // Skip everything if there aren't any pools ! if (aliases != null && aliases.length > 0) { ! StatisticsIF[] statisticsArray = ProxoolFacade.getStatistics(alias); ! final boolean statisticsAvailable = (statisticsArray != null && statisticsArray.length > 0); ! final boolean statisticsComingSoon = def.getStatistics() != null; ! // We can't be on the statistics tab if there are no statistics ! if (!statisticsComingSoon && tab.equals(TAB_STATISTICS)) { ! tab = TAB_DEFINITION; ! } ! doTabs(response.getOutputStream(), alias, link, tab, statisticsAvailable, statisticsComingSoon); ! if (tab.equals(TAB_DEFINITION)) { ! doDefinition(response.getOutputStream(), def); ! } else if (tab.equals(TAB_SNAPSHOT)) { ! doSnapshot(response.getOutputStream(), alias, link, snapshotDetail, snapshotConnectionId); ! } else if (tab.equals(TAB_STATISTICS)){ ! doStatistics(response.getOutputStream(), statisticsArray, def); ! } else { ! throw new ServletException("Unrecognised tab '" + tab + "'"); ! } } } catch (ProxoolException e) { ! throw new ServletException("Problem serving Proxool Admin", e); ! } ! ! if (output.equals(OUTPUT_FULL)) { ! closeHtml(response.getOutputStream()); } } ! private void doTabs(ServletOutputStream out, String alias, String link, String tab, boolean statisticsAvailable, boolean statisticsComingSoon) throws IOException { ! out.println("<ul>"); ! out.println("<li class=\"" + (tab.equals(TAB_DEFINITION) ? "active" : "inactive") + "\"><a class=\"quiet\" href=\"" + link + "?alias=" + alias + "&tab=" + TAB_DEFINITION + "\">Definition</a></li>"); ! out.println("<li class=\"" + (tab.equals(TAB_SNAPSHOT) ? "active" : "inactive") + "\"><a class=\"quiet\" href=\"" + link + "?alias=" + alias + "&tab=" + TAB_SNAPSHOT + "\">Snapshot</a></li>"); ! if (statisticsAvailable) { ! out.println("<li class=\"" + (tab.equals(TAB_STATISTICS) ? "active" : "inactive") + "\"><a class=\"quiet\" href=\"" + link + "?alias=" + alias + "&tab=" + TAB_STATISTICS + "\">Statistics</a></li>"); ! } else if (statisticsComingSoon) { ! out.println("<li class=\"disabled\">Statistics</li>"); ! } ! out.println("</ul>"); } ! ! private void doStatistics(ServletOutputStream out, StatisticsIF[] statisticsArray, ConnectionPoolDefinitionIF cpd) throws IOException { for (int i = 0; i < statisticsArray.length; i++) { StatisticsIF statistics = statisticsArray[i]; ! openDataTable(out); ! ! // Period ! printDefinitionEntry(out, "Period", TIME_FORMAT.format(statistics.getStartDate()) + " to " + TIME_FORMAT.format(statistics.getStopDate()), STATISTIC); // Served ! printDefinitionEntry(out, "Served", statistics.getServedCount() + " (" + DECIMAL_FORMAT.format(statistics.getServedPerSecond()) + "/s)", STATISTIC); // Refused ! printDefinitionEntry(out, "Refused", statistics.getRefusedCount() + " (" + DECIMAL_FORMAT.format(statistics.getRefusedPerSecond()) + "/s)", STATISTIC); // averageActiveTime ! printDefinitionEntry(out, "Average active time", DECIMAL_FORMAT.format(statistics.getAverageActiveTime() / 1000) + "s", STATISTIC); // activityLevel *************** *** 177,181 **** int[] lengths = {activityLevel, 100 - activityLevel}; drawBarChart(activityLevelBuffer, colours, lengths); ! printDefinitionEntry(out, "Activity level", activityLevelBuffer.toString()); closeTable(out); --- 247,251 ---- int[] lengths = {activityLevel, 100 - activityLevel}; drawBarChart(activityLevelBuffer, colours, lengths); ! printDefinitionEntry(out, "Activity level", activityLevelBuffer.toString(), STATISTIC); closeTable(out); *************** *** 197,201 **** int length = lengths[j]; if (length > 0) { ! out.append("<td bgcolor=\"#"); out.append(colour); out.append("\" width=\""); --- 267,271 ---- int length = lengths[j]; if (length > 0) { ! out.append("<td style=\"background-color: #"); out.append(colour); out.append("\" width=\""); *************** *** 207,240 **** } ! private void doDefinition(ServletOutputStream out, String alias, String link) throws ProxoolException, IOException { ! ConnectionPoolDefinitionIF cpd = ProxoolFacade.getConnectionPoolDefinition(alias); ! ! out.print("<b>Defintition</b> for "); ! out.println(alias); ! openTable(out); ! ! // url ! printDefinitionEntry(out, "URL", cpd.getUrl()); ! ! // driver ! printDefinitionEntry(out, "Driver", cpd.getDriver()); ! ! // minimumConnectionCount and maximumConnectionCount ! printDefinitionEntry(out, "Connections", cpd.getMinimumConnectionCount() + " (min), " + cpd.getMaximumConnectionCount() + " (max)"); ! ! // prototypeCount ! printDefinitionEntry(out, "Prototyping", cpd.getPrototypeCount() > 0 ? String.valueOf(cpd.getPrototypeCount()) : null); ! ! // maximumConnectionLifetime ! // printDefinitionEntry(out, "Connection Lifetime", TIME_FORMAT.format(new Date(cpd.getMaximumConnectionLifetime() - DATE_OFFSET))); ! printDefinitionEntry(out, "Connection Lifetime", formatMilliseconds(cpd.getMaximumConnectionLifetime())); ! ! // maximumActiveTime ! // printDefinitionEntry(out, "Maximum active time", TIME_FORMAT.format(new Date(cpd.getMaximumActiveTime() - DATE_OFFSET))); ! printDefinitionEntry(out, "Maximum active time", formatMilliseconds(cpd.getMaximumActiveTime())); ! printDefinitionEntry(out, "House keeping sleep time", (cpd.getHouseKeepingSleepTime() / 1000) + "s"); ! // houseKeepingTestSql ! printDefinitionEntry(out, "House keeping test SQL", cpd.getHouseKeepingTestSql()); // fatalSqlExceptions --- 277,302 ---- } ! private void doDefinition(ServletOutputStream out, ConnectionPoolDefinitionIF cpd) throws IOException { ! openDataTable(out); ! printDefinitionEntry(out, ProxoolConstants.ALIAS, cpd.getAlias(), CORE_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.DRIVER_URL, cpd.getUrl(), CORE_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.DRIVER_CLASS, cpd.getDriver(), CORE_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.MINIMUM_CONNECTION_COUNT, String.valueOf(cpd.getMinimumConnectionCount()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.MAXIMUM_CONNECTION_COUNT, String.valueOf(cpd.getMaximumConnectionCount()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.PROTOTYPE_COUNT, cpd.getPrototypeCount() > 0 ? String.valueOf(cpd.getPrototypeCount()) : null, STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE, String.valueOf(cpd.getSimultaneousBuildThrottle()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME, formatMilliseconds(cpd.getMaximumConnectionLifetime()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.MAXIMUM_ACTIVE_TIME, formatMilliseconds(cpd.getMaximumActiveTime()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME, (cpd.getHouseKeepingSleepTime() / 1000) + "s", STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.HOUSE_KEEPING_TEST_SQL, cpd.getHouseKeepingTestSql(), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.TEST_BEFORE_USE, String.valueOf(cpd.isTestBeforeUse()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.TEST_AFTER_USE, String.valueOf(cpd.isTestAfterUse()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.RECENTLY_STARTED_THRESHOLD, formatMilliseconds(cpd.getRecentlyStartedThreshold()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME, formatMilliseconds(cpd.getOverloadWithoutRefusalLifetime()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.INJECTABLE_CONNECTION_INTERFACE_NAME, String.valueOf(cpd.getInjectableConnectionInterface()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.INJECTABLE_STATEMENT_INTERFACE_NAME, String.valueOf(cpd.getInjectableStatementInterface()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME, String.valueOf(cpd.getInjectableCallableStatementInterface()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME, String.valueOf(cpd.getInjectablePreparedStatementInterface()), STANDARD_PROPERTY); // fatalSqlExceptions *************** *** 250,258 **** fatalSqlExceptions = fatalSqlExceptionsBuffer.toString(); } ! printDefinitionEntry(out, "Fatal SQL exceptions", fatalSqlExceptions); ! printDefinitionEntry(out, "Wrapper", cpd.getFatalSqlExceptionWrapper()); ! ! // statistics ! printDefinitionEntry(out, "Statistics", cpd.getStatistics()); closeTable(out); --- 312,331 ---- fatalSqlExceptions = fatalSqlExceptionsBuffer.toString(); } ! printDefinitionEntry(out, ProxoolConstants.FATAL_SQL_EXCEPTION, fatalSqlExceptions, STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS, cpd.getFatalSqlExceptionWrapper(), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.STATISTICS, cpd.getStatistics(), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.STATISTICS_LOG_LEVEL, cpd.getStatisticsLogLevel(), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.VERBOSE, String.valueOf(cpd.isVerbose()), STANDARD_PROPERTY); ! printDefinitionEntry(out, ProxoolConstants.TRACE, String.valueOf(cpd.isTrace()), STANDARD_PROPERTY); ! Properties p = cpd.getDelegateProperties(); ! Iterator i = p.keySet().iterator(); ! while (i.hasNext()) { ! String name = (String) i.next(); ! String value = p.getProperty(name); ! if (name.toLowerCase().indexOf("password") > -1 || name.toLowerCase().indexOf("passwd") > -1) { ! value = "******"; ! } ! printDefinitionEntry(out, name + " (delegated)", value, DELEGATED_PROPERTY); ! } closeTable(out); *************** *** 261,275 **** private void doSnapshot(ServletOutputStream out, String alias, String link, String level, String connectionId) throws IOException, ProxoolException { ! boolean detail = (level != null && level.equals(LEVEL_MORE)); SnapshotIF snapshot = ProxoolFacade.getSnapshot(alias, detail); if (snapshot != null) { ! out.print("<b>Snapshot</b> at "); ! out.println(TIME_FORMAT.format(snapshot.getSnapshotDate())); ! openTable(out); // dateStarted ! printDefinitionEntry(out, "Start date", DATE_FORMAT.format(snapshot.getDateStarted())); // connections --- 334,349 ---- private void doSnapshot(ServletOutputStream out, String alias, String link, String level, String connectionId) throws IOException, ProxoolException { ! boolean detail = (level != null && level.equals(DETAIL_MORE)); SnapshotIF snapshot = ProxoolFacade.getSnapshot(alias, detail); if (snapshot != null) { ! openDataTable(out); // dateStarted ! printDefinitionEntry(out, "Start date", DATE_FORMAT.format(snapshot.getDateStarted()), SNAPSHOT); ! ! // snapshot date ! printDefinitionEntry(out, "Snapshot", TIME_FORMAT.format(snapshot.getSnapshotDate()), SNAPSHOT); // connections *************** *** 289,321 **** snapshot.getMaximumConnectionCount() - snapshot.getActiveConnectionCount() - snapshot.getAvailableConnectionCount()}; drawBarChart(connectionsBuffer, colours, lengths); ! printDefinitionEntry(out, "Connections", connectionsBuffer.toString()); // servedCount ! printDefinitionEntry(out, "Served", String.valueOf(snapshot.getServedCount())); // refusedCount ! printDefinitionEntry(out, "Refused", String.valueOf(snapshot.getRefusedCount())); if (!detail) { out.println(" <tr>"); ! out.print("<td colspan=\"2\" align=\"right\"><a href=\""); ! out.print(link); ! out.print("?"); ! out.print(ALIAS); ! out.print("="); ! out.print(alias); ! out.print("&"); ! out.print(LEVEL); ! out.print("="); ! out.print(LEVEL_MORE); ! out.println("\">more information</a></td>"); out.println(" </tr>"); } else { out.println(" <tr>"); ! out.print(" <td width=\"200\" valign=\"top\" style=\"" + STYLE_CAPTION + "\">"); ! out.print("Details"); ! out.println("</td>"); ! out.print(" <td style=\"" + STYLE_NO_DATA + "\">"); doSnapshotDetails(out, alias, snapshot, link, connectionId); --- 363,390 ---- snapshot.getMaximumConnectionCount() - snapshot.getActiveConnectionCount() - snapshot.getAvailableConnectionCount()}; drawBarChart(connectionsBuffer, colours, lengths); ! printDefinitionEntry(out, "Connections", connectionsBuffer.toString(), SNAPSHOT); // servedCount ! printDefinitionEntry(out, "Served", String.valueOf(snapshot.getServedCount()), SNAPSHOT); // refusedCount ! printDefinitionEntry(out, "Refused", String.valueOf(snapshot.getRefusedCount()), SNAPSHOT); if (!detail) { out.println(" <tr>"); ! out.print(" <td colspan=\"2\" align=\"right\"><form action=\"" + link + "\" method=\"GET\">"); ! out.print("<input type=\"hidden\" name=\"" + ALIAS + "\" value=\"" + alias + "\">"); ! out.print("<input type=\"hidden\" name=\"" + TAB + "\" value=\"" + TAB_SNAPSHOT + "\">"); ! out.print("<input type=\"hidden\" name=\"" + DETAIL + "\" value=\"" + DETAIL_MORE + "\">"); ! out.print("<input type=\"submit\" value=\"More information>\">"); ! out.println("</form></td>"); out.println(" </tr>"); } else { out.println(" <tr>"); ! out.print(" <th width=\"200\" valign=\"top\">"); ! out.print("Details:<br>(click ID to drill down)"); ! out.println("</th>"); ! out.print(" <td>"); doSnapshotDetails(out, alias, snapshot, link, connectionId); *************** *** 324,328 **** out.println(" </tr>"); ! long drillDownConnectionId = 0; if (connectionId != null) { drillDownConnectionId = Long.valueOf(connectionId).longValue(); --- 393,397 ---- out.println(" </tr>"); ! long drillDownConnectionId; if (connectionId != null) { drillDownConnectionId = Long.valueOf(connectionId).longValue(); *************** *** 330,339 **** if (drillDownConnection != null) { out.println(" <tr>"); ! out.print(" <td width=\"200\" valign=\"top\" style=\"" + STYLE_CAPTION + "\">"); out.print("Connection #" + connectionId); out.println("</td>"); ! out.print(" <td style=\"" + STYLE_NO_DATA + "\">"); ! doDrillDownConnection(out, drillDownConnection, link); out.println("</td>"); --- 399,408 ---- if (drillDownConnection != null) { out.println(" <tr>"); ! out.print(" <th valign=\"top\">"); out.print("Connection #" + connectionId); out.println("</td>"); ! out.print(" <td>"); ! doDrillDownConnection(out, drillDownConnection); out.println("</td>"); *************** *** 343,357 **** out.println(" <tr>"); ! out.print("<td colspan=\"2\" align=\"right\"><a href=\""); ! out.print(link); ! out.print("?"); ! out.print(ALIAS); ! out.print("="); ! out.print(alias); ! out.print("&"); ! out.print(LEVEL); ! out.print("="); ! out.print(LEVEL_LESS); ! out.println("\">less information</a></td>"); out.println(" </tr>"); } --- 412,421 ---- out.println(" <tr>"); ! out.print(" <td colspan=\"2\" align=\"right\"><form action=\"" + link + "\" method=\"GET\">"); ! out.print("<input type=\"hidden\" name=\"" + ALIAS + "\" value=\"" + alias + "\">"); ! out.print("<input type=\"hidden\" name=\"" + TAB + "\" value=\"" + TAB_SNAPSHOT + "\">"); ! out.print("<input type=\"hidden\" name=\"" + DETAIL + "\" value=\"" + DETAIL_LESS + "\">"); ! out.print("<input type=\"submit\" value=\"< Less information\">"); ! out.println("</form></td>"); out.println(" </tr>"); } *************** *** 369,381 **** if (snapshot.getConnectionInfos() != null && snapshot.getConnectionInfos().length > 0) { ! out.println("<table cellpadding=\"2\" border=\"0\">"); out.println(" <tbody>"); out.print("<tr>"); ! out.print("<td style=\"font-size: 90%\">#</td>"); ! out.print("<td style=\"font-size: 90%\" align=\"center\">born</td>"); ! out.print("<td style=\"font-size: 90%\" align=\"center\">last<br>start</td>"); ! out.print("<td style=\"font-size: 90%\" align=\"center\">lap<br>(ms)</td>"); ! out.print("<td style=\"font-size: 90%\" width=\"90%\"> thread</td>"); out.print("</tr>"); --- 433,445 ---- if (snapshot.getConnectionInfos() != null && snapshot.getConnectionInfos().length > 0) { ! out.println("<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\">"); out.println(" <tbody>"); out.print("<tr>"); ! out.print("<td>#</td>"); ! out.print("<td align=\"center\">born</td>"); ! out.print("<td align=\"center\">last<br>start</td>"); ! out.print("<td align=\"center\">lap<br>(ms)</td>"); ! out.print("<td> thread</td>"); out.print("</tr>"); *************** *** 389,393 **** // drillDownConnectionId ! out.print("<td bgcolor=\"#"); if (connectionInfo.getStatus() == ConnectionInfoIF.STATUS_ACTIVE) { out.print("ffcccc"); --- 453,457 ---- // drillDownConnectionId ! out.print("<td style=\"background-color: #"); if (connectionInfo.getStatus() == ConnectionInfoIF.STATUS_ACTIVE) { out.print("ffcccc"); *************** *** 412,418 **** out.print(alias); out.print("&"); ! out.print(LEVEL); out.print("="); ! out.print(LEVEL_MORE); out.print("&"); out.print(CONNECTION_ID); --- 476,486 ---- out.print(alias); out.print("&"); ! out.print(TAB); out.print("="); ! out.print(TAB_SNAPSHOT); ! out.print("&"); ! out.print(DETAIL); ! out.print("="); ! out.print(DETAIL_MORE); out.print("&"); out.print(CONNECTION_ID); *************** *** 436,449 **** // active ! out.print("<td align=\"right\">"); if (connectionInfo.getTimeLastStopActive() > 0) { ! out.print((int) (connectionInfo.getTimeLastStopActive() - connectionInfo.getTimeLastStartActive())); } else if (connectionInfo.getTimeLastStartActive() > 0) { ! out.print("<font color=\"red\">"); ! out.print((int) (snapshot.getSnapshotDate().getTime() - connectionInfo.getTimeLastStartActive())); ! out.print("</font>"); ! } else { ! out.print(" "); } out.print(" </td>"); --- 504,517 ---- // active ! out.print("<td align=\"right\" class=\""); ! out.print(getStatusClass(connectionInfo)); ! out.print("\">"); ! String active = " "; if (connectionInfo.getTimeLastStopActive() > 0) { ! active = String.valueOf((int) (connectionInfo.getTimeLastStopActive() - connectionInfo.getTimeLastStartActive())); } else if (connectionInfo.getTimeLastStartActive() > 0) { ! active = String.valueOf((int) (snapshot.getSnapshotDate().getTime() - connectionInfo.getTimeLastStartActive())); } + out.print(active); out.print(" </td>"); *************** *** 464,471 **** } ! private void doDrillDownConnection(ServletOutputStream out, ConnectionInfoIF drillDownConnection, String link) throws IOException { // proxy ! out.print("<div style=\"font-size: 90%\">"); out.print("proxy = "); out.print(drillDownConnection.getProxyHashcode()); --- 532,556 ---- } ! private static String getStatusClass(ConnectionInfoIF info) { ! try { ! return STATUS_CLASSES[info.getStatus()]; ! } catch (ArrayIndexOutOfBoundsException e) { ! LOG.warn("Unknown status: " + info.getStatus()); ! return "unknown-" + info.getStatus(); ! } ! } ! ! private void doDrillDownConnection(ServletOutputStream out, ConnectionInfoIF drillDownConnection) throws IOException { // proxy ! if (drillDownConnection.getLastSqlCall() != null) { ! out.print("<div class=\"drill-down\">"); ! out.print("sql = "); ! out.print(drillDownConnection.getLastSqlCall()); ! out.print("</div>"); ! } ! ! // proxy ! out.print("<div class=\"drill-down\">"); out.print("proxy = "); out.print(drillDownConnection.getProxyHashcode()); *************** *** 473,477 **** // delegate ! out.print("<div style=\"font-size: 90%\">"); out.print("delegate = "); out.print(drillDownConnection.getDelegateHashcode()); --- 558,562 ---- // delegate ! out.print("<div class=\"drill-down\">"); out.print("delegate = "); out.print(drillDownConnection.getDelegateHashcode()); *************** *** 479,483 **** // url ! out.print("<div style=\"font-size: 90%\">"); out.print("url = "); out.print(drillDownConnection.getDelegateUrl()); --- 564,568 ---- // url ! out.print("<div class=\"drill-down\">"); out.print("url = "); out.print(drillDownConnection.getDelegateUrl()); *************** *** 487,491 **** private void openHtml(ServletOutputStream out) throws IOException { ! out.println("<html><header><title>Proxool Admin</title></header><body BGCOLOR=\"#eeeeee\">"); } --- 572,601 ---- private void openHtml(ServletOutputStream out) throws IOException { ! out.println("<html><header><title>Proxool Admin</title>"); ! if (cssFile != null) { ! out.println("<script type=\"text/css\" src=\"" + cssFile + "\"></script>"); ! } else { ! out.println("<style>"); ! out.println("body {background-color: #93bde6;}\n" + ! "div.version {font-weight: bold; font-size: 100%; margin-bottom: 8px;}\n" + ! "h1 {font-weight: bold; font-size: 100%}\n" + ! "table.data {font-size: 90%; border-collapse: collapsed; border: 1px solid black;}\n" + ! "table.data th {background: #bddeff; width: 200px; text-align: left; padding-right: 8px; font-weight: normal;}\n" + ! "table.data td {background: #ffffff; vertical-align: top;}\n" + ! "td.null {background: yellow;}\n" + ! "td.available {font-color: black;}\n" + ! "td.active {font-color: red;}\n" + ! "td.offline {font-color: blue;}\n" + ! "div.drill-down {}\n" + ! "ul {list-style: none; padding: 0px; margin: 0px; position: relative;}\n" + ! "li {padding: 0px; margin: 0px 4px 0px 0px; display: inline; border: 1px solid black; border-width: 1px 1px 0px 1px;}\n" + ! "li.active {background: #bddeff;}\n" + ! "li.inactive {background: #eeeeee;}\n" + ! "li.disabled {background: #dddddd; color: #999999; padding: 0px 4px 0px 4px;}\n" + ! "a.quiet {color: black; text-decoration: none; padding: 0px 4px 0px 4px; }\n" + ! "a.quiet:hover {background: white;}\n"); ! out.println("</style>"); ! } ! out.println("</header><body>"); } *************** *** 494,499 **** } ! private void openTable(ServletOutputStream out) throws IOException { ! out.println("<table width=\"550\" cellpadding=\"2\" cellspacing=\"2\" border=\"0\" bgcolor=\"#EEEEEE\" style=\"border: 1px solid black\">"); out.println(" <tbody>"); } --- 604,609 ---- } ! private void openDataTable(ServletOutputStream out) throws IOException { ! out.println("<table cellpadding=\"2\" cellspacing=\"0\" border=\"1\" class=\"data\">"); out.println(" <tbody>"); } *************** *** 506,519 **** ! private void printDefinitionEntry(ServletOutputStream out, String name, String value) throws IOException { out.println(" <tr>"); ! out.print(" <td width=\"200\" valign=\"top\" style=\"" + STYLE_CAPTION + "\">"); out.print(name); ! out.println("</td>"); ! if (value != null) { ! out.print(" <td style=\"" + STYLE_DATA + "\">"); out.print(value); } else { ! out.print(" <td style=\"" + STYLE_NO_DATA + "\">off"); } out.print("</td>"); --- 616,629 ---- ! private void printDefinitionEntry(ServletOutputStream out, String name, String value, String type) throws IOException { out.println(" <tr>"); ! out.print(" <th valign=\"top\">"); out.print(name); ! out.println(":</th>"); ! out.print(" <td class=\"" + type + "\"nowrap>"); ! if (value != null && !value.equals("null")) { out.print(value); } else { ! out.print("-"); } out.print("</td>"); *************** *** 521,553 **** } ! private void doList(ServletOutputStream out, String alias, String link, String level) throws IOException, ProxoolException { ! ! out.print("<b>Pools</b>"); ! openTable(out); String[] aliases = ProxoolFacade.getAliases(); - for (int i = 0; i < aliases.length; i++) { - String a = aliases[i]; - String style = ""; - if (a.equals(alias)) { - style = "background: white;"; - } - ConnectionPoolDefinitionIF cpd = ProxoolFacade.getConnectionPoolDefinition(a); - out.println(" <tr style=\"" + style + "\">"); ! out.print(" <td width=\"200\" style=\"" + STYLE_CAPTION + "\">"); ! out.print(a.equals(alias) ? ">" : " "); ! out.println("</td>"); ! ! out.print(" <td><a href=\"" + link + "?" + ALIAS + "=" + a + "&" + LEVEL + "=" + level + "\">"); ! out.print(a); ! out.println("</a> -> "); ! out.print(cpd.getUrl()); ! out.println("</td>"); ! out.println(" </tr>"); } - - closeTable(out); - } --- 631,659 ---- } ! private void doList(ServletOutputStream out, String alias, String tab, String link) throws IOException { String[] aliases = ProxoolFacade.getAliases(); ! if (aliases.length == 0) { ! out.println("<p>No pools have been registered.</p>"); ! } else if (aliases.length == 1) { ! // Don't bother listing. Just show it. ! } else { ! out.println("<form action=\"" + link + "\" method=\"GET\" name=\"alias\">"); ! out.println("<select name=\"alias\" size=\"" + Math.min(aliases.length, 5) + "\""); ! for (int i = 0; i < aliases.length; i++) { ! out.print(" <option value=\""); ! out.print(aliases[i]); ! out.print("\""); ! out.print(aliases[i].equals(alias) ? " selected" : ""); ! out.print(">"); ! out.print(aliases[i]); ! out.println("</option>"); ! } ! out.println("</select>"); ! out.println("<input name=\"" + TAB + "\" value=\"" + tab + "\" type=\"hidden\">"); ! out.println("<input value=\"Show\" type=\"submit\">"); ! out.println("</form>"); } } *************** *** 570,573 **** --- 676,682 ---- Revision history: $Log$ + Revision 1.9 2005/09/26 13:31:14 billhorsman + Smartened up AdminServlet + Revision 1.8 2003/09/29 17:49:19 billhorsman Includes new fatal-sql-exception-wrapper-class in display |