use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse 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;
}
use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse in project kylo by Teradata.
the class ClouderaServicesStatusCheck method healthCheck.
@Override
public List<ServiceStatusResponse> healthCheck() {
List<ServiceStatusResponse> serviceStatusResponseList = new ArrayList<>();
// Get the Map of Services and optional Components we are tracking
Map<String, List<String>> definedServiceComponentMap = ServiceMonitorCheckUtil.getMapOfServiceAndComponents(services);
if (definedServiceComponentMap != null && !definedServiceComponentMap.isEmpty()) {
ClouderaRootResource rootResource;
try {
rootResource = clouderaClient.getClouderaResource();
if (rootResource == null) {
throw new Exception("The Cloudera Resource is null... It may still be trying to initialize the Rest Client.");
}
ApiClusterList clusters = rootResource.getPopulatedClusterList();
for (ApiCluster cluster : clusters.getClusters()) {
String clusterName = cluster.getName();
List<ApiService> services = cluster.getServices();
for (ApiService service : services) {
List<ServiceComponent> serviceComponents = new ArrayList<>();
List<ServiceAlert> alerts = new ArrayList<>();
String serviceName = service.getType();
if (definedServiceComponentMap.containsKey(serviceName)) {
service.getHealthSummary();
List<ApiHealthCheck> healthChecks = service.getHealthChecks();
for (ApiHealthCheck healthCheck : healthChecks) {
alerts.add(apiHealthCheckToServiceAlert(null, healthCheck));
}
List<ApiRole> roles = service.getRoles();
for (ApiRole role : roles) {
String roleName = role.getType();
role.getHealthSummary();
List<ApiHealthCheck> roleHealthChecks = role.getHealthChecks();
ServiceComponent.STATE roleState = apiRoleStateToServiceComponentState(role.getRoleState());
List<ServiceAlert> componentAlerts = new ArrayList<>();
for (ApiHealthCheck healthCheck : roleHealthChecks) {
ServiceAlert alert = apiHealthCheckToServiceAlert(roleName, healthCheck);
alerts.add(alert);
componentAlerts.add(alert);
}
ServiceComponent component = new DefaultServiceComponent.Builder(roleName, roleState).clusterName(clusterName).message(role.getRoleState().name()).alerts(componentAlerts).build();
if (definedServiceComponentMap.containsKey(serviceName) && (definedServiceComponentMap.get(serviceName).contains(ServiceMonitorCheckUtil.ALL_COMPONENTS) || definedServiceComponentMap.get(serviceName).contains(component.getName()))) {
serviceComponents.add(component);
}
}
ServiceStatusResponse serviceStatusResponse = new DefaultServiceStatusResponse(serviceName, serviceComponents, alerts);
serviceStatusResponseList.add(serviceStatusResponse);
}
}
}
} catch (Exception e) {
Throwable cause;
if (e.getCause() != null) {
cause = e.getCause();
} else {
cause = e;
}
ServiceComponent clouderaServiceComponent = new DefaultServiceComponent.Builder("Cloudera REST_CLIENT", ServiceComponent.STATE.DOWN).serviceName("Cloudera").clusterName("UNKNOWN").exception(cause).build();
List<ServiceComponent> clouderaComponents = new ArrayList<>();
clouderaComponents.add(clouderaServiceComponent);
ServiceStatusResponse serviceStatusResponse = new DefaultServiceStatusResponse(clouderaServiceComponent.getServiceName(), clouderaComponents);
serviceStatusResponseList.add(serviceStatusResponse);
// add the other services as being Warnings
addClouderaServiceErrors(cause.getMessage(), serviceStatusResponseList, definedServiceComponentMap);
}
}
return serviceStatusResponseList;
}
Aggregations