* @param level either {@link #DETAIL_LESS} or {@link #DETAIL_MORE}
* @param connectionId the connection we want to drill into (optional)
*/
private void doSnapshot(ServletOutputStream out, ConnectionPoolDefinitionIF cpd, String link, String level, String connectionId) throws IOException, ProxoolException {
boolean detail = (level != null && level.equals(DETAIL_MORE));
SnapshotIF snapshot = ProxoolFacade.getSnapshot(cpd.getAlias(), detail);
if (snapshot != null) {
openDataTable(out);
printDefinitionEntry(out, ProxoolConstants.ALIAS, cpd.getAlias(), CORE_PROPERTY);
// dateStarted
printDefinitionEntry(out, "Start date", DATE_FORMAT.format(snapshot.getDateStarted()), SNAPSHOT);
// snapshot date
printDefinitionEntry(out, "Snapshot", TIME_FORMAT.format(snapshot.getSnapshotDate()), SNAPSHOT);
// connections
StringBuffer connectionsBuffer = new StringBuffer();
connectionsBuffer.append(snapshot.getActiveConnectionCount());
connectionsBuffer.append(" (active), ");
connectionsBuffer.append(snapshot.getAvailableConnectionCount());
connectionsBuffer.append(" (available), ");
if (snapshot.getOfflineConnectionCount() > 0) {
connectionsBuffer.append(snapshot.getOfflineConnectionCount());
connectionsBuffer.append(" (offline), ");
}
connectionsBuffer.append(snapshot.getMaximumConnectionCount());
connectionsBuffer.append(" (max)<br/>");
String[] colours = {"ff9999", "66cc66", "cccccc"};
int[] lengths = {snapshot.getActiveConnectionCount(), snapshot.getAvailableConnectionCount(),
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=\"" + cpd.getAlias() + "\">");
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, cpd, snapshot, link, connectionId);
out.println("</td>");
out.println(" </tr>");
long drillDownConnectionId;
if (connectionId != null) {
drillDownConnectionId = Long.valueOf(connectionId).longValue();
ConnectionInfoIF drillDownConnection = snapshot.getConnectionInfo(drillDownConnectionId);
if (drillDownConnection != null) {
out.println(" <tr>");
out.print(" <th valign=\"top\">");
out.print("Connection #" + connectionId);
out.println("</td>");