Search in sources :

Example 6 with ReadConfigResponse

use of com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse in project cloudbreak by hortonworks.

the class ServiceEndpointHealthListenerTask method checkStatus.

@Override
public boolean checkStatus(ServiceEndpointHealthPollerObject serviceEndpointHealthPollerObject) {
    boolean healthy = false;
    String clusterIdentifer = serviceEndpointHealthPollerObject.getClusterIdentifier();
    LOGGER.debug("Check cluster proxy endpoint health for {}.", clusterIdentifer);
    try {
        ClusterProxyRegistrationClient client = serviceEndpointHealthPollerObject.getClient();
        ReadConfigResponse response = client.readConfig(clusterIdentifer);
        if (response != null) {
            long stillWaitingForHealthyCount = response.getServices().stream().flatMap(service -> service.getEndpoints().stream()).filter(endpoint -> endpoint.getStatus() != null).map(ReadConfigEndpoint::getStatus).filter(status -> !HEALTHY_STATUSES.contains(status)).count();
            healthy = stillWaitingForHealthyCount == 0;
        }
    } catch (Exception e) {
        LOGGER.debug("Failed to check cluster proxy endpoint health for {}, error: {}", clusterIdentifer, e.getMessage());
    }
    return healthy;
}
Also used : ClusterProxyRegistrationClient(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient) Component(org.springframework.stereotype.Component) ClusterProxyRegistrationClient(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient) Logger(org.slf4j.Logger) StatusCheckerTask(com.sequenceiq.cloudbreak.polling.StatusCheckerTask) ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse) LoggerFactory(org.slf4j.LoggerFactory) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Set(java.util.Set) ReadConfigEndpoint(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigEndpoint) ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse) ReadConfigEndpoint(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigEndpoint) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Aggregations

ReadConfigResponse (com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse)6 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)4 Stack (com.sequenceiq.freeipa.entity.Stack)4 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ClusterProxyRegistrationClient (com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 CCMV2_BACKEND_ID_FORMAT (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2ParameterConstants.CCMV2_BACKEND_ID_FORMAT)1 ServiceFamilies (com.sequenceiq.cloudbreak.ccm.endpoint.ServiceFamilies)1 CcmV2Config (com.sequenceiq.cloudbreak.clusterproxy.CcmV2Config)1 ClientCertificate (com.sequenceiq.cloudbreak.clusterproxy.ClientCertificate)1 ClusterProxyConfiguration (com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyConfiguration)1 ClusterProxyEnablementService (com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService)1 ClusterServiceConfig (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig)1 ClusterServiceHealthCheck (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceHealthCheck)1 ConfigRegistrationRequest (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest)1 ConfigRegistrationRequestBuilder (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequestBuilder)1 ConfigRegistrationResponse (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse)1 ReadConfigEndpoint (com.sequenceiq.cloudbreak.clusterproxy.ReadConfigEndpoint)1