Class ProseoUtil

java.lang.Object
de.dlr.proseo.model.util.ProseoUtil

public class ProseoUtil extends Object
Class to hold general utility methods
Author:
Ernst Melchinger
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Maximum number of retries for database concurrency issues
    static final int
    Wait interval in ms before retrying database operation
    static final int
    Maximum number of retries for Kubernetes API issues
    static final int
    Wait interval in ms before retrying Kubernetes API operation
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Wait a slightly randomized amount of time based on database wait parameters
    static void
    dbWait(int attempt)
    Wait a slightly randomized amount of time based on database wait parameters (increasing progressively with the number of attempts)
    static String
    Escape a give String to make it safe to be printed or stored.
    static String
    Extracts the prosEO-compliant message from the "Warning" header, if any
    static void
    Wait a slightly randomized amount of time based on Kubernetes wait parameters
    static void
    kubeWait(int attempt)
    Wait a slightly randomized amount of time based on Kubernetes wait parameters (increasing progressively with the number of attempts)
    static void
    randomWait(int attempt, int waitInterval)
    Wait a slightly randomized amount of time, increasing progressively with the number of attempts

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DB_MAX_RETRY

      public static final int DB_MAX_RETRY
      Maximum number of retries for database concurrency issues
      See Also:
    • DB_WAIT

      public static final int DB_WAIT
      Wait interval in ms before retrying database operation
      See Also:
    • K8S_MAX_RETRY

      public static final int K8S_MAX_RETRY
      Maximum number of retries for Kubernetes API issues
      See Also:
    • K8S_WAIT

      public static final int K8S_WAIT
      Wait interval in ms before retrying Kubernetes API operation
      See Also:
  • Constructor Details

    • ProseoUtil

      public ProseoUtil()
  • Method Details

    • escape

      public static String escape(String s)
      Escape a give String to make it safe to be printed or stored.
      Parameters:
      s - The input String.
      Returns:
      The output String.
    • extractProseoMessage

      public static String extractProseoMessage(String warningHeader)
      Extracts the prosEO-compliant message from the "Warning" header, if any
      Parameters:
      warningHeader - the HTTP Warning header to extract the message from
      Returns:
      the prosEO-compliant message, if there is one, or the unchanged warning header, if there is one, or null otherwise
    • randomWait

      public static void randomWait(int attempt, int waitInterval)
      Wait a slightly randomized amount of time, increasing progressively with the number of attempts
      Parameters:
      attempt - the retry attempt count
      waitInterval - the base wait interval to apply
    • dbWait

      public static void dbWait()
      Wait a slightly randomized amount of time based on database wait parameters
    • dbWait

      public static void dbWait(int attempt)
      Wait a slightly randomized amount of time based on database wait parameters (increasing progressively with the number of attempts)
      Parameters:
      attempt - the retry attempt count
    • kubeWait

      public static void kubeWait()
      Wait a slightly randomized amount of time based on Kubernetes wait parameters
    • kubeWait

      public static void kubeWait(int attempt)
      Wait a slightly randomized amount of time based on Kubernetes wait parameters (increasing progressively with the number of attempts)
      Parameters:
      attempt - the retry attempt count