Search in sources :

Example 1 with AlertSummary

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

the class AmbariServicesStatusCheck method healthCheck.

/**
 * https://github.com/apache/ambari/blob/trunk/ambari-server/docs/api/v1/host-component-resources.md
 *
 * State 	Description                                                                          <br>
 * INIT 	The initial clean state after the component is first created.                        <br>
 * INSTALLING 	In the process of installing the component.                                  <br>
 * INSTALL_FAILED 	The component install failed.                                                <br>
 * INSTALLED 	The component has been installed successfully but is not currently running.  <br>
 * STARTING 	In the process of starting the component.                                    <br>
 * STARTED 	The component has been installed and started.                                        <br>
 * STOPPING 	In the process of stopping the component.                                    <br>
 * UNINSTALLING 	In the process of uninstalling the component.                                <br>
 * UNINSTALLED 	The component has been successfully uninstalled.                             <br>
 * WIPING_OUT 	In the process of wiping out the installed component.                        <br>
 * UPGRADING 	In the process of upgrading the component.                                   <br>
 * MAINTENANCE 	The component has been marked for maintenance.                               <br>
 * UNKNOWN 	The component state can not be determined.                                           <br>
 */
@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()) {
        try {
            AmbariClient client = ambariClient;
            // get the Clusers from ambari
            List<String> clusterNames = client.getAmbariClusterNames();
            // get the Service Status from Ambari
            ServiceComponentInfoSummary response = client.getServiceComponentInfo(clusterNames, services);
            // get alert info for these services as well
            AlertSummary alertSummary = client.getAlerts(clusterNames, services);
            // Convert the Ambari Alerts to the Pipeline Controller Alert
            List<ServiceAlert> serviceAlerts = transformAmbariAlert(alertSummary);
            // Convert the Ambari ServiceComponentInfo objects to Pipeline Controller ServiceComponents
            serviceStatusResponseList = transformAmbariServiceComponents(response, serviceAlerts, definedServiceComponentMap);
        } catch (RestClientException e) {
            Throwable cause;
            if (e.getCause() != null) {
                cause = e.getCause();
            } else {
                cause = e;
            }
            ServiceComponent ambariServiceComponent = new DefaultServiceComponent.Builder("Unknown", "Ambari", "Ambari REST_CLIENT", ServiceComponent.STATE.DOWN).exception(cause).build();
            List<ServiceComponent> ambariComponents = new ArrayList<>();
            ambariComponents.add(ambariServiceComponent);
            ServiceStatusResponse serviceStatusResponse = new DefaultServiceStatusResponse(ambariServiceComponent.getServiceName(), ambariComponents);
            serviceStatusResponseList.add(serviceStatusResponse);
            // add the other services as being Warnings
            addAmbariServiceErrors(cause.getMessage(), serviceStatusResponseList, definedServiceComponentMap);
        }
    }
    return serviceStatusResponseList;
}
Also used : ServiceComponentInfoSummary(com.thinkbiganalytics.servicemonitor.rest.model.ambari.ServiceComponentInfoSummary) DefaultServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse) ServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.ServiceStatusResponse) 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) RestClientException(org.springframework.web.client.RestClientException) ArrayList(java.util.ArrayList) List(java.util.List) AlertSummary(com.thinkbiganalytics.servicemonitor.rest.model.ambari.AlertSummary) AmbariClient(com.thinkbiganalytics.servicemonitor.rest.client.ambari.AmbariClient)

Example 2 with AlertSummary

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

the class AmbariJerseyClient method getAlerts.

/**
 * @see AmbariClient#getAlerts(List, String)
 */
public AlertSummary getAlerts(List<String> clusterNames, String services) throws RestClientException {
    AlertSummary alerts = null;
    for (String clusterName : clusterNames) {
        AmbariAlertsCommand alertsCommand = new AmbariAlertsCommand(clusterName, services);
        AlertSummary alertSummary = get(alertsCommand);
        if (alerts == null) {
            alerts = alertSummary;
        } else {
            alerts.getItems().addAll(alertSummary.getItems());
        }
    }
    return alerts;
}
Also used : AlertSummary(com.thinkbiganalytics.servicemonitor.rest.model.ambari.AlertSummary)

Aggregations

AlertSummary (com.thinkbiganalytics.servicemonitor.rest.model.ambari.AlertSummary)2 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 AmbariClient (com.thinkbiganalytics.servicemonitor.rest.client.ambari.AmbariClient)1 ServiceComponentInfoSummary (com.thinkbiganalytics.servicemonitor.rest.model.ambari.ServiceComponentInfoSummary)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RestClientException (org.springframework.web.client.RestClientException)1