Search in sources :

Example 1 with UpscaleStackResult

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());
}
Also used : UpscaleStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackResult) Test(org.junit.Test)

Example 2 with UpscaleStackResult

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));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) UpscaleStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackResult) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) Event(reactor.bus.Event) UpscaleStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackRequest) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ResourcesStatePollerResult(com.sequenceiq.cloudbreak.cloud.task.ResourcesStatePollerResult)

Aggregations

UpscaleStackResult (com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackResult)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 UpscaleStackRequest (com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackRequest)1 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)1 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)1 ResourcesStatePollerResult (com.sequenceiq.cloudbreak.cloud.task.ResourcesStatePollerResult)1 Test (org.junit.Test)1 Event (reactor.bus.Event)1