Search in sources :

Example 1 with GetVirtualMachineRecommendtaionRequest

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendtaionRequest in project cloudbreak by hortonworks.

the class CloudParameterService method getRecommendation.

public VmRecommendations getRecommendation(String platform) {
    LOGGER.debug("Get platform vm recommendation");
    GetVirtualMachineRecommendtaionRequest getVirtualMachineRecommendtaionRequest = new GetVirtualMachineRecommendtaionRequest(platform);
    eventBus.notify(getVirtualMachineRecommendtaionRequest.selector(), eventFactory.createEvent(getVirtualMachineRecommendtaionRequest));
    try {
        GetVirtualMachineRecommendationResponse res = getVirtualMachineRecommendtaionRequest.await();
        LOGGER.info("Platform vm recommendation result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform vm recommendation", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getRecommendations();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform vm recommendation", e);
        throw new OperationException(e);
    }
}
Also used : GetVirtualMachineRecommendtaionRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendtaionRequest) GetVirtualMachineRecommendationResponse(com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendationResponse) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 2 with GetVirtualMachineRecommendtaionRequest

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendtaionRequest in project cloudbreak by hortonworks.

the class GetVirtualMachineRecommendationsHandler method accept.

@Override
public void accept(Event<GetVirtualMachineRecommendtaionRequest> gVMRRE) {
    LOGGER.info("Received GetVirtualMachineRecommendtaionRequest event: {}", gVMRRE);
    GetVirtualMachineRecommendtaionRequest request = gVMRRE.getData();
    String cloudPlatform = request.getCloudPlatform();
    try {
        CloudConnector connector = cloudPlatformConnectors.getDefault(Platform.platform(cloudPlatform));
        VmRecommendations recommendations = connector.parameters().recommendedVms();
        GetVirtualMachineRecommendationResponse gVMRResponse = new GetVirtualMachineRecommendationResponse(request, recommendations);
        request.getResult().onNext(gVMRResponse);
        LOGGER.info("Query platform machine recommendations finished.");
    } catch (RuntimeException e) {
        LOGGER.warn("Could not get virtual machine recommendations for platform: " + cloudPlatform, e);
        request.getResult().onNext(new GetVirtualMachineRecommendationResponse(e.getMessage(), e, request));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) GetVirtualMachineRecommendtaionRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendtaionRequest) VmRecommendations(com.sequenceiq.cloudbreak.cloud.model.VmRecommendations) GetVirtualMachineRecommendationResponse(com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendationResponse)

Aggregations

GetVirtualMachineRecommendationResponse (com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendationResponse)2 GetVirtualMachineRecommendtaionRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendtaionRequest)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 VmRecommendations (com.sequenceiq.cloudbreak.cloud.model.VmRecommendations)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1