return new RetriableAccessDeniedException(buffer.toString(), failure); default: return new InteroperabilityException(buffer.toString(), failure);
case application: if(failure instanceof RetriableAccessDeniedException) { final Duration duration = ((RetriableAccessDeniedException) failure).getRetry(); if(duration != null) {
@Override public BackgroundException map(final StorageException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(ExceptionUtils.getRootCause(e) instanceof UnknownHostException) { return new NotfoundException(buffer.toString(), e); } switch(e.getHttpStatusCode()) { case 403: return new LoginFailureException(buffer.toString(), e); case 404: return new NotfoundException(buffer.toString(), e); case 304: case 405: case 400: case 411: case 412: return new InteroperabilityException(buffer.toString(), e); case 500: // InternalError // OperationTimedOut return new ConnectionTimeoutException(buffer.toString(), e); case 503: // ServerBusy return new RetriableAccessDeniedException(buffer.toString(), e); } return this.wrap(e, buffer); } }
case RETRYLATER: { final Duration delay = Duration.ofSeconds(response.getRetryAfterSeconds()); throw new RetriableAccessDeniedException(String.format("Job %s not yet loaded into cache", job), delay); if(chunks.isEmpty()) { log.info(String.format("Still missing chunks for file %s for job %s", file.getName(), job)); throw new RetriableAccessDeniedException(String.format("Missing chunks for job %s", job), Duration.ofSeconds(PreferencesFactory.get().getInteger("spectra.retry.delay")));
if(e.getRetry() != null) { return new RetriableAccessDeniedException(buffer.toString(), Duration.ofSeconds(e.getRetry()), e);
switch(failure.getErrorCode()) { case "Throttling": return new RetriableAccessDeniedException(buffer.toString(), e); case "AccessDeniedException": return new AccessDeniedException(buffer.toString(), e);
@Override public BackgroundException map(final IOException failure) { final StringBuilder buffer = new StringBuilder(); if(failure instanceof GoogleJsonResponseException) { final GoogleJsonResponseException error = (GoogleJsonResponseException) failure; this.append(buffer, error.getDetails().getMessage()); switch(error.getDetails().getCode()) { case HttpStatus.SC_FORBIDDEN: final List<GoogleJsonError.ErrorInfo> errors = error.getDetails().getErrors(); for(GoogleJsonError.ErrorInfo info : errors) { if("usageLimits".equals(info.getDomain())) { return new RetriableAccessDeniedException(buffer.toString(), Duration.ofSeconds(5), failure); } } break; } } if(failure instanceof HttpResponseException) { final HttpResponseException response = (HttpResponseException) failure; this.append(buffer, response.getStatusMessage()); return new HttpResponseExceptionMappingService().map(new org.apache.http.client .HttpResponseException(response.getStatusCode(), buffer.toString())); } return super.map(failure); } }
return new RetriableAccessDeniedException(buffer.toString(), delay);