use of com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionRequest in project cloudbreak by hortonworks.
the class ResourceDefinitionHandler method accept.
@Override
public void accept(Event<ResourceDefinitionRequest> getRegionsRequestEvent) {
LOGGER.info("Received event: {}", getRegionsRequestEvent);
ResourceDefinitionRequest request = getRegionsRequestEvent.getData();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getPlatform());
String resource = request.getResource();
String definition = connector.parameters().resourceDefinition(request.getResource());
if (definition == null) {
Exception exception = new Exception("Failed to find resource definition for " + resource);
request.getResult().onNext(new ResourceDefinitionResult(exception.getMessage(), exception, request));
} else {
request.getResult().onNext(new ResourceDefinitionResult(request, definition));
}
} catch (RuntimeException e) {
request.getResult().onNext(new ResourceDefinitionResult(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionRequest in project cloudbreak by hortonworks.
the class ResourceDefinitionService method getResourceDefinition.
@Cacheable("resourceDefinitionCache")
public String getResourceDefinition(String cloudPlatform, String resource) {
LOGGER.debug("Sending request for {} {} resource property definition", cloudPlatform, resource);
CloudPlatformVariant platformVariant = new CloudPlatformVariant(Platform.platform(cloudPlatform), Variant.EMPTY);
ResourceDefinitionRequest request = new ResourceDefinitionRequest(platformVariant, resource);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
try {
ResourceDefinitionResult result = request.await();
LOGGER.info("Resource property definition: {}", result);
return result.getDefinition();
} catch (InterruptedException e) {
LOGGER.error("Error while sending resource definition request", e);
throw new OperationException(e);
}
}
Aggregations