use of com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackResult in project cloudbreak by hortonworks.
the class UpscaleStackComponentTest method testUpscaleStack.
@Test
public void testUpscaleStack() {
UpscaleStackResult result = sendCloudRequest();
assertEquals(ResourceStatus.UPDATED, result.getResourceStatus());
assertEquals(1, result.getResults().size());
assertEquals(ResourceStatus.UPDATED, result.getResults().get(0).getStatus());
assertFalse(result.isFailed());
assertNull(result.getErrorDetails());
}
use of com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackResult in project cloudbreak by hortonworks.
the class UpscaleStackHandler method accept.
@Override
public void accept(Event<UpscaleStackRequest> upscaleStackRequestEvent) {
LOGGER.info("Received event: {}", upscaleStackRequestEvent);
UpscaleStackRequest request = upscaleStackRequestEvent.getData();
CloudContext cloudContext = request.getCloudContext();
try {
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
List<CloudResourceStatus> resourceStatus = connector.resources().upscale(ac, request.getCloudStack(), request.getResourceList());
List<CloudResource> resources = ResourceLists.transform(resourceStatus);
PollTask<ResourcesStatePollerResult> task = statusCheckFactory.newPollResourcesStateTask(ac, resources, true);
ResourcesStatePollerResult statePollerResult = ResourcesStatePollerResults.build(cloudContext, resourceStatus);
if (!task.completed(statePollerResult)) {
statePollerResult = syncPollingScheduler.schedule(task);
}
UpscaleStackResult result = ResourcesStatePollerResults.transformToUpscaleStackResult(statePollerResult, request);
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(upscaleStackRequestEvent.getHeaders(), result));
LOGGER.info("Upscale successfully finished for {}", cloudContext);
} catch (Exception e) {
UpscaleStackResult result = new UpscaleStackResult(e.getMessage(), e, request);
request.getResult().onNext(result);
eventBus.notify(CloudPlatformResult.failureSelector(UpscaleStackResult.class), new Event<>(upscaleStackRequestEvent.getHeaders(), result));
}
}
Aggregations