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