Search in sources :

Example 1 with GetPlatformOrchestratorsResult

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

the class CloudParameterService method getOrchestrators.

public PlatformOrchestrators getOrchestrators() {
    LOGGER.debug("Get platform orchestrators");
    GetPlatformOrchestratorsRequest getPlatformOrchestratorsRequest = new GetPlatformOrchestratorsRequest();
    eventBus.notify(getPlatformOrchestratorsRequest.selector(), eventFactory.createEvent(getPlatformOrchestratorsRequest));
    try {
        GetPlatformOrchestratorsResult res = getPlatformOrchestratorsRequest.await();
        LOGGER.info("Platform orchestrators result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform orchestrators", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getPlatformOrchestrators();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform orchestrators", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformOrchestratorsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformOrchestratorsRequest) GetPlatformOrchestratorsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformOrchestratorsResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 2 with GetPlatformOrchestratorsResult

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

the class GetPlatformOrchestratorsHandler method accept.

@Override
public void accept(Event<GetPlatformOrchestratorsRequest> getPlatformOrchestratorsRequest) {
    LOGGER.info("Received event: {}", getPlatformOrchestratorsRequest);
    GetPlatformOrchestratorsRequest request = getPlatformOrchestratorsRequest.getData();
    try {
        Map<Platform, Collection<Orchestrator>> platformCollectionHashMap = Maps.newHashMap();
        Map<Platform, Orchestrator> defaults = Maps.newHashMap();
        for (Entry<Platform, Collection<Variant>> connector : cloudPlatformConnectors.getPlatformVariants().getPlatformToVariants().entrySet()) {
            PlatformOrchestrator platformOrchestrator = cloudPlatformConnectors.getDefault(connector.getKey()).parameters().orchestratorParams();
            platformCollectionHashMap.put(connector.getKey(), platformOrchestrator.types());
            defaults.put(connector.getKey(), platformOrchestrator.defaultType());
        }
        GetPlatformOrchestratorsResult getPlatformOrchestratorsResult = new GetPlatformOrchestratorsResult(request, new PlatformOrchestrators(platformCollectionHashMap, defaults));
        request.getResult().onNext(getPlatformOrchestratorsResult);
        LOGGER.info("Query platform orchestrators types finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new GetPlatformOrchestratorsResult(e.getMessage(), e, request));
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) PlatformOrchestrator(com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrator) Collection(java.util.Collection) PlatformOrchestrators(com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrators) GetPlatformOrchestratorsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformOrchestratorsRequest) GetPlatformOrchestratorsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformOrchestratorsResult) Orchestrator(com.sequenceiq.cloudbreak.cloud.model.Orchestrator) PlatformOrchestrator(com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrator)

Aggregations

GetPlatformOrchestratorsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformOrchestratorsRequest)2 GetPlatformOrchestratorsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformOrchestratorsResult)2 Orchestrator (com.sequenceiq.cloudbreak.cloud.model.Orchestrator)1 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)1 PlatformOrchestrator (com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrator)1 PlatformOrchestrators (com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrators)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1 Collection (java.util.Collection)1