private Observable<Long> handleRetryAttemptInternal(DocumentClientException e, int attemptNumber) throws DocumentClientException { RetryPolicy retryPolicy = null; if (e.getStatusCode() == HttpConstants.StatusCodes.BADREQUEST && e.getSubStatusCode() != null && e.getSubStatusCode() == HttpConstants.SubStatusCodes.PARTITION_KEY_MISMATCH) { // If HttpStatusCode is 404 (NotFound) and SubStatusCode is // 1001 (PartitionKeyMismatch), invoke the partition key mismatch retry policy retryPolicy = keyMismatchRetryPolicy; } if (retryPolicy == null || !retryPolicy.shouldRetry(e)) { LOGGER.trace("Execution encontured exception: {}, status code {} sub status code {}. Won't retry!", e.getMessage(), e.getStatusCode(), e.getSubStatusCode()); return Observable.error(e); } LOGGER.trace("Execution encontured exception: {}, status code {} sub status code {}. Will retry in {}ms", e.getMessage(), e.getStatusCode(), e.getSubStatusCode(), retryPolicy.getRetryAfterInMilliseconds()); long waitTime = retryPolicy.getRetryAfterInMilliseconds(); return Observable.just(waitTime); } }
if (e.getStatusCode() == HttpConstants.StatusCodes.FORBIDDEN && e.getSubStatusCode() != null && e.getSubStatusCode() == HttpConstants.SubStatusCodes.FORBIDDEN_WRITEFORBIDDEN) { } else if (e.getStatusCode() == HttpConstants.StatusCodes.NOTFOUND && e.getSubStatusCode() != null && e.getSubStatusCode() == HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE) { e.getMessage(), e.getStatusCode(), e.getSubStatusCode()); return Observable.error(e); e.getMessage(), e.getStatusCode(), e.getSubStatusCode(), retryPolicy.getRetryAfterInMilliseconds());
private static Observable<Long> handleRetryAttempt(Throwable t, int attemptNumber, RxRetryHandler retryPolicy) { Throwable cause = extractDocumentClientCause(t, attemptNumber); if (LOGGER.isDebugEnabled()) { if (cause instanceof DocumentClientException) { DocumentClientException ex = (DocumentClientException) cause; LOGGER.debug("Handling Failure Attempt [{}], StatusCode [{}], SubStatusCode," + " Error: [{}] ", attemptNumber, ex.getStatusCode(), ex.getSubStatusCode(), ex.getError(), ex); } else { LOGGER.debug("Handling Failure Attempt [{}], req [{}]", attemptNumber, cause); } } try { return retryPolicy.handleRetryAttempt(cause, attemptNumber); } catch (Exception e) { return Observable.error(e); } } }