public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
   if (command.getFailureCount() > retryCountLimit) return false;
   if (response.getStatusCode() == 404
       && command.getCurrentRequest().getMethod().equals("DELETE")) {
     command.incrementFailureCount();
     return true;
   } else if (response.getStatusCode() == 409) {
     byte[] content = HttpUtils.closeClientButKeepContentStream(response);
     // Content can be null in the case of HEAD requests
     if (content != null) {
       try {
         AtmosError error =
             utils.parseAtmosErrorFromContent(command, response, new String(content));
         if (error.getCode() == 1006) {
           return backoffHandler.shouldRetryRequest(command, response);
         }
         // don't increment count before here, since backoff handler does already
         command.incrementFailureCount();
       } catch (HttpException e) {
         logger.warn(e, "error parsing response: %s", new String(content));
       }
     } else {
       command.incrementFailureCount();
     }
     return true;
   }
   return false;
 }
Exemplo n.º 2
0
 @Override
 public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
   if (response.getStatusCode() == 503) {
     // Content can be null in the case of HEAD requests
     if (response.getPayload() != null) {
       closeClientButKeepContentStream(response);
       AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response);
       if (error != null) {
         return shouldRetryRequestOnError(command, response, error);
       }
     }
   }
   return false;
 }