use of com.sequenceiq.cloudbreak.cloud.event.resource.LaunchLoadBalancerResult in project cloudbreak by hortonworks.
the class StackCreationActions method provisioningFinishedAction.
@Bean(name = "PROVISIONING_FINISHED_STATE")
public Action<?, ?> provisioningFinishedAction() {
return new AbstractStackCreationAction<>(LaunchLoadBalancerResult.class) {
@Override
protected void doExecute(StackCreationContext context, LaunchLoadBalancerResult payload, Map<Object, Object> variables) {
Stack stack = stackCreationService.loadBalancerProvisioningFinished(context, payload, variables);
StackCreationContext newContext = new StackCreationContext(context.getFlowParameters(), stack, context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
sendEvent(newContext);
}
@Override
protected Selectable createRequest(StackCreationContext context) {
List<CloudInstance> cloudInstances = cloudStackConverter.buildInstances(context.getStack());
List<CloudResource> cloudResources = context.getStack().getResources().stream().map(r -> cloudResourceConverter.convert(r)).collect(Collectors.toList());
return new CollectMetadataRequest(context.getCloudContext(), context.getCloudCredential(), cloudResources, cloudInstances, cloudInstances);
}
};
}
use of com.sequenceiq.cloudbreak.cloud.event.resource.LaunchLoadBalancerResult 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