Boolean wasError = newInstanceStatus.get(serverBase);
newInstanceStatus.put(serverBase, true);
newInstanceErrorInformation.remove(serverBase);
if(wasError != null && wasError)
{
NotificationMessage serverErrorMessage = new NotificationMessage("Server available after being unavailable", serverBase, "SYSTEM", NotificationMessage.SERVER_UNAVAILABLE_SOLVED, "n/a", serverBase);
TransactionHistoryController.getController().create(serverErrorMessage);
}
}
}
catch(Exception e)
{
if(address.contains("Preview"))
logger.info("Error in instance monitor: " + serverBase + ", Message: " + e.getMessage());
else
logger.warn("Error in instance monitor: " + serverBase + ", Message: " + e.getMessage());
try
{
String cause = "" + e.getMessage();
if(e instanceof FileNotFoundException)
cause = "Application not found";
else if(e instanceof SocketTimeoutException)
cause = "" + e.getMessage();
NotificationMessage serverErrorMessage = new NotificationMessage("Server down!: " + cause, serverBase, "SYSTEM", NotificationMessage.SERVER_UNAVAILABLE, "n/a", serverBase);
TransactionHistoryController.getController().create(serverErrorMessage);
}
catch (Exception e2)
{
logger.error("Error adding transaction history log for error: " + e2.getMessage(), e);
}
newInstanceStatus.put(serverBase, false);
Integer retries = newInstanceErrorInformation.get(serverBase);
if(retries == null)
{
retries = 0;
}
newInstanceErrorInformation.put(serverBase, retries+1);
boolean isDivisibleBy10 = retries % 10 == 0;
if(retries == 0 || isDivisibleBy10)
{
logger.error("A deliver instance is down or unresponsive. Tested instance: " + address + ". Message: " + e.getMessage());
sendWarningMail(serverBase);
}
/*
if(retries == 20)
{
ViewMessageCenterAction.addSystemMessage("administrator", ViewMessageCenterAction.SYSTEM_MESSAGE_TYPE, "alert('One server is down: " + serverBase + "');");
}
*/
}
}
List publicDeliveryUrls = CmsPropertyHandler.getPublicDeliveryUrls();
Iterator publicDeliveryUrlsIterator = publicDeliveryUrls.iterator();
while(publicDeliveryUrlsIterator.hasNext())
{
String serverBase = "" + publicDeliveryUrlsIterator.next();
String address = serverBase + "/UpdateCache!test.action";
try
{
HttpHelper httpHelper = new HttpHelper();
String response = httpHelper.getUrlContent(address, new HashMap(), null, 5000);
if(response.indexOf("test ok") == -1)
throw new Exception("Got wrong answer");
else
{
Boolean wasError = newInstanceStatus.get(serverBase);
newInstanceStatus.put(serverBase, true);
newInstanceErrorInformation.remove(serverBase);
if(wasError != null && wasError)
{
NotificationMessage serverErrorMessage = new NotificationMessage("Server available after being unavailable", serverBase, "SYSTEM", NotificationMessage.SERVER_UNAVAILABLE_SOLVED, "n/a", serverBase);
TransactionHistoryController.getController().create(serverErrorMessage);
}
}
}
catch(Exception e)
{
logger.info("Error in instance monitor: " + serverBase + ", Message: " + e.getMessage());
try
{
String cause = "" + e.getMessage();
if(e instanceof FileNotFoundException)
cause = "Application not found";
else if(e instanceof SocketTimeoutException)
cause = "" + e.getMessage();
NotificationMessage serverErrorMessage = new NotificationMessage("Server down!: " + cause, serverBase, "SYSTEM", NotificationMessage.SERVER_UNAVAILABLE, "n/a", serverBase);
TransactionHistoryController.getController().create(serverErrorMessage);
}
catch (Exception e2)
{
logger.error("Error adding transaction history log for error: " + e2.getMessage(), e);