Search in sources :

Example 1 with ReadConfigEndpoint

use of com.sequenceiq.cloudbreak.clusterproxy.ReadConfigEndpoint 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

ClusterProxyRegistrationClient (com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient)1 ReadConfigEndpoint (com.sequenceiq.cloudbreak.clusterproxy.ReadConfigEndpoint)1 ReadConfigResponse (com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 StatusCheckerTask (com.sequenceiq.cloudbreak.polling.StatusCheckerTask)1 Set (java.util.Set)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Component (org.springframework.stereotype.Component)1