}
ps.println("</table>");
DistributedQueueState dqs = dqm.getDistributedQueueState();
ps.println("<h1>Distributed Queue State - Viewed By Remote Broker</h1>");
ps.println("<table>");
ps.println("<tr><th>Remote Broker</th><th>Area</th><th>State</th><th>State Time</th><th>Last Available Date</th><th>Last Error Message</th></tr>");
// sort brokers by name (url)
TreeMap<String,RemoteBrokerInfo> sortedRemoteBrokers = new TreeMap<String,RemoteBrokerInfo>();
for (RemoteBrokerInfo bi : dqs.getRemoteBrokers().values()) {
sortedRemoteBrokers.put(bi.getUrl(), bi);
}
for (RemoteBrokerInfo bi : sortedRemoteBrokers.values()) {
ps.print("<tr><td>");
ps.print(bi.getUrl());
ps.print("</td><td>");
ps.print(bi.getAreaId());
ps.print("</td><td>");
ps.print(RemoteBrokerInfo.STATES[bi.getState()]);
ps.print("</td><td>");
long stateDuration = System.currentTimeMillis() - bi.getLastStateChangedTime();
//ps.print(formatter.print(new Period(stateDuration)));
ps.print(PeriodFormatterUtil.toLinuxUptimeStyleString(stateDuration));
ps.print("</td><td>");
ps.print((bi.getLastAvailableTime() <= 0 ? "Never" : new DateTime(bi.getLastAvailableTime())));
ps.print("</td><td>");
ps.print((bi.getLastErrorMessage() == null ? "" : bi.getLastErrorMessage()));
ps.print("</td></tr>");
// print out queues if they exist
if (bi.getRemoteQueues().size() > 0) {
ps.print("<tr class=\"queue\"><td colspan=6>");
ps.print(" > Remote Queues: ");
// sort by name
TreeSet<String> sortedRemoteQueues = new TreeSet<String>();
for (String q : bi.getRemoteQueues()) {
sortedRemoteQueues.add(q);
}
// print them out
int i = 0;
for (String q : sortedRemoteQueues) {
if (i != 0) ps.print(", ");
ps.print(q);
i++;
}
ps.print("</td></tr>");
}
}
ps.println("</table>");
ps.println("<h1>Distributed Queue State - Viewed By Remote Queue</h1>");
ps.println("<table>");
ps.println("<tr><th>Queue Name</th><th>State</th><th>State Time</th><th>Remote Brokers</th></tr>");
if (dqs.getRemoteQueues().size() <= 0) {
ps.println("<tr><td colspan=3>None</td></tr>");
} else {
// sort queues by name (url)
TreeMap<String,RemoteQueueInfo> sortedRemoteQueues = new TreeMap<String,RemoteQueueInfo>();
for (RemoteQueueInfo qi : dqs.getRemoteQueues().values()) {
sortedRemoteQueues.put(qi.getName(), qi);
}
for (RemoteQueueInfo qi : sortedRemoteQueues.values()) {
ps.print("<tr><td>");