Search in sources :

Example 6 with IdbmmsOperationException

use of com.sequenceiq.cloudbreak.idbmms.exception.IdbmmsOperationException in project cloudbreak by hortonworks.

the class GrpcIdbmmsClient method getMappingsConfig.

/**
 * Retrieves IDBroker mappings from IDBMMS for a particular environment.
 *
 * @param actorCrn the actor CRN; must not be {@code null}
 * @param environmentCrn the environment CRN to get mappings for; must not be {@code null}
 * @param requestId an optional request ID; must not be {@code null}
 * @return the mappings config associated with environment {@code environmentCrn}; never {@code null}
 * @throws NullPointerException if either argument is {@code null}
 * @throws IdbmmsOperationException if any problem is encountered during the IDBMMS call processing
 */
public MappingsConfig getMappingsConfig(String actorCrn, String environmentCrn, Optional<String> requestId) {
    checkNotNull(actorCrn, "actorCrn should not be null.");
    checkNotNull(environmentCrn);
    checkNotNull(requestId, "requestId should not be null.");
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        IdbmmsClient client = makeClient(channelWrapper.getChannel(), actorCrn);
        String effectiveRequestId = requestId.orElse(UUID.randomUUID().toString());
        LOGGER.debug("Fetching IDBroker mappings for environment {} using request ID {}", environmentCrn, effectiveRequestId);
        MappingsConfig mappingsConfig = client.getMappingsConfig(effectiveRequestId, environmentCrn);
        LOGGER.debug("Retrieved IDBroker mappings of version {} for environment {}", mappingsConfig.getMappingsVersion(), environmentCrn);
        return mappingsConfig;
    } catch (RuntimeException e) {
        throw new IdbmmsOperationException(String.format("Error during IDBMMS operation: %s", e.getMessage()), e);
    }
}
Also used : MappingsConfig(com.sequenceiq.cloudbreak.idbmms.model.MappingsConfig) IdbmmsOperationException(com.sequenceiq.cloudbreak.idbmms.exception.IdbmmsOperationException) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)

Aggregations

IdbmmsOperationException (com.sequenceiq.cloudbreak.idbmms.exception.IdbmmsOperationException)6 Test (org.junit.jupiter.api.Test)3 ManagedChannelWrapper (com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)2 MappingsConfig (com.sequenceiq.cloudbreak.idbmms.model.MappingsConfig)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 AccountMappingBase (com.sequenceiq.common.api.cloudstorage.AccountMappingBase)1 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 Logger (org.slf4j.Logger)1