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;
}
Aggregations