Search in sources :

Example 1 with HealthCheckResult

use of com.sequenceiq.cloudbreak.common.type.HealthCheckResult in project cloudbreak by hortonworks.

the class ClouderaManagerClusterStatusService method getCertCheck.

private static Optional<HealthCheck> getCertCheck(ApiHost apiHost) {
    Optional<ApiHealthCheck> healthCheck = emptyIfNull(apiHost.getHealthChecks()).stream().filter(health -> HOST_AGENT_CERTIFICATE_EXPIRY.equals(health.getName())).findFirst();
    if (healthCheck.isPresent()) {
        HealthCheckResult result = ApiHealthSummary.BAD.equals(healthCheck.get().getSummary()) || ApiHealthSummary.CONCERNING.equals(healthCheck.get().getSummary()) ? HealthCheckResult.UNHEALTHY : HealthCheckResult.HEALTHY;
        Optional<String> reason = Optional.ofNullable(healthCheck.get().getSummary()).map(apiSum -> "Cert health on CM: " + apiSum.getValue());
        return Optional.of(new HealthCheck(HealthCheckType.CERT, result, reason));
    }
    return Optional.empty();
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) HealthCheckResult(com.sequenceiq.cloudbreak.common.type.HealthCheckResult) HealthCheck(com.sequenceiq.cloudbreak.common.type.HealthCheck) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ExtendedHostStatuses(com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses) LoggerFactory(org.slf4j.LoggerFactory) ApiService(com.cloudera.api.swagger.model.ApiService) ApiRole(com.cloudera.api.swagger.model.ApiRole) StringUtils(org.apache.commons.lang3.StringUtils) ApiException(com.cloudera.api.swagger.client.ApiException) ClusterCommandType(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterCommandType) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) ApiRoleState(com.cloudera.api.swagger.model.ApiRoleState) BigDecimal(java.math.BigDecimal) Collectors.toMap(java.util.stream.Collectors.toMap) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) SyncApiCommandRetriever(com.sequenceiq.cloudbreak.cm.commands.SyncApiCommandRetriever) Collection(java.util.Collection) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) Set(java.util.Set) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) Collectors(java.util.stream.Collectors) ApiVersionInfo(com.cloudera.api.swagger.model.ApiVersionInfo) Collectors.joining(java.util.stream.Collectors.joining) Sets(com.google.common.collect.Sets) ClusterStatus(com.sequenceiq.cloudbreak.cluster.status.ClusterStatus) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) ApiHealthSummary(com.cloudera.api.swagger.model.ApiHealthSummary) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) CollectionUtils.emptyIfNull(org.apache.commons.collections4.CollectionUtils.emptyIfNull) Joiner(com.google.common.base.Joiner) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ApiCommand(com.cloudera.api.swagger.model.ApiCommand) CMRepositoryVersionUtil(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil) ApiClient(com.cloudera.api.swagger.client.ApiClient) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) ClusterStatusResult(com.sequenceiq.cloudbreak.cluster.status.ClusterStatusResult) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) HashMap(java.util.HashMap) Function(java.util.function.Function) Scope(org.springframework.context.annotation.Scope) ServicesResourceApi(com.cloudera.api.swagger.ServicesResourceApi) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) ClouderaManagerApiClientProvider(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerApiClientProvider) Service(org.springframework.stereotype.Service) ApiHost(com.cloudera.api.swagger.model.ApiHost) Collectors.mapping(java.util.stream.Collectors.mapping) RolesResourceApi(com.cloudera.api.swagger.RolesResourceApi) ApiServiceState(com.cloudera.api.swagger.model.ApiServiceState) ApiHealthCheck(com.cloudera.api.swagger.model.ApiHealthCheck) HealthCheckType(com.sequenceiq.cloudbreak.common.type.HealthCheckType) Logger(org.slf4j.Logger) ClusterStatusService(com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService) TimeUnit(java.util.concurrent.TimeUnit) HostName.hostName(com.sequenceiq.cloudbreak.cloud.model.HostName.hostName) Collectors.toList(java.util.stream.Collectors.toList) ClusterManagerCommand(com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand) HostName(com.sequenceiq.cloudbreak.cloud.model.HostName) RetryTemplate(org.springframework.retry.support.RetryTemplate) ApiRoleRef(com.cloudera.api.swagger.model.ApiRoleRef) ClouderaManagerApiFactory(com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory) ApiHealthCheck(com.cloudera.api.swagger.model.ApiHealthCheck) HealthCheck(com.sequenceiq.cloudbreak.common.type.HealthCheck) ApiHealthCheck(com.cloudera.api.swagger.model.ApiHealthCheck) HealthCheckResult(com.sequenceiq.cloudbreak.common.type.HealthCheckResult)

Example 2 with HealthCheckResult

use of com.sequenceiq.cloudbreak.common.type.HealthCheckResult in project cloudbreak by hortonworks.

the class VmStatusCheckerConclusionStepTest method createExtendedHostStatuses.

private ExtendedHostStatuses createExtendedHostStatuses(boolean healthy) {
    Map<HostName, Set<HealthCheck>> hostStatuses = new HashMap<>();
    HealthCheckResult status = healthy ? HealthCheckResult.HEALTHY : HealthCheckResult.UNHEALTHY;
    String reason = healthy ? null : "error";
    Set<HealthCheck> healthChecks = Sets.newHashSet(new HealthCheck(HealthCheckType.HOST, status, Optional.ofNullable(reason)));
    hostStatuses.put(HostName.hostName("host1"), healthChecks);
    hostStatuses.put(HostName.hostName("host2"), healthChecks);
    return new ExtendedHostStatuses(hostStatuses);
}
Also used : ExtendedHostStatuses(com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses) Set(java.util.Set) HashMap(java.util.HashMap) HealthCheck(com.sequenceiq.cloudbreak.common.type.HealthCheck) HealthCheckResult(com.sequenceiq.cloudbreak.common.type.HealthCheckResult) HostName(com.sequenceiq.cloudbreak.cloud.model.HostName)

Aggregations

HostName (com.sequenceiq.cloudbreak.cloud.model.HostName)2 ExtendedHostStatuses (com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses)2 HealthCheck (com.sequenceiq.cloudbreak.common.type.HealthCheck)2 HealthCheckResult (com.sequenceiq.cloudbreak.common.type.HealthCheckResult)2 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)1 ClustersResourceApi (com.cloudera.api.swagger.ClustersResourceApi)1 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)1 RolesResourceApi (com.cloudera.api.swagger.RolesResourceApi)1 ServicesResourceApi (com.cloudera.api.swagger.ServicesResourceApi)1 ApiClient (com.cloudera.api.swagger.client.ApiClient)1 ApiException (com.cloudera.api.swagger.client.ApiException)1 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)1 ApiHealthCheck (com.cloudera.api.swagger.model.ApiHealthCheck)1 ApiHealthSummary (com.cloudera.api.swagger.model.ApiHealthSummary)1 ApiHost (com.cloudera.api.swagger.model.ApiHost)1 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)1 ApiRole (com.cloudera.api.swagger.model.ApiRole)1 ApiRoleRef (com.cloudera.api.swagger.model.ApiRoleRef)1 ApiRoleState (com.cloudera.api.swagger.model.ApiRoleState)1 ApiService (com.cloudera.api.swagger.model.ApiService)1