use of com.sequenceiq.cloudbreak.cloud.event.resource.LaunchLoadBalancerRequest in project cloudbreak by hortonworks.
the class LaunchLoadBalancerHandler method accept.
@Override
public void accept(Event<LaunchLoadBalancerRequest> launchLoadBalancerRequestEvent) {
LOGGER.debug("Received event: {}", launchLoadBalancerRequestEvent);
LaunchLoadBalancerRequest request = launchLoadBalancerRequestEvent.getData();
CloudContext cloudContext = request.getCloudContext();
CloudStack cloudStack = request.getCloudStack();
CloudConnector<Object> connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
try {
LaunchLoadBalancerResult result;
if (!cloudStack.getLoadBalancers().isEmpty()) {
ResourcesStatePollerResult statePollerResult = launchLoadBalancers(cloudStack, connector, ac, persistenceNotifier, cloudContext);
result = ResourcesStatePollerResults.transformToLaunchLoadBalancerResult(request, statePollerResult);
request.getResult().onNext(result);
LOGGER.debug("Launching the load balancers successfully finished for {}", cloudContext);
} else {
LOGGER.debug("No load balancers configured for stack.");
result = new LaunchLoadBalancerResult(request.getResourceId(), List.of());
}
eventBus.notify(result.selector(), new Event<>(launchLoadBalancerRequestEvent.getHeaders(), result));
} catch (Exception e) {
if (ExceptionUtils.getRootCause(e) instanceof InterruptedException) {
LOGGER.info("Interrupted exception is ignored as it has been thrown because of graceful shutdown of the java process.");
}
LaunchLoadBalancerResult failure = new LaunchLoadBalancerResult(e, request.getResourceId());
LOGGER.warn("Error during launching the load balancerse:", e);
request.getResult().onNext(failure);
eventBus.notify(failure.selector(), new Event<>(launchLoadBalancerRequestEvent.getHeaders(), failure));
}
}
Aggregations