Search in sources :

Example 1 with ServiceComponentInfoItem

use of com.thinkbiganalytics.servicemonitor.rest.model.ambari.ServiceComponentInfoItem in project kylo by Teradata.

the class AmbariServicesStatusCheck method transformAmbariServiceComponents.

/**
 * Convert Ambari ServiceComponentInfo into  ServiceComponent objects
 */
private List<ServiceStatusResponse> transformAmbariServiceComponents(ServiceComponentInfoSummary ambariServiceComponents, List<ServiceAlert> serviceAlerts, Map<String, List<String>> definedServiceComponentMap) {
    List<ServiceStatusResponse> list = new ArrayList<>();
    if (ambariServiceComponents != null) {
        Map<String, List<ServiceComponent>> serviceComponentMap = new HashMap<>();
        for (ServiceComponentInfoItem item : ambariServiceComponents.getItems()) {
            ServiceComponent.STATE state = getServiceComponentState(item);
            String message = item.getServiceComponentInfo().getState();
            String name = item.getServiceComponentInfo().getComponentName();
            String serviceName = item.getServiceComponentInfo().getServiceName();
            String clusterName = item.getServiceComponentInfo().getClusterName();
            ServiceComponent component = new DefaultServiceComponent.Builder(clusterName, serviceName, name, state).alerts(alertsForComponent(serviceAlerts, item.getServiceComponentInfo().getComponentName())).message(message).build();
            if (!serviceComponentMap.containsKey(component.getServiceName())) {
                serviceComponentMap.put(component.getServiceName(), new ArrayList<>());
            }
            if (definedServiceComponentMap.get(component.getServiceName()).contains(ServiceMonitorCheckUtil.ALL_COMPONENTS) || definedServiceComponentMap.get(component.getServiceName()).contains(component.getName())) {
                serviceComponentMap.get(component.getServiceName()).add(component);
            }
        }
        // build the response
        for (Map.Entry<String, List<ServiceComponent>> entry : serviceComponentMap.entrySet()) {
            List<ServiceAlert> alertsForService = alertsForService(serviceAlerts, entry.getKey());
            ServiceStatusResponse serviceStatusResponse = new DefaultServiceStatusResponse(entry.getKey(), entry.getValue(), alertsForService);
            if (ServiceStatusResponse.STATE.DOWN.equals(serviceStatusResponse.getState())) {
                notifyServiceDown(serviceStatusResponse);
            } else if (ServiceStatusResponse.STATE.UP.equals(serviceStatusResponse.getState())) {
                notifyServiceUp(serviceStatusResponse);
            }
            list.add(serviceStatusResponse);
        }
    }
    return list;
}
Also used : DefaultServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse) ServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.ServiceStatusResponse) HashMap(java.util.HashMap) DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) ServiceComponent(com.thinkbiganalytics.servicemonitor.model.ServiceComponent) ArrayList(java.util.ArrayList) DefaultServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse) DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) ServiceComponentInfoItem(com.thinkbiganalytics.servicemonitor.rest.model.ambari.ServiceComponentInfoItem) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

DefaultServiceAlert (com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert)1 DefaultServiceComponent (com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent)1 DefaultServiceStatusResponse (com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse)1 ServiceAlert (com.thinkbiganalytics.servicemonitor.model.ServiceAlert)1 ServiceComponent (com.thinkbiganalytics.servicemonitor.model.ServiceComponent)1 ServiceStatusResponse (com.thinkbiganalytics.servicemonitor.model.ServiceStatusResponse)1 ServiceComponentInfoItem (com.thinkbiganalytics.servicemonitor.rest.model.ambari.ServiceComponentInfoItem)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1