Search in sources :

Example 1 with GetDiskTypesRequest

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

the class CloudParameterService method getDiskTypes.

public PlatformDisks getDiskTypes() {
    LOGGER.debug("Get platform disktypes");
    GetDiskTypesRequest getDiskTypesRequest = new GetDiskTypesRequest();
    eventBus.notify(getDiskTypesRequest.selector(), eventFactory.createEvent(getDiskTypesRequest));
    try {
        GetDiskTypesResult res = getDiskTypesRequest.await();
        LOGGER.info("Platform disk types result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform disk types", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getPlatformDisks();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform disk types", e);
        throw new OperationException(e);
    }
}
Also used : GetDiskTypesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesRequest) GetDiskTypesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 2 with GetDiskTypesRequest

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

the class GetDiskTypesHandler method accept.

@Override
public void accept(Event<GetDiskTypesRequest> getDiskTypesRequestEvent) {
    LOGGER.info("Received event: {}", getDiskTypesRequestEvent);
    GetDiskTypesRequest request = getDiskTypesRequestEvent.getData();
    try {
        Map<Platform, Collection<DiskType>> platformDiskTypes = Maps.newHashMap();
        Map<Platform, DiskType> defaultDiskTypes = Maps.newHashMap();
        Map<Platform, Map<String, VolumeParameterType>> diskMappings = Maps.newHashMap();
        Map<Platform, Map<DiskType, DisplayName>> diskDisplayNames = Maps.newHashMap();
        for (Entry<Platform, Collection<Variant>> connector : cloudPlatformConnectors.getPlatformVariants().getPlatformToVariants().entrySet()) {
            DiskTypes diskTypes = cloudPlatformConnectors.getDefault(connector.getKey()).parameters().diskTypes();
            defaultDiskTypes.put(connector.getKey(), diskTypes.defaultType());
            platformDiskTypes.put(connector.getKey(), diskTypes.types());
            diskMappings.put(connector.getKey(), diskTypes.diskMapping());
            diskDisplayNames.put(connector.getKey(), diskTypes.displayNames());
        }
        GetDiskTypesResult getDiskTypesResult = new GetDiskTypesResult(request, new PlatformDisks(platformDiskTypes, defaultDiskTypes, diskMappings, diskDisplayNames));
        request.getResult().onNext(getDiskTypesResult);
        LOGGER.info("Query platform disk types finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new GetDiskTypesResult(e.getMessage(), e, request));
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) PlatformDisks(com.sequenceiq.cloudbreak.cloud.model.PlatformDisks) DiskType(com.sequenceiq.cloudbreak.cloud.model.DiskType) GetDiskTypesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesRequest) GetDiskTypesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesResult) DiskTypes(com.sequenceiq.cloudbreak.cloud.model.DiskTypes) Collection(java.util.Collection) Map(java.util.Map)

Aggregations

GetDiskTypesRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesRequest)2 GetDiskTypesResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesResult)2 DiskType (com.sequenceiq.cloudbreak.cloud.model.DiskType)1 DiskTypes (com.sequenceiq.cloudbreak.cloud.model.DiskTypes)1 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)1 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1 Collection (java.util.Collection)1 Map (java.util.Map)1