Search in sources :

Example 1 with PermanentlyFailedException

use of com.sequenceiq.cloudbreak.util.PermanentlyFailedException in project cloudbreak by hortonworks.

the class CloudParameterService method getCloudAccessConfigs.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudAccessConfigs getCloudAccessConfigs(ExtendedCloudCredential cloudCredential, String region, String variant, Map<String, String> filters) {
    LOGGER.debug("Get platform accessConfigs");
    GetPlatformCloudAccessConfigsRequest getPlatformCloudAccessConfigsRequest = new GetPlatformCloudAccessConfigsRequest(cloudCredential, cloudCredential, variant, region, filters);
    eventBus.notify(getPlatformCloudAccessConfigsRequest.selector(), Event.wrap(getPlatformCloudAccessConfigsRequest));
    try {
        GetPlatformCloudAccessConfigsResult res = getPlatformCloudAccessConfigsRequest.await();
        LOGGER.debug("Platform accessConfigs result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform accessConfigs, retry again", res.getErrorDetails());
            throw new GetCloudParameterException("Failed to get access configs for the cloud provider. " + getCauseMessages(res.getErrorDetails()), res.getErrorDetails());
        }
        if (res.getStatus().equals(EventStatus.PERMANENTLY_FAILED)) {
            LOGGER.debug("Failed to get platform accessConfigs", res.getErrorDetails());
            throw new PermanentlyFailedException(res.getErrorDetails());
        }
        return res.getCloudAccessConfigs();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform accessConfigs", e);
        throw new OperationException(e);
    }
}
Also used : PermanentlyFailedException(com.sequenceiq.cloudbreak.util.PermanentlyFailedException) GetPlatformCloudAccessConfigsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsResult) GetPlatformCloudAccessConfigsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsRequest) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Retryable(org.springframework.retry.annotation.Retryable)

Example 2 with PermanentlyFailedException

use of com.sequenceiq.cloudbreak.util.PermanentlyFailedException in project cloudbreak by hortonworks.

the class GetPlatformSecurityGroupsHandler method accept.

@Override
public void accept(Event<GetPlatformSecurityGroupsRequest> getPlatformSecurityGroupsRequest) {
    LOGGER.debug("Received event: {}", getPlatformSecurityGroupsRequest);
    GetPlatformSecurityGroupsRequest request = getPlatformSecurityGroupsRequest.getData();
    try {
        CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
        CloudSecurityGroups securityGroups = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().securityGroups(request.getExtendedCloudCredential(), Region.region(request.getRegion()), request.getFilters());
        GetPlatformSecurityGroupsResult getPlatformSecurityGroupsResult = new GetPlatformSecurityGroupsResult(request.getResourceId(), securityGroups);
        request.getResult().onNext(getPlatformSecurityGroupsResult);
        LOGGER.debug("Query platform networks types finished.");
    } catch (PermanentlyFailedException e) {
        request.getResult().onNext(new GetPlatformSecurityGroupsResult(EventStatus.PERMANENTLY_FAILED, e.getMessage(), e, request.getResourceId()));
    } catch (Exception e) {
        request.getResult().onNext(new GetPlatformSecurityGroupsResult(e.getMessage(), e, request.getResourceId()));
    }
}
Also used : PermanentlyFailedException(com.sequenceiq.cloudbreak.util.PermanentlyFailedException) GetPlatformSecurityGroupsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsRequest) GetPlatformSecurityGroupsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsResult) CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) PermanentlyFailedException(com.sequenceiq.cloudbreak.util.PermanentlyFailedException)

Aggregations

PermanentlyFailedException (com.sequenceiq.cloudbreak.util.PermanentlyFailedException)2 GetPlatformCloudAccessConfigsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsRequest)1 GetPlatformCloudAccessConfigsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsResult)1 GetPlatformSecurityGroupsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsRequest)1 GetPlatformSecurityGroupsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformSecurityGroupsResult)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CloudSecurityGroups (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups)1 OperationException (com.sequenceiq.cloudbreak.service.OperationException)1 Retryable (org.springframework.retry.annotation.Retryable)1