use of com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendationResponse 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);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendationResponse 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));
}
}
Aggregations