List<MessageDescriptor> statusList = new ArrayList<MessageDescriptor>();
List<ServerDescriptor> servers = AServerDescriptorDAO.getServerDescriptors();
for (int i = 0; i < servers.size(); i++) {
MessageDescriptor md = new MessageDescriptor(servers.get(i));
try {
String rawContent = getRawContent(md.getServerUrl());
Matcher m = ACTIVE_CONNECTIONS_PATTERN.matcher(rawContent);
if (m.find()) {
md.setCurrentConnections(Integer.parseInt(m.group(1)));
}
} catch (IOException e) {
md.setDown(true);
}
statusList.add(md);
if (md.hasProblem()) {
md.setWhen(new Date());
String key = AMessageDAO.createMessageDescriptor(md);
Queue queue = QueueFactory.getQueue("serverError");
TaskOptions taskOptions = TaskOptions.Builder.withUrl("/sendAll").param(SendMessageServlet.PARAMETER_SERVER, key).method(Method.POST);
queue.add(taskOptions);