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;
}
Aggregations