use of com.sequenceiq.redbeams.flow.redbeams.provision.event.allocate.AllocateDatabaseServerSuccess in project cloudbreak by hortonworks.
the class AllocateDatabaseServerHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent handlerEvent) {
Event<AllocateDatabaseServerRequest> event = handlerEvent.getEvent();
LOGGER.debug("Received event: {}", event);
AllocateDatabaseServerRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
Selectable response;
try {
CloudConnector<Object> connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
CloudCredential cloudCredential = request.getCloudCredential();
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, cloudCredential);
DatabaseStack databaseStack = request.getDatabaseStack();
databaseServerSslCertificatePrescriptionService.prescribeSslCertificateIfNeeded(cloudContext, cloudCredential, request.getDbStack(), databaseStack);
List<CloudResourceStatus> resourceStatuses = connector.resources().launchDatabaseServer(ac, databaseStack, persistenceNotifier);
List<CloudResource> resources = ResourceLists.transform(resourceStatuses);
PollTask<ResourcesStatePollerResult> task = statusCheckFactory.newPollResourcesStateTask(ac, resources, true);
ResourcesStatePollerResult statePollerResult = ResourcesStatePollerResults.build(cloudContext, resourceStatuses);
if (!task.completed(statePollerResult)) {
statePollerResult = syncPollingScheduler.schedule(task);
}
validateResourcesState(cloudContext, statePollerResult);
response = new AllocateDatabaseServerSuccess(request.getResourceId());
// request.getResult().onNext(success);
LOGGER.debug("Launching the database stack successfully finished for {}", cloudContext);
} catch (Exception e) {
response = new AllocateDatabaseServerFailed(request.getResourceId(), e);
LOGGER.warn("Error launching the database stack:", e);
// request.getResult().onNext(failure);
}
return response;
}
Aggregations