Class SnowflakeUtil


  • public class SnowflakeUtil
    extends Object
    Author:
    jhuang
    • Constructor Detail

      • SnowflakeUtil

        public SnowflakeUtil()
    • Method Detail

      • checkErrorAndThrowExceptionIncludingReauth

        public static void checkErrorAndThrowExceptionIncludingReauth​(com.fasterxml.jackson.databind.JsonNode rootNode)
                                                               throws SnowflakeSQLException
        Throws:
        SnowflakeSQLException
      • getEpochTimeInMicroSeconds

        public static long getEpochTimeInMicroSeconds()
      • logResponseDetails

        public static void logResponseDetails​(org.apache.http.HttpResponse response,
                                              SFLogger logger)
        A utility to log response details.

        Used when there is an error in http response

        Parameters:
        response - http response get from server
        logger - logger object
      • createDefaultExecutorService

        public static ThreadPoolExecutor createDefaultExecutorService​(String threadNamePrefix,
                                                                      int parallel)
        Returns a new thread pool configured with the default settings.
        Parameters:
        threadNamePrefix - prefix of the thread name
        parallel - the number of concurrency
        Returns:
        A new thread pool configured with the default settings.
      • isBlank

        public static boolean isBlank​(String input)
      • randomAlphaNumeric

        public static String randomAlphaNumeric​(int count)
      • systemGetProperty

        public static String systemGetProperty​(String property)
        System.getProperty wrapper. If System.getProperty raises an SecurityException, it is ignored and returns null.
        Parameters:
        property - the property name
        Returns:
        the property value if set, otherwise null.
      • systemGetEnv

        public static String systemGetEnv​(String env)
        System.getenv wrapper. If System.getenv raises an SecurityException, it is ignored and returns null.
        Parameters:
        env - the environment variable name.
        Returns:
        the environment variable value if set, otherwise null.
      • systemSetEnv

        public static void systemSetEnv​(String key,
                                        String value)
        System.setEnv function. Can be used for unit tests.
      • systemUnsetEnv

        public static void systemUnsetEnv​(String key)
        System.unsetEnv function to remove a system environment parameter in the map
        Parameters:
        key -
      • getSecondsFromMillis

        public static long getSecondsFromMillis​(long millis)
        Round the time value from milliseconds to seconds so the seconds can be used to create SimpleDateFormatter. Negative values have to be rounded to the next negative value, while positive values should be cut off with no rounding.
        Parameters:
        millis -
        Returns:
      • getTimeInSessionTimezone

        public static Time getTimeInSessionTimezone​(Long time,
                                                    int nanos)
        Get the time value in session timezone instead of UTC calculation done by java.sql.Time.
        Parameters:
        time - time in seconds
        nanos - nanoseconds
        Returns:
        time in session timezone