use of com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.LoadBalancerMetadataFailure in project cloudbreak by hortonworks.
the class LoadBalancerMetadataHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<LoadBalancerMetadataRequest> event) {
LoadBalancerMetadataRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
try {
LOGGER.info("Fetch cloud load balancer metadata");
List<CloudLoadBalancerMetadata> loadBalancerStatuses = loadBalancerMetadataService.collectMetadata(cloudContext, request.getCloudCredential(), request.getTypesPresentInStack(), request.getCloudResources());
Set<CloudLoadBalancerMetadata> failedStatues = loadBalancerStatuses.stream().filter(this::isMissingMetadata).collect(Collectors.toSet());
if (!failedStatues.isEmpty()) {
Set<String> names = failedStatues.stream().map(CloudLoadBalancerMetadata::getName).collect(Collectors.toSet());
throw new CloudbreakException("Creation failed for load balancers: " + names);
}
LOGGER.info("Persisting load balancer metadata to the database: {}", loadBalancerStatuses);
metadataSetupService.saveLoadBalancerMetadata(request.getStack(), loadBalancerStatuses);
LOGGER.info("Load balancer metadata collection was successful");
return new LoadBalancerMetadataSuccess(request.getStack());
} catch (Exception e) {
LOGGER.warn("Failed to fetch cloud load balancer metadata.", e);
return new LoadBalancerMetadataFailure(request.getResourceId(), e);
}
}
Aggregations