YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.browser.BrowseRetryPolicy Class Reference

Decides whether and how a failed Browse request is repeated, so a short network drop does not show up as an empty folder. More...

Collaboration diagram for de.yaacc.browser.BrowseRetryPolicy:
Collaboration graph

Classes

interface  Sleeper
 Sleeps; replaceable so tests do not wait. More...
 

Public Member Functions

ContentDirectoryBrowseResult execute (Supplier< ContentDirectoryBrowseResult > attempt, BooleanSupplier cancelled)
 Runs attempt until it gives a result that is not retriable, the tries are used up, cancelled turns true or the thread is interrupted while waiting.
 

Static Public Member Functions

static boolean isRetriable (ContentDirectoryBrowseResult result)
 
static boolean isFailure (ContentDirectoryBrowseResult result)
 
static long backoffMillisBefore (int attemptNumber)
 

Static Public Attributes

static final int MAX_ATTEMPTS = 3
 Total number of tries, the first one included.
 
static final long[] BACKOFF_MILLIS = {500L, 1500L}
 Wait before try 2 and before try 3.
 

Detailed Description

Decides whether and how a failed Browse request is repeated, so a short network drop does not show up as an empty folder.

No Android classes: unit-testable on the JVM.

Rules:

  • At most MAX_ATTEMPTS tries in total; the waits before try 2 and 3 are BACKOFF_MILLIS (500 ms, 1500 ms).
  • A result is repeated when there is no result at all (no provider device right now, discovery may bring it back), or when it carries a transport failure (no connection, timeout, no answer, device missing from the registry).
  • It is not repeated when the server answered with a UPnP error (for example an unsupported sort criterion: the same request would fail the same way), when it has content (also an empty folder), or when it has neither content nor failure.
  • It stops early when the task is cancelled or the waiting thread is interrupted.

Meant for the worker thread only: execute sleeps.

Member Function Documentation

◆ backoffMillisBefore()

static long de.yaacc.browser.BrowseRetryPolicy.backoffMillisBefore ( int attemptNumber)
static
Parameters
attemptNumber2 or 3 (the try that follows the wait)
Returns
the wait before that try in milliseconds, 0 for the first try

Referenced by de.yaacc.browser.BrowseRetryPolicy.execute().

Here is the caller graph for this function:

◆ execute()

ContentDirectoryBrowseResult de.yaacc.browser.BrowseRetryPolicy.execute ( Supplier< ContentDirectoryBrowseResult > attempt,
BooleanSupplier cancelled )

Runs attempt until it gives a result that is not retriable, the tries are used up, cancelled turns true or the thread is interrupted while waiting.

Returns
the result of the last try that ran; null if cancelled before the first try or the last try gave no result
Here is the call graph for this function:

◆ isFailure()

static boolean de.yaacc.browser.BrowseRetryPolicy.isFailure ( ContentDirectoryBrowseResult result)
static
Returns
true if result is a failed load: no result at all or a result with a failure (retriable or not); a result without content and without failure is not
Here is the call graph for this function:

◆ isRetriable()

static boolean de.yaacc.browser.BrowseRetryPolicy.isRetriable ( ContentDirectoryBrowseResult result)
static
Returns
true if result is no answer of the server, so another try can help

Referenced by de.yaacc.browser.BrowseRetryPolicy.execute().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: