use of com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesResult in project cloudbreak by hortonworks.
the class DownscaleStackCollectResourcesHandler method accept.
@Override
public void accept(Event<DownscaleStackCollectResourcesRequest> collectResourcesRequestEvent) {
LOGGER.info("Received event: {}", collectResourcesRequestEvent);
DownscaleStackCollectResourcesRequest request = collectResourcesRequestEvent.getData();
DownscaleStackCollectResourcesResult result;
try {
CloudContext cloudContext = request.getCloudContext();
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
Object resourcesToScale = connector.resources().collectResourcesToRemove(ac, request.getCloudStack(), request.getCloudResources(), request.getInstances());
LOGGER.info("Collect resources successfully finished for {}", cloudContext);
result = new DownscaleStackCollectResourcesResult(request, resourcesToScale);
} catch (RuntimeException e) {
LOGGER.error("Failed to handle DownscaleStackCollectResourcesRequest.", e);
result = new DownscaleStackCollectResourcesResult(e.getMessage(), e, request);
}
request.getResult().onNext(result);
LOGGER.info("DownscaleStackCollectResourcesRequest finished");
eventBus.notify(result.selector(), new Event<>(collectResourcesRequestEvent.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesResult in project cloudbreak by hortonworks.
the class StackDownscaleActions method stackDownscaleAction.
@Bean(name = "DOWNSCALE_STATE")
public Action<?, ?> stackDownscaleAction() {
return new AbstractStackDownscaleAction<DownscaleStackCollectResourcesResult>(DownscaleStackCollectResourcesResult.class) {
@Override
protected void doExecute(StackScalingFlowContext context, DownscaleStackCollectResourcesResult payload, Map<Object, Object> variables) {
Selectable request = new DownscaleStackRequest(context.getCloudContext(), context.getCloudCredential(), context.getCloudStack(), (List<CloudResource>) variables.get(RESOURCES), (List<CloudInstance>) variables.get(INSTANCES), payload.getResourcesToScale());
sendEvent(context.getFlowId(), request);
}
};
}
Aggregations