Search in sources :

Example 1 with ServiceStatusCheck

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;
}
Also used : ServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.ServiceStatusResponse) ArrayList(java.util.ArrayList) Callable(java.util.concurrent.Callable) BeansException(org.springframework.beans.BeansException) ServicesStatusCheck(com.thinkbiganalytics.servicemonitor.check.ServicesStatusCheck) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) ArrayList(java.util.ArrayList) List(java.util.List) ServiceStatusCheck(com.thinkbiganalytics.servicemonitor.check.ServiceStatusCheck)

Aggregations

ServiceStatusCheck (com.thinkbiganalytics.servicemonitor.check.ServiceStatusCheck)1 ServicesStatusCheck (com.thinkbiganalytics.servicemonitor.check.ServicesStatusCheck)1 ServiceStatusResponse (com.thinkbiganalytics.servicemonitor.model.ServiceStatusResponse)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 BeansException (org.springframework.beans.BeansException)1