public void run() {
Boolean isHealthy = false;
try {
ArrayList<HttpListener> enabledListeners = new ArrayList<HttpListener>();
Server serv = instance.getServer();
ConfigContext cfgCtx = InstanceHangAction.configCtx;
Config cfg = ServerHelper.getConfigForServer(cfgCtx, serv.getName());
// get http-listeners on this server
HttpService httpSrv = cfg.getHttpService();
HttpListener[] listeners = httpSrv.getHttpListener();
for (HttpListener listener : listeners) {
if (listener.isEnabled()) {
enabledListeners.add(listener);
//count++;
}
}
int size = enabledListeners.size();
ExecutorService exSrv = Executors.newFixedThreadPool(size);
ArrayList<Future<Boolean>> checkTasks = new ArrayList<Future<Boolean>>(size);
int timeout = instance.getTimeout();
int i = 0;
for (HttpListener listener : enabledListeners) {
Callable<Boolean> checkListener = new CheckListenerHealth(serv,
listener,
timeout);
Future<Boolean> task = exSrv.submit(checkListener);
checkTasks.add(task);
}
// wait for status from the checks
for (Future<Boolean> task : checkTasks) {
isHealthy = task.get();
if (isHealthy) {
//found atleast one healthy listener on the instance
if (instance.getClusterName()!=null) {
_logger.log(Level.INFO,"sgmt.instancehang_clserverhealthy",
new Object[]{serv.getName(),instance.getClusterName()});
} else {
_logger.log(Level.INFO,"sgmt.instancehang_serverhealthy",
serv.getName());
}
break;
}
}
if(!isHealthy) {
String cName = instance.getClusterName();
if (cName!=null) {
//clustered server
_logger.log(Level.WARNING,"sgmt.instancehang_clserverunhealthy",
new Object[]{cName,serv.getName()});
} else {
//standalone server
_logger.log(Level.WARNING,"sgmt.instancehang_serverunhealthy",
serv.getName());
}
}
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
} catch (ExecutionException ex) {