Class MirrorNodeHttpRetryPolicy

java.lang.Object
com.hedera.hashgraph.sdk.MirrorNodeHttpRetryPolicy

public final class MirrorNodeHttpRetryPolicy extends Object
The retry budget for one mirror node REST call.

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 Details

    • defaults

      public static MirrorNodeHttpRetryPolicy defaults()
      A policy with every field at its declared default: five attempts, a 30 s per-attempt bound, a total bound inherited from Client.getRequestTimeout(), 250 ms of initial backoff capped at 8 s, and 408, 429, 500, 502, 503, 504 as the retryable statuses.
      Returns:
      the default policy
    • withMaxAttempts

      public MirrorNodeHttpRetryPolicy withMaxAttempts(int maxAttempts)
      Derive a copy with a different attempt budget.

      Counted per request: one initial request plus up to maxAttempts - 1 retries of that request. A paginated walk gets the budget afresh for each page; what spans the whole walk is getTotalDeadline().

      Parameters:
      maxAttempts - the number of attempts per request, at least 1
      Returns:
      the derived policy
    • withPerAttemptTimeout

      public MirrorNodeHttpRetryPolicy withPerAttemptTimeout(Duration perAttemptTimeout)
      Derive a copy with a different per-attempt bound.
      Parameters:
      perAttemptTimeout - the bound on one attempt, end to end; Duration.ZERO means no per-attempt cap, leaving the remaining total as the only bound
      Returns:
      the derived policy
    • withTotalDeadline

      public MirrorNodeHttpRetryPolicy withTotalDeadline(Duration totalDeadline)
      Derive a copy with a different total bound.
      Parameters:
      totalDeadline - the bound on the whole call, every page and every backoff included; Duration.ZERO means inherit Client.getRequestTimeout() rather than "no bound"
      Returns:
      the derived policy
    • withInitialBackoff

      public MirrorNodeHttpRetryPolicy withInitialBackoff(Duration initialBackoff)
      Derive a copy with a different backoff base.

      Named initialBackoff rather than minBackoff because 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

      public MirrorNodeHttpRetryPolicy withMaxBackoff(Duration maxBackoff)
      Derive a copy with a different backoff cap.
      Parameters:
      maxBackoff - the cap on the computed backoff
      Returns:
      the derived policy
    • withRetryableStatusCodes

      public MirrorNodeHttpRetryPolicy withRetryableStatusCodes(List<Integer> retryableStatusCodes)
      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

      public Duration getPerAttemptTimeout()
      Extract the per-attempt bound.
      Returns:
      the bound on one attempt; Duration.ZERO means no per-attempt cap
    • getTotalDeadline

      public Duration getTotalDeadline()
      Extract the total bound.
      Returns:
      the bound on the whole call; Duration.ZERO means inherit the client's request timeout
    • getInitialBackoff

      public Duration getInitialBackoff()
      Extract the backoff base.
      Returns:
      the base of the exponential
    • getMaxBackoff

      public Duration getMaxBackoff()
      Extract the backoff cap.
      Returns:
      the cap on the computed backoff
    • getRetryableStatusCodes

      public List<Integer> 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

      public String toString()
      Overrides:
      toString in class Object