Package org.apache.druid.rpc
Class StandardRetryPolicy
- java.lang.Object
-
- org.apache.druid.rpc.StandardRetryPolicy
-
- All Implemented Interfaces:
ServiceRetryPolicy
public class StandardRetryPolicy extends Object implements ServiceRetryPolicy
Retry policy configurable with a maximum number of attempts and min/max wait time. The policy retries on IOExceptions and ChannelExceptions, and on HTTP 500, 502, 503, and 504. Other exceptions and other HTTP status codes are considered nonretryable errors.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStandardRetryPolicy.Builder
-
Field Summary
-
Fields inherited from interface org.apache.druid.rpc.ServiceRetryPolicy
UNLIMITED
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StandardRetryPolicyaboutAnHour()Retry policy that uses up to about an hour of total wait time.static StandardRetryPolicy.Builderbuilder()longmaxAttempts()Returns the maximum number of desired attempts, orServiceRetryPolicy.UNLIMITEDif unlimited.longmaxWaitMillis()Returns the maximum wait time between retries.longminWaitMillis()Returns the minimum wait time between retries.static StandardRetryPolicynoRetries()Retry policy that never retries.booleanretryHttpResponse(org.jboss.netty.handler.codec.http.HttpResponse response)Returns whether the given HTTP response can be retried.booleanretryLoggable()Returns whether to log the cause of failure before retryingbooleanretryNotAvailable()Returns whether service-not-available, i.e.booleanretryThrowable(Throwable t)Returns whether the given exception can be retried.static StandardRetryPolicyunlimited()Standard unlimited retry policy.static StandardRetryPolicyunlimitedWithoutRetryLogging()Standard unlimited retry policy along with muted the logging for the retries.
-
-
-
Method Detail
-
builder
public static StandardRetryPolicy.Builder builder()
-
unlimited
public static StandardRetryPolicy unlimited()
Standard unlimited retry policy. Never stops retrying as long as errors remain retryable. SeeServiceClientdocumentation for details on what errors are retryable.
-
unlimitedWithoutRetryLogging
public static StandardRetryPolicy unlimitedWithoutRetryLogging()
Standard unlimited retry policy along with muted the logging for the retries.
-
aboutAnHour
public static StandardRetryPolicy aboutAnHour()
Retry policy that uses up to about an hour of total wait time. Note that this is just the total waiting time between attempts. It does not include the time that each attempt takes to execute.
-
noRetries
public static StandardRetryPolicy noRetries()
Retry policy that never retries.
-
maxAttempts
public long maxAttempts()
Description copied from interface:ServiceRetryPolicyReturns the maximum number of desired attempts, orServiceRetryPolicy.UNLIMITEDif unlimited. A value of 1 means no retries. Zero is invalid.- Specified by:
maxAttemptsin interfaceServiceRetryPolicy
-
minWaitMillis
public long minWaitMillis()
Description copied from interface:ServiceRetryPolicyReturns the minimum wait time between retries.- Specified by:
minWaitMillisin interfaceServiceRetryPolicy
-
maxWaitMillis
public long maxWaitMillis()
Description copied from interface:ServiceRetryPolicyReturns the maximum wait time between retries.- Specified by:
maxWaitMillisin interfaceServiceRetryPolicy
-
retryHttpResponse
public boolean retryHttpResponse(org.jboss.netty.handler.codec.http.HttpResponse response)
Description copied from interface:ServiceRetryPolicyReturns whether the given HTTP response can be retried. The response will have a non-2xx error code.- Specified by:
retryHttpResponsein interfaceServiceRetryPolicy
-
retryThrowable
public boolean retryThrowable(Throwable t)
Description copied from interface:ServiceRetryPolicyReturns whether the given exception can be retried.- Specified by:
retryThrowablein interfaceServiceRetryPolicy
-
retryLoggable
public boolean retryLoggable()
Description copied from interface:ServiceRetryPolicyReturns whether to log the cause of failure before retrying- Specified by:
retryLoggablein interfaceServiceRetryPolicy
-
retryNotAvailable
public boolean retryNotAvailable()
Description copied from interface:ServiceRetryPolicyReturns whether service-not-available, i.e. emptyServiceLocations.getLocations(), can be retried.- Specified by:
retryNotAvailablein interfaceServiceRetryPolicy
-
-