p2p/discovery/backoff/backoff
library
Classes
-
AttemptBackoff
-
A base class for backoff strategies that track attempt numbers
-
BackoffCache
-
Cache for peer information with backoff
-
BackoffConnector
-
A utility to connect to peers, but only if we have not recently tried connecting to them already
-
BackoffDiscovery
-
BackoffDiscovery is an implementation of discovery that caches peer data and attenuates repeated queries
-
BackoffStrategy
-
Describes how backoff will be implemented. BackoffStrategies are stateful.
-
Clock
-
Interface for getting the current time
-
ConnCacheData
-
Data stored in the connection cache
-
ExponentialBackoff
-
A backoff strategy based on an exponential function of the attempt number
-
ExponentialDecorrelatedJitter
-
A backoff strategy that uses decorrelated jitter with exponential backoff
-
FixedBackoff
-
A backoff strategy with a constant delay
-
LRUCache<K, V>
-
A simple LRU (Least Recently Used) cache implementation
-
PolynomialBackoff
-
A backoff strategy based on a polynomial function of the attempt number
-
RandomizedBackoff
-
A base class for randomized backoff strategies
-
RealClock
-
Real implementation of Clock using system time
Functions
-
boundedDuration(Duration d, Duration min, Duration max)
→ Duration
-
Returns a duration bounded between min and max
-
checkUpdates(Map<PeerId, AddrInfo> orig, Map<PeerId, AddrInfo> update)
→ bool
-
Checks if the peer addresses have changed
-
findPeerDispatcher(BackoffCache c, Stream<AddrInfo> peerStream)
→ void
-
Dispatches peers from a discovery query to all registered channels
-
findPeerReceiver(StreamController<AddrInfo> peerController, Stream<AddrInfo> evtStream, List<AddrInfo> rcvPeers)
→ void
-
Receives peers from a dispatcher and forwards them to a result channel
-
fullJitter(Duration duration, Duration min, Duration max, Random rng)
→ Duration
-
FullJitter returns a random number, uniformly chosen from the range
min, boundedDur
.
boundedDur is the duration bounded between min and max.
-
newExponentialBackoff(Duration min, Duration max, Jitter jitter, Duration timeUnits, double base, Duration offset, Random rng)
→ BackoffFactory
-
Creates a BackoffFactory with backoff of the form base^x + offset where x is the attempt number
jitter is the function for adding randomness around the backoff
timeUnits are the units of time the base^x is evaluated in
-
newExponentialDecorrelatedJitter(Duration min, Duration max, double base, Random rng)
→ BackoffFactory
-
Creates a BackoffFactory with backoff of the roughly of the form base^x where x is the attempt number.
Delays start at the minimum duration and after each attempt delay = rand(min, delay * base), bounded by the max
See https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ for more information
-
newFixedBackoff(Duration delay)
→ BackoffFactory
-
Creates a BackoffFactory with a constant backoff duration
-
newPolynomialBackoff(Duration min, Duration max, Jitter jitter, Duration timeUnits, List<double> polyCoefs, Random rng)
→ BackoffFactory
-
Creates a BackoffFactory with backoff of the form c0x^0, c1x^1, ...cn*x^n where x is the attempt number
jitter is the function for adding randomness around the backoff
timeUnits are the units of time the polynomial is evaluated in
polyCoefs is the array of polynomial coefficients from
c0, c1, ... cn
-
noJitter(Duration duration, Duration min, Duration max, Random rng)
→ Duration
-
NoJitter returns the duration bounded between min and max