use of com.thinkbiganalytics.servicemonitor.check.ServiceStatusCheck in project kylo by Teradata.
the class ServiceMonitorManager method doServiceCheck.
/**
* Run a service check on the system.
* Each service will run in a separate thread and return status back
*
* @return a list of service status objects
*/
public List<ServiceStatusResponse> doServiceCheck() {
List<ServiceStatusResponse> serviceHealthResponseList = new ArrayList<ServiceStatusResponse>();
if (totalServices > 0) {
ExecutorService pool = Executors.newFixedThreadPool(totalServices);
List<Callable<List<ServiceStatusResponse>>> tasks = new ArrayList<>();
for (ServiceStatusCheck serviceHealth : services) {
tasks.add(serviceCheckAsCallable(serviceHealth));
}
for (ServicesStatusCheck serviceHealth : servicesHealth) {
tasks.add(servicesCheckAsCallable(serviceHealth));
}
try {
List<Future<List<ServiceStatusResponse>>> results = pool.invokeAll(tasks);
for (Future<List<ServiceStatusResponse>> result : results) {
try {
List<ServiceStatusResponse> responses = result.get();
if (responses != null) {
for (ServiceStatusResponse response : responses) {
if (response != null) {
serviceHealthResponseList.add(response);
}
}
}
} catch (Exception e) {
}
}
} catch (Exception e) {
}
pool.shutdown();
}
notifyAlerts(serviceHealthResponseList);
return serviceHealthResponseList;
}
Aggregations