com.amazonaws.mturk.filter
Class RetryFilter
java.lang.Object
com.amazonaws.mturk.filter.Filter
com.amazonaws.mturk.filter.RetryFilter
public class RetryFilter
- extends Filter
Default Filter implementation which handles retry of operation on receiving certain retriable errors
which can be configured in the SDK configuration (retriable_errors)
|
Constructor Summary |
RetryFilter()
Use this constructor if you do not want to retry any error |
RetryFilter(java.util.Set<java.lang.String> retriableErrorSet,
int retryMaxAttempts,
long retryDelayMillis)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RetryFilter
public RetryFilter()
- Use this constructor if you do not want to retry any error
RetryFilter
public RetryFilter(java.util.Set<java.lang.String> retriableErrorSet,
int retryMaxAttempts,
long retryDelayMillis)
- Parameters:
retriableErrorSet - - set of errors which should be retriedretryMaxAttempts - - maximum number of retry attemptsretryDelayMillis - - delay between retry attempts
getRetriableErrors
public java.util.Set<java.lang.String> getRetriableErrors()
setRetriableErrors
public void setRetriableErrors(java.util.Set<java.lang.String> retriableErrors)
- Parameters:
retriableErrors - - sets retriable errors set
addRetriableError
public void addRetriableError(java.lang.String error)
- Parameters:
error - - error code for adding to the set of retriable errors
getRetryMaxAttempts
public int getRetryMaxAttempts()
setRetryMaxAttempts
public void setRetryMaxAttempts(int retryMaxAttempts)
getRetryDelayMillis
public long getRetryDelayMillis()
setRetryDelayMillis
public void setRetryDelayMillis(long retryDelayMillis)
execute
public Reply execute(Message m)
throws ServiceException
- Calls the next filter and catches ServiceException. Checks if error is one of the retriable errors and retries.
throws ServiceException if it retry fails or not retriable
- Specified by:
execute in class Filter
- Parameters:
m - - request message got from previous filter
- Returns:
- result of the execution of this filter
throws ServiceException on errors
- Throws:
ServiceException
shouldRetry
protected boolean shouldRetry(ServiceException e,
java.lang.Object requests)
- Parameters:
e - - exception caughtrequests - - the requests which caused the exception
- Returns:
- true if the request can be retried. i.e. check the retriable error set
getDelay
protected long getDelay(int retry)
- Calculates the delay during retries including a jitter