Interface LoadBalancedRetryPolicy
public interface LoadBalancedRetryPolicy
Retry logic to use for the
LoadBalancerClient.- Author:
- Ryan Baxter, Olga Maciaszek-Sharma
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn true to retry the failed request on the next server from the load balancer.booleanReturn true to retry the failed request on the same server.voidclose(LoadBalancedRetryContext context) Called when the retry operation has ended.voidregisterThrowable(LoadBalancedRetryContext context, Throwable throwable) Called when the execution fails.booleanretryableException(Throwable exception) Returntrueto retry if the provided exception is thrown.booleanretryableStatusCode(int statusCode) If an exception is not thrown when making a request, this method will be called to see if the client would like to retry the request based on the status code returned.
-
Method Details
-
canRetrySameServer
Return true to retry the failed request on the same server. This method may be called more than once when executing a single operation.- Parameters:
context- The context for the retry operation.- Returns:
- True to retry the failed request on the same server; false otherwise.
-
canRetryNextServer
Return true to retry the failed request on the next server from the load balancer. This method may be called more than once when executing a single operation.- Parameters:
context- The context for the retry operation.- Returns:
- True to retry the failed request on the next server from the load balancer; false otherwise.
-
close
Called when the retry operation has ended.- Parameters:
context- The context for the retry operation.
-
registerThrowable
Called when the execution fails.- Parameters:
context- The context for the retry operation.throwable- The throwable from the failed execution.
-
retryableStatusCode
boolean retryableStatusCode(int statusCode) If an exception is not thrown when making a request, this method will be called to see if the client would like to retry the request based on the status code returned. For example, in Cloud Foundry, the router will return a404when an app is not available. Since HTTP clients do not throw an exception when a404is returned,retryableStatusCodeallows clients to force a retry.- Parameters:
statusCode- The HTTP status code.- Returns:
- True if a retry should be attempted; false to just return the response.
-
retryableException
Returntrueto retry if the provided exception is thrown.- Parameters:
exception- theThrowableto evaluate- Returns:
- true to retry on the provided exception
-