@Override public boolean isClockSkewException() { return Optional.ofNullable(awsErrorDetails) .map(a -> AwsErrorCode.CLOCK_SKEW_ERROR_CODES.contains(a.errorCode())) .orElse(false); }
@Override public boolean isThrottlingException() { return super.isThrottlingException() || Optional.ofNullable(awsErrorDetails) .map(a -> AwsErrorCode.THROTTLING_ERROR_CODES.contains(a.errorCode())) .orElse(false); }
@Override public boolean shouldRetry(RetryPolicyContext context) { Exception ex = context.exception(); if (ex instanceof AwsServiceException) { AwsServiceException exception = (AwsServiceException) ex; return retryableErrorCodes.contains(exception.awsErrorDetails().errorCode()); } return false; }
private BuilderImpl(AwsErrorDetails awsErrorDetails) { this.errorMessage = awsErrorDetails.errorMessage(); this.errorCode = awsErrorDetails.errorCode(); this.serviceName = awsErrorDetails.serviceName(); this.sdkHttpResponse = awsErrorDetails.sdkHttpResponse(); this.rawResponse = awsErrorDetails.rawResponse(); }
@Override public FeatureState getFeatureState(final Feature feature) { final GetObjectRequest getRequest = GetObjectRequest.builder() .bucket(s3TogglzProperties.getBucketName()) .key(keyForFeature(feature)) .build(); try (ResponseInputStream<GetObjectResponse> responseStream = s3Client.getObject(getRequest)) { if (responseStream != null) { final FeatureStateStorageWrapper wrapper = objectMapper.reader() .forType(FeatureStateStorageWrapper.class) .readValue(responseStream); return FeatureStateStorageWrapper.featureStateForWrapper(feature, wrapper); } } catch (final S3Exception ae) { if (ERR_NO_SUCH_KEY.equals(ae.awsErrorDetails().errorCode())) { return null; } throw ae; } catch (final IOException e) { throw new RuntimeException("Failed to get the feature state", e); } return null; }
public FeatureState retrieveFeatureStateFromS3(final Feature feature) { final GetObjectRequest getRequest = GetObjectRequest.builder() .bucket(togglzProperties.getS3().getBucketName()) .key(keyForFeature(feature)) .build(); try (final ResponseInputStream<GetObjectResponse> responseStream = s3Client.getObject(getRequest)) { if (responseStream != null) { final FeatureStateStorageWrapper wrapper = objectMapper.reader() .forType(FeatureStateStorageWrapper.class) .readValue(responseStream); return FeatureStateStorageWrapper.featureStateForWrapper(feature, wrapper); } } catch (final S3Exception ae) { if (ERR_NO_SUCH_KEY.equals(ae.awsErrorDetails().errorCode()) || ae.awsErrorDetails().sdkHttpResponse().statusCode() == 404) { return null; } throw ae; } catch (final IOException e) { throw new RuntimeException("Failed to get the feature state", e); } return null; }