use of com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataResult in project cloudbreak by hortonworks.
the class LoadBalancerRecreatorService method collectLoadBalancerMetadata.
private List<CloudLoadBalancerMetadata> collectLoadBalancerMetadata(AuthenticatedContext authenticatedContext, Long stackId) {
List<LoadBalancerType> loadBalancerTypes = loadBalancerPersistenceService.findByStackId(stackId).stream().map(LoadBalancer::getType).collect(Collectors.toList());
List<CloudResource> cloudResources = resourceService.findByStackIdAndType(stackId, ResourceType.ELASTIC_LOAD_BALANCER).stream().map(r -> cloudResourceConverter.convert(r)).collect(Collectors.toList());
CollectLoadBalancerMetadataRequest request = new CollectLoadBalancerMetadataRequest(authenticatedContext.getCloudContext(), authenticatedContext.getCloudCredential(), loadBalancerTypes, cloudResources);
eventBus.notify(request.selector(), Event.wrap(request));
try {
CollectLoadBalancerMetadataResult res = request.await();
LOGGER.debug("Collect load balancer metadata result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
String msg = "Failed to collect the load balancer metadata. " + res.getErrorDetails().getMessage();
LOGGER.debug(msg);
throw new CloudbreakServiceException(msg, res.getErrorDetails());
}
return res.getResults();
} catch (InterruptedException e) {
LOGGER.error("Error while collect load balancer metadata", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataResult in project cloudbreak by hortonworks.
the class CollectLoadBalancerMetadataHandler method accept.
@Override
public void accept(Event<CollectLoadBalancerMetadataRequest> collectLBMetadataRequestEvent) {
LOGGER.debug("Received event: {}", collectLBMetadataRequestEvent);
CollectLoadBalancerMetadataRequest request = collectLBMetadataRequestEvent.getData();
try {
List<CloudLoadBalancerMetadata> loadBalancerStatuses = loadBalancerMetadataService.collectMetadata(request.getCloudContext(), request.getCloudCredential(), request.getTypesPresentInStack(), request.getCloudResources());
CollectLoadBalancerMetadataResult collectLBMetadataResult = new CollectLoadBalancerMetadataResult(request.getResourceId(), loadBalancerStatuses);
request.getResult().onNext(collectLBMetadataResult);
eventBus.notify(collectLBMetadataResult.selector(), new Event<>(collectLBMetadataRequestEvent.getHeaders(), collectLBMetadataResult));
LOGGER.debug("Load balancer metadata collection successfully finished");
} catch (RuntimeException e) {
LOGGER.error("Collecting load balancer metadata failed", e);
CollectLoadBalancerMetadataResult failure = new CollectLoadBalancerMetadataResult(e, request.getResourceId());
request.getResult().onNext(failure);
eventBus.notify(failure.selector(), new Event<>(collectLBMetadataRequestEvent.getHeaders(), failure));
}
}
use of com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataResult in project cloudbreak by hortonworks.
the class StackCreationActions method collectLoadBalancerMetadataAction.
@Bean(name = "COLLECTMETADATA_LOADBALANCER_STATE")
public Action<?, ?> collectLoadBalancerMetadataAction() {
return new AbstractStackCreationAction<>(CollectLoadBalancerMetadataResult.class) {
@Override
protected void doExecute(StackCreationContext context, CollectLoadBalancerMetadataResult payload, Map<Object, Object> variables) {
Stack stack = stackCreationService.setupLoadBalancerMetadata(context, payload);
StackCreationContext newContext = new StackCreationContext(context.getFlowParameters(), stack, context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
if (newContext.getStack().getTunnel().useCcm()) {
GetTlsInfoResult getTlsInfoResult = new GetTlsInfoResult(context.getCloudContext().getId(), new TlsInfo(true));
sendEvent(newContext, getTlsInfoResult.selector(), getTlsInfoResult);
} else {
sendEvent(newContext);
}
}
@Override
protected Selectable createRequest(StackCreationContext context) {
CloudStack cloudStack = cloudStackConverter.convert(context.getStack());
return new GetTlsInfoRequest<GetTlsInfoResult>(context.getCloudContext(), context.getCloudCredential(), cloudStack);
}
};
}
Aggregations