for(Component component : domainComposite.getComponents()) {
for(Service service : component.getServices()) {
Interface interfaceContract = service.getInterfaceContract().getInterface();
if(Manageable.class.getName().equals(interfaceContract.toString())) {
Status status = new Status();
status.setName(component.getName());
status.setUri(service.getBindings().get(0).getURI());
try {
String serviceName = component.getName() + "/" + service.getName();
Manageable serviceInstance = node.getService(Manageable.class, serviceName);
Timer t = new Timer();
serviceInstance.isAlive();
status.setExecution(t.elapsed(TimeUnit.MILLISECONDS));
if(status.getExecution() < warningThreshold) {
status.setStatus(Status.OK);
}else if(status.getExecution() > warningThreshold) {
status.setStatus(Status.WARNING);
}else if(status.getExecution() > criticalThreshold) {
status.setStatus(Status.CRITICAL);
} else {
status.setStatus(Status.UNAVAILABLE);
}
} catch (Exception e) {
status.setStatus(Status.UNAVAILABLE);
status.setStatusMessage(e.getMessage());
}
statuses.add(status);
}
}