Class BoxUtils

java.lang.Object
edu.byu.hbll.box.internal.util.BoxUtils

public class BoxUtils extends Object
Random utilities used by Box.
Author:
Charles Draper
  • Constructor Details

    • BoxUtils

      public BoxUtils()
  • Method Details

    • retryDateTime

      public static Instant retryDateTime(Instant base, Duration retryDelay, double retryJitter)
      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 the base. 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 the retryJitter 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 from
      retryDelay - the initial or minimum delay before processing again
      retryJitter - a percentage of the calculated delay added or subtracted
      Returns:
      the retry date/time
    • canonicalizeFields

      public static Set<String> canonicalizeFields(Collection<String> fields)
      Converts non _at_doc fields into _at_doc fields.
      Parameters:
      fields - dot-notated fields denoting what should be projected
      Returns:
      the new fields