Class Utils


  • public class Utils
    extends Object
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • pollUntil

        public static <T> T pollUntil​(Callable<T> callable,
                                      @Nonnull
                                      java.util.function.Predicate<T> predicate,
                                      int timeOutInSeconds)
        Get resource repeatedly until it match the predicate or timeout, will return null when meet exception with default pollingInterval = 1s
        Parameters:
        callable - callable to get resource
        predicate - function that evaluate the resource
        timeOutInSeconds - max time for the method
        Returns:
        the first resource which fit the predicate or the last result before timeout
      • pollUntil

        public static <T> T pollUntil​(Callable<T> callable,
                                      @Nonnull
                                      java.util.function.Predicate<T> predicate,
                                      int timeOutInSeconds,
                                      int pollingInterval)
        Get resource repeatedly until it match the predicate or timeout, will return null when meet exception
        Parameters:
        callable - callable to get resource
        predicate - function that evaluate the resource
        timeOutInSeconds - max time for the method
        pollingInterval - polling interval
        Returns:
        the first resource which fit the predicate or the last result before timeout
      • toCpuString

        public static String toCpuString​(double cpuCount)
        Converts cpu count from double to String
        Parameters:
        cpuCount - cpu count, 1 core can be represented by 1 or 1000m
        Returns:
        cpu String
      • toMemoryString

        public static String toMemoryString​(double sizeInGB)
        Converts memory count from double to String
        Parameters:
        sizeInGB - memory in GB
        Returns:
        memory String
      • isInteger

        private static boolean isInteger​(double sizeInGB)