use of com.sequenceiq.redbeams.flow.redbeams.provision.event.allocate.AllocateDatabaseServerFailed in project cloudbreak by hortonworks.
the class AllocateDatabaseServerHandler method defaultFailureEvent.
@Override
protected Selectable defaultFailureEvent(Long resourceId, Exception e, Event<AllocateDatabaseServerRequest> event) {
AllocateDatabaseServerFailed failure = new AllocateDatabaseServerFailed(resourceId, e);
LOGGER.warn("Error launching the database stack:", e);
return failure;
}
use of com.sequenceiq.redbeams.flow.redbeams.provision.event.allocate.AllocateDatabaseServerFailed in project cloudbreak by hortonworks.
the class AllocateDatabaseServerHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<AllocateDatabaseServerRequest> 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();
DBStack dbStack = dbStackService.getById(request.getResourceId());
databaseServerSslCertificatePrescriptionService.prescribeSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, 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());
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);
}
return response;
}
use of com.sequenceiq.redbeams.flow.redbeams.provision.event.allocate.AllocateDatabaseServerFailed in project cloudbreak by hortonworks.
the class AllocateDatabaseServerHandlerTest method verifyFailureEvent.
private void verifyFailureEvent(Selectable selectable) {
assertThat(selectable).isInstanceOf(AllocateDatabaseServerFailed.class);
AllocateDatabaseServerFailed allocateDatabaseServerFailed = (AllocateDatabaseServerFailed) selectable;
assertThat(allocateDatabaseServerFailed.getResourceId()).isEqualTo(RESOURCE_ID);
}
use of com.sequenceiq.redbeams.flow.redbeams.provision.event.allocate.AllocateDatabaseServerFailed 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