Search in sources :

Example 1 with ApiService

use of com.cloudera.api.model.ApiService in project components by Talend.

the class HadoopCMCluster method getHostedServices.

@Override
public Map<HadoopHostedService, HadoopClusterService> getHostedServices() {
    ApiServiceList services = cluster.readServices(DataView.SUMMARY);
    Map<HadoopHostedService, HadoopClusterService> servicesMapping = new HashMap<HadoopHostedService, HadoopClusterService>();
    for (ApiService service : services.getServices()) {
        if (HadoopHostedService.isSupport(service.getType())) {
            HadoopCMClusterService clusterService = new HadoopCMClusterService(service.getName(), cluster, blacklistParams);
            if (clusterService.hasConfigurations()) {
                servicesMapping.put(HadoopHostedService.fromString(service.getType()), clusterService);
            }
        }
    }
    return servicesMapping;
}
Also used : HashMap(java.util.HashMap) ApiService(com.cloudera.api.model.ApiService) ApiServiceList(com.cloudera.api.model.ApiServiceList)

Example 2 with ApiService

use of com.cloudera.api.model.ApiService in project kylo by Teradata.

the class DefaultClouderaRootResource method getPopulatedClusterList.

/**
 * @return cluster list with initialised service health status
 */
public ApiClusterList getPopulatedClusterList() {
    ApiClusterList clusters = rootResource.getClustersResource().readClusters(DataView.SUMMARY);
    if (clusters != null && clusters.getClusters() != null) {
        for (ApiCluster cluster : clusters.getClusters()) {
            String clusterName = cluster.getName();
            ApiServiceList services = rootResource.getClustersResource().getServicesResource(clusterName).readServices(DataView.SUMMARY);
            if (services != null && services.getServices() != null) {
                cluster.setServices(services.getServices());
                for (ApiService service : services.getServices()) {
                    String serviceName = service.getName();
                    ApiHealthSummary healthSummary = service.getHealthSummary();
                    List<ApiHealthCheck> healthChecks = service.getHealthChecks();
                    service.setHealthChecks(healthChecks);
                    service.setHealthSummary(healthSummary);
                    ApiRoleList roles = rootResource.getClustersResource().getServicesResource(clusterName).getRolesResource(serviceName).readRoles();
                    if (roles != null && roles.getRoles() != null) {
                        service.setRoles(roles.getRoles());
                        for (ApiRole role : roles.getRoles()) {
                            ApiHealthSummary roleHealthSummary = role.getHealthSummary();
                            List<ApiHealthCheck> roleHealthChecks = role.getHealthChecks();
                            role.setHealthSummary(roleHealthSummary);
                            role.setHealthChecks(roleHealthChecks);
                        }
                    }
                }
            }
        }
    }
    return clusters;
}
Also used : ApiRole(com.cloudera.api.model.ApiRole) ApiClusterList(com.cloudera.api.model.ApiClusterList) ApiCluster(com.cloudera.api.model.ApiCluster) ApiService(com.cloudera.api.model.ApiService) ApiHealthCheck(com.cloudera.api.model.ApiHealthCheck) ApiRoleList(com.cloudera.api.model.ApiRoleList) ApiServiceList(com.cloudera.api.model.ApiServiceList) ApiHealthSummary(com.cloudera.api.model.ApiHealthSummary)

Example 3 with ApiService

use of com.cloudera.api.model.ApiService 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;
}
Also used : DefaultServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse) ServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.ServiceStatusResponse) ApiClusterList(com.cloudera.api.model.ApiClusterList) ApiCluster(com.cloudera.api.model.ApiCluster) ArrayList(java.util.ArrayList) ClouderaRootResource(com.thinkbiganalytics.servicemonitor.rest.client.cdh.ClouderaRootResource) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) ApiRole(com.cloudera.api.model.ApiRole) ApiHealthCheck(com.cloudera.api.model.ApiHealthCheck) ApiClusterList(com.cloudera.api.model.ApiClusterList) ArrayList(java.util.ArrayList) List(java.util.List) DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) ServiceComponent(com.thinkbiganalytics.servicemonitor.model.ServiceComponent) DefaultServiceStatusResponse(com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse) DefaultServiceComponent(com.thinkbiganalytics.servicemonitor.model.DefaultServiceComponent) ApiService(com.cloudera.api.model.ApiService)

Aggregations

ApiService (com.cloudera.api.model.ApiService)3 ApiCluster (com.cloudera.api.model.ApiCluster)2 ApiClusterList (com.cloudera.api.model.ApiClusterList)2 ApiHealthCheck (com.cloudera.api.model.ApiHealthCheck)2 ApiRole (com.cloudera.api.model.ApiRole)2 ApiServiceList (com.cloudera.api.model.ApiServiceList)2 ApiHealthSummary (com.cloudera.api.model.ApiHealthSummary)1 ApiRoleList (com.cloudera.api.model.ApiRoleList)1 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 ClouderaRootResource (com.thinkbiganalytics.servicemonitor.rest.client.cdh.ClouderaRootResource)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1