org.apache.hc.client5.http.impl.sync

## Class DefaultServiceUnavailableRetryStrategy

- java.lang.Object
- - org.apache.hc.client5.http.impl.sync.DefaultServiceUnavailableRetryStrategy

All Implemented Interfaces:
  ServiceUnavailableRetryStrategy

    @Immutable
    public class DefaultServiceUnavailableRetryStrategy
    extends Object
    implements ServiceUnavailableRetryStrategy

Default implementation of the `ServiceUnavailableRetryStrategy` interface. that retries `503` (Service Unavailable) responses for a fixed number of times at a fixed interval.

Since:
  4.2

### Constructor Summary

Constructors
Constructor and Description
`DefaultServiceUnavailableRetryStrategy()`
`DefaultServiceUnavailableRetryStrategy(int maxRetries, int defaultRetryInterval)`

### Method Summary

Methods
`long` `getRetryInterval(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context)`
`boolean` `retryRequest(org.apache.hc.core5.http.HttpResponse response, int executionCount, org.apache.hc.core5.http.protocol.HttpContext context)` Determines if a method should be retried given the response from the target server.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultServiceUnavailableRetryStrategy

    public DefaultServiceUnavailableRetryStrategy(int maxRetries,
                                          int defaultRetryInterval)

#### DefaultServiceUnavailableRetryStrategy

    public DefaultServiceUnavailableRetryStrategy()

### Method Detail

#### retryRequest

    public boolean retryRequest(org.apache.hc.core5.http.HttpResponse response,
                       int executionCount,
                       org.apache.hc.core5.http.protocol.HttpContext context)

Description copied from interface: `ServiceUnavailableRetryStrategy`
Determines if a method should be retried given the response from the target server.

Specified by:
  `retryRequest` in interface `ServiceUnavailableRetryStrategy`
Parameters:
  `response` - the response from the target server
  `executionCount` - the number of times this method has been unsuccessfully executed
  `context` - the context for the request execution
Returns:
  `true` if the method should be retried, `false` otherwise

#### getRetryInterval

    public long getRetryInterval(org.apache.hc.core5.http.HttpResponse response,
                        org.apache.hc.core5.http.protocol.HttpContext context)

Specified by:
  `getRetryInterval` in interface `ServiceUnavailableRetryStrategy`
Returns:
  The interval between the subsequent retry in milliseconds.