Package edu.byu.hbll.box.internal.util
Class BoxUtils
java.lang.Object
edu.byu.hbll.box.internal.util.BoxUtils
Random utilities used by Box.
- Author:
- Charles Draper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncanonicalizeFields
(Collection<String> fields) Converts non _at_doc fields into _at_doc fields.static Instant
retryDateTime
(Instant base, Duration retryDelay, double retryJitter) Calculates a retry date/time based on a base date/time (eg.
-
Constructor Details
-
BoxUtils
public BoxUtils()
-
-
Method Details
-
retryDateTime
Calculates a retry date/time based on a base date/time (eg. first attempt), a retry delay, and retry jitter.The minimum (ie, the first) delay corresponds to the
retryDelay
. Subsequent delays are calculated by taking the difference between NOW and thebase
. This essentially doubles the delay each time. A random amount of jitter +/- is added to the calculated delay. The bounds of the jitter is based on theretryJitter
parameter which is a percentage of the calculated delay. This random variation can be critical if failures occur during certain windows of time or as part of batches with other conflicting items.Examples:
- Given a
base
of 1 second ago,retryDelay
of 1 minute,retryJitter
of 0.5, the retry date/time will be anywhere from 30 seconds to 90 seconds from NOW (minimum of 1 minute +/- 1 minute * 0.5). - Given a
base
of 8 minutes ago,retryDelay
of 1 minute,retryJitter
of 0.5, the retry date/time will be anywhere from 4 minutes to 12 minutes from NOW (8 minutes +/- 8 minutes * 0.5)..
- Parameters:
base
- the base date/time the retry date/time is calculated fromretryDelay
- the initial or minimum delay before processing againretryJitter
- a percentage of the calculated delay added or subtracted- Returns:
- the retry date/time
- Given a
-
canonicalizeFields
Converts non _at_doc fields into _at_doc fields.- Parameters:
fields
- dot-notated fields denoting what should be projected- Returns:
- the new fields
-