Search in sources :

Example 1 with ClusterProxyRegistrationClient

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

the class ServiceEndpointHealthListenerTask method handleTimeout.

@Override
public void handleTimeout(ServiceEndpointHealthPollerObject clusterProxyHealthPollerObject) {
    String clusterIdentifer = clusterProxyHealthPollerObject.getClusterIdentifier();
    String errorMessage;
    try {
        ClusterProxyRegistrationClient client = clusterProxyHealthPollerObject.getClient();
        errorMessage = client.readConfig(clusterIdentifer).toHumanReadableString();
    } catch (Exception e) {
        errorMessage = String.format("Failed to check cluster proxy endpoint health for %s, error: %s", clusterIdentifer, e.getMessage());
        LOGGER.error(errorMessage);
    }
    throw new CloudbreakServiceException("Operation timed out. Failed to check cluster proxy endpoint health. " + errorMessage);
}
Also used : ClusterProxyRegistrationClient(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 2 with ClusterProxyRegistrationClient

use of com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient 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)2 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)2 ReadConfigEndpoint (com.sequenceiq.cloudbreak.clusterproxy.ReadConfigEndpoint)1 ReadConfigResponse (com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse)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