Search in sources :

Example 1 with PlatformParametersResult

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

the class PlatformParametersHandler method accept.

@Override
public void accept(Event<PlatformParametersRequest> platformParameterRequestEvent) {
    LOGGER.info("Received event: {}", platformParameterRequestEvent);
    PlatformParametersRequest request = platformParameterRequestEvent.getData();
    Map<Platform, PlatformParameters> platformParameters = new HashMap<>();
    try {
        for (Entry<Platform, Collection<Variant>> connector : cloudPlatformConnectors.getPlatformVariants().getPlatformToVariants().entrySet()) {
            platformParameters.put(connector.getKey(), cloudPlatformConnectors.getDefault(connector.getKey()).parameters());
        }
        PlatformParametersResult platformParameterResult = new PlatformParametersResult(request, platformParameters);
        request.getResult().onNext(platformParameterResult);
        LOGGER.info("Query platform parameters finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new PlatformParametersResult(e.getMessage(), e, request));
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) HashMap(java.util.HashMap) PlatformParametersRequest(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParametersRequest) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) Collection(java.util.Collection) PlatformParametersResult(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParametersResult)

Example 2 with PlatformParametersResult

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

the class CloudParameterService method getPlatformParameters.

public Map<Platform, PlatformParameters> getPlatformParameters() {
    LOGGER.debug("Get platform parameters for");
    PlatformParametersRequest parametersRequest = new PlatformParametersRequest();
    eventBus.notify(parametersRequest.selector(), eventFactory.createEvent(parametersRequest));
    try {
        PlatformParametersResult res = parametersRequest.await();
        LOGGER.info("Platform parameter result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform parameters", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getPlatformParameters();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting platform parameters", e);
        throw new OperationException(e);
    }
}
Also used : PlatformParametersRequest(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParametersRequest) PlatformParametersResult(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParametersResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

PlatformParametersRequest (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParametersRequest)2 PlatformParametersResult (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParametersResult)2 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)1 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1