It is a value, not client state: it is resolved per call as package default, then the
Client's policy, then any per-query setter, and carried into the call by value. That lets
concurrent calls hold different budgets while sharing one connection pool.
Instances are derived from defaults() with the withX methods. There is no public
constructor, so a policy with a zero attempt count or a null status list — five attempts that never
retry, silently — is unreachable.
The retryable set is data rather than a rule in prose: "5xx" is read differently by every
implementer, and 501, 505, 506, 507, 508, 510 and
511 all describe a server that will answer identically next time.
-
Method Summary
Modifier and TypeMethodDescriptionstatic MirrorNodeHttpRetryPolicydefaults()A policy with every field at its declared default: five attempts, a 30 s per-attempt bound, a total bound inherited fromClient.getRequestTimeout(), 250 ms of initial backoff capped at 8 s, and408, 429, 500, 502, 503, 504as the retryable statuses.Extract the backoff base.intExtract the attempt budget.Extract the backoff cap.Extract the per-attempt bound.Extract the retryable status set.Extract the total bound.booleanisRetryable(int statusCode) Whether a status is worth repeating the exchange for.toString()withInitialBackoff(Duration initialBackoff) Derive a copy with a different backoff base.withMaxAttempts(int maxAttempts) Derive a copy with a different attempt budget.withMaxBackoff(Duration maxBackoff) Derive a copy with a different backoff cap.withPerAttemptTimeout(Duration perAttemptTimeout) Derive a copy with a different per-attempt bound.withRetryableStatusCodes(List<Integer> retryableStatusCodes) Derive a copy with a different retryable status set.withTotalDeadline(Duration totalDeadline) Derive a copy with a different total bound.
-
Method Details
-
defaults
A policy with every field at its declared default: five attempts, a 30 s per-attempt bound, a total bound inherited fromClient.getRequestTimeout(), 250 ms of initial backoff capped at 8 s, and408, 429, 500, 502, 503, 504as the retryable statuses.- Returns:
- the default policy
-
withMaxAttempts
Derive a copy with a different attempt budget.Counted per request: one initial request plus up to
maxAttempts - 1retries of that request. A paginated walk gets the budget afresh for each page; what spans the whole walk isgetTotalDeadline().- Parameters:
maxAttempts- the number of attempts per request, at least 1- Returns:
- the derived policy
-
withPerAttemptTimeout
Derive a copy with a different per-attempt bound.- Parameters:
perAttemptTimeout- the bound on one attempt, end to end;Duration.ZEROmeans no per-attempt cap, leaving the remaining total as the only bound- Returns:
- the derived policy
-
withTotalDeadline
Derive a copy with a different total bound.- Parameters:
totalDeadline- the bound on the whole call, every page and every backoff included;Duration.ZEROmeans inheritClient.getRequestTimeout()rather than "no bound"- Returns:
- the derived policy
-
withInitialBackoff
Derive a copy with a different backoff base.Named
initialBackoffrather thanminBackoffbecause with full jitter the draw is from[0, min(maxBackoff, initialBackoff * 2^n)), so there is no floor — the value is the base of the exponential, not a minimum wait.- Parameters:
initialBackoff- the base of the exponential- Returns:
- the derived policy
-
withMaxBackoff
Derive a copy with a different backoff cap.- Parameters:
maxBackoff- the cap on the computed backoff- Returns:
- the derived policy
-
withRetryableStatusCodes
Derive a copy with a different retryable status set.- Parameters:
retryableStatusCodes- the statuses worth repeating the exchange for- Returns:
- the derived policy
-
getMaxAttempts
public int getMaxAttempts()Extract the attempt budget.- Returns:
- the number of attempts per request
-
getPerAttemptTimeout
Extract the per-attempt bound.- Returns:
- the bound on one attempt;
Duration.ZEROmeans no per-attempt cap
-
getTotalDeadline
Extract the total bound.- Returns:
- the bound on the whole call;
Duration.ZEROmeans inherit the client's request timeout
-
getInitialBackoff
Extract the backoff base.- Returns:
- the base of the exponential
-
getMaxBackoff
Extract the backoff cap.- Returns:
- the cap on the computed backoff
-
getRetryableStatusCodes
Extract the retryable status set.- Returns:
- an unmodifiable list of status codes
-
isRetryable
public boolean isRetryable(int statusCode) Whether a status is worth repeating the exchange for.- Parameters:
statusCode- the status the mirror node answered with- Returns:
- true if it should be retried
-
toString
-